Magellan Linux

Annotation of /trunk/installer/include/read_disk.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1026 - (hide annotations) (download) (as text)
Sun May 30 17:43:44 2010 UTC (13 years, 11 months ago) by niro
File MIME type: application/x-sh
File size: 2093 byte(s)
-fixed header
-uuid support
-drop partition_id_2_fs_name cruft and use mount -f --guess-fstype instead
-better bootflag handling
-suppress logical containers of secondary partition types
-get disk/partition information from hwinfo
1 niro 773 #!/bin/bash
2 niro 1026 # $Id$
3 niro 773
4 niro 774 source include/hwdetection.sh
5 niro 773
6     # use C locale
7     export LC_ALL=C
8    
9     nocdrom()
10     {
11     local i
12     local item="$1"
13    
14     for i in ${ALL_CDROMS}
15     do
16     [[ ${i} = ${item} ]] && return 1
17     done
18    
19     return 0
20     }
21    
22     query_partition_disk_setup()
23     {
24     local i
25     local partition
26     local filesystem
27     local mountpoint
28     local command="$1"
29     local given_partition="$2"
30    
31     #
32     #--overwrite
33    
34     for i in ${PARTITION_DISK_SETUP}
35     do
36     partition=$(echo ${i} | cut -d: -f1)
37     filesystem=$(echo ${i} | cut -d: -f2)
38     mountpoint=$(echo ${i} | cut -d: -f3)
39    
40     if [[ ${partition} = ${given_partition} ]]
41     then
42     case ${command} in
43     --filesystem) echo "${filesystem}"; return 0;;
44     --mountpoint) echo "${mountpoint}"; return 0;;
45     --delete) export PARTITION_DISK_SETUP="${PARTITION_DISK_SETUP/${i}/}"; return 0;;
46     esac
47     fi
48     done
49     }
50    
51 niro 1026 # all disks, but exclude all ramdisks
52 niro 773 ALL_DISKS="$(get_hwinfo disk | sed '/\/dev\/ram[0-9].*/d' )"
53     ALL_CDROMS="$(get_hwinfo cdrom)"
54    
55     for disk in ${ALL_DISKS}
56     do
57     # exclude cdroms
58     nocdrom ${disk} || continue
59    
60 niro 1026 echo "${disk}|${disk}"
61 niro 773
62 niro 1026 # while read partition size id boot
63     while read partition blurb
64 niro 773 do
65     # size
66 niro 1026 size="$(sfdisk -s ${partition})"
67     # fstype
68     fstype="$(mount -f --guess-fstype ${partition})"
69 niro 773 # bootable flag
70 niro 1026 boot="$(fdisk -l ${disk} | grep ${partition} | grep \* | sed 's/.*\(*\).*/b/')"
71 niro 773 # # swap
72     # if [[ ${id} = 82 ]]
73     # then
74     # mountpoint="swap"
75     # format="swap"
76     # export PARTITION_DISK_SETUP="${PARTITION_DISK_SETUP} ${disk}:swap:swap"
77     # else
78     # mountpoint, but detect any swap
79 niro 1026 mountpoint="$(query_partition_disk_setup --mountpoint ${partition})"
80 niro 773 # filesystem to format
81 niro 1026 format="$(query_partition_disk_setup --filesystem ${partition})"
82 niro 773 # fi
83    
84 niro 1026 # do not print unkown disk with a size of 1
85     # these disks are containers for secondary partition types
86     if [[ ${fstype} = unknown ]] && [ ${size} -eq 1 ]
87     then
88     continue
89     fi
90    
91 niro 773 echo -n "|${partition}"
92     echo -n "|${size}"
93 niro 1026 echo -n "|${fstype}"
94 niro 773 echo -n "|${boot}"
95     echo -n "|${mountpoint}"
96     echo -n "|${format}"
97     echo
98    
99     done << EOF
100 niro 1026 $(get_hwinfo partition | grep ${disk})
101 niro 773 EOF
102     done

Properties

Name Value
svn:executable *