Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1026 - (show 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 #!/bin/bash
2 # $Id$
3
4 source include/hwdetection.sh
5
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 # all disks, but exclude all ramdisks
52 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 echo "${disk}|${disk}"
61
62 # while read partition size id boot
63 while read partition blurb
64 do
65 # size
66 size="$(sfdisk -s ${partition})"
67 # fstype
68 fstype="$(mount -f --guess-fstype ${partition})"
69 # bootable flag
70 boot="$(fdisk -l ${disk} | grep ${partition} | grep \* | sed 's/.*\(*\).*/b/')"
71 # # 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 mountpoint="$(query_partition_disk_setup --mountpoint ${partition})"
80 # filesystem to format
81 format="$(query_partition_disk_setup --filesystem ${partition})"
82 # fi
83
84 # 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 echo -n "|${partition}"
92 echo -n "|${size}"
93 echo -n "|${fstype}"
94 echo -n "|${boot}"
95 echo -n "|${mountpoint}"
96 echo -n "|${format}"
97 echo
98
99 done << EOF
100 $(get_hwinfo partition | grep ${disk})
101 EOF
102 done

Properties

Name Value
svn:executable *