Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1078 - (hide annotations) (download) (as text)
Mon Jun 28 17:36:12 2010 UTC (13 years, 10 months ago) by niro
File MIME type: application/x-sh
File size: 1972 byte(s)
-move to next disk, if partition is empty
1 niro 773 #!/bin/bash
2 niro 1026 # $Id$
3 niro 773
4 niro 1034 source /etc/installer.conf
5     source ${INSTALLER_DIR}/include/hwdetection.sh
6 niro 773
7     # use C locale
8     export LC_ALL=C
9    
10     nocdrom()
11     {
12     local i
13     local item="$1"
14    
15     for i in ${ALL_CDROMS}
16     do
17     [[ ${i} = ${item} ]] && return 1
18     done
19    
20     return 0
21     }
22    
23     query_partition_disk_setup()
24     {
25     local i
26     local partition
27     local filesystem
28     local mountpoint
29     local command="$1"
30     local given_partition="$2"
31    
32     for i in ${PARTITION_DISK_SETUP}
33     do
34     partition=$(echo ${i} | cut -d: -f1)
35     filesystem=$(echo ${i} | cut -d: -f2)
36     mountpoint=$(echo ${i} | cut -d: -f3)
37    
38     if [[ ${partition} = ${given_partition} ]]
39     then
40     case ${command} in
41     --filesystem) echo "${filesystem}"; return 0;;
42     --mountpoint) echo "${mountpoint}"; return 0;;
43     --delete) export PARTITION_DISK_SETUP="${PARTITION_DISK_SETUP/${i}/}"; return 0;;
44     esac
45     fi
46     done
47     }
48    
49 niro 1026 # all disks, but exclude all ramdisks
50 niro 773 ALL_DISKS="$(get_hwinfo disk | sed '/\/dev\/ram[0-9].*/d' )"
51     ALL_CDROMS="$(get_hwinfo cdrom)"
52    
53     for disk in ${ALL_DISKS}
54     do
55     # exclude cdroms
56     nocdrom ${disk} || continue
57    
58 niro 1026 echo "${disk}|${disk}"
59 niro 773
60 niro 1026 while read partition blurb
61 niro 773 do
62 niro 1078 # continue if partition is empty
63     [[ -z ${partition} ]] && continue
64    
65 niro 773 # 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 1035 # mountpoint, but detect any swap
72     mountpoint="$(query_partition_disk_setup --mountpoint ${partition})"
73     # filesystem to format
74     format="$(query_partition_disk_setup --filesystem ${partition})"
75 niro 773
76 niro 1026 # do not print unkown disk with a size of 1
77     # these disks are containers for secondary partition types
78     if [[ ${fstype} = unknown ]] && [ ${size} -eq 1 ]
79     then
80     continue
81     fi
82    
83 niro 773 echo -n "|${partition}"
84     echo -n "|${size}"
85 niro 1026 echo -n "|${fstype}"
86 niro 773 echo -n "|${boot}"
87     echo -n "|${mountpoint}"
88     echo -n "|${format}"
89     echo
90    
91     done << EOF
92 niro 1026 $(get_hwinfo partition | grep ${disk})
93 niro 773 EOF
94     done

Properties

Name Value
svn:executable *