3 # Copyright (C) 2010 Free Software Foundation, Inc.
5 # GRUB is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # GRUB is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with GRUB. If not, see <http://www.gnu.org/licenses/>.
19 grubshell
=@builddir@
/grub-shell
21 create_disk_image
() {
24 qemu-img create
${name} ${size} >/dev
/null
32 if ! grep "($disk)" ${outfile} >/dev
/null
34 echo "($disk): disk/partiton not found"
48 echo ls |
${grubshell} --boot=cd --qemu-opts="-hda ${imgfile}" \
49 --modules=$mod |
tr -d "\n\r" > ${outfile}
54 imgfile
=`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` ||
exit 1
55 outfile
=`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` ||
exit 1
58 # MSDOS partition types
61 echo "Checking MSDOS partition types..."
64 create_disk_image
${imgfile} 64M
65 ${parted} -a none
-s ${imgfile} mklabel msdos
66 list_parts part_msdos
${imgfile} ${outfile}
67 check_output
${outfile} hd0
70 create_disk_image
${imgfile} 64M
71 ${parted} -a none
-s ${imgfile} mklabel msdos mkpart primary
0 10M
72 list_parts part_msdos
${imgfile} ${outfile}
73 check_output
${outfile} hd0 hd0
,msdos1
76 create_disk_image
${imgfile} 128M
77 ${parted} -a none
-s ${imgfile} mklabel msdos mkpart primary
0 10M mkpart primary
10M
20M
78 list_parts part_msdos
${imgfile} ${outfile}
79 check_output
${outfile} hd0 hd0
,msdos1 hd0
,msdos2
82 create_disk_image
${imgfile} 128M
83 ${parted} -a none
-s ${imgfile} mklabel msdos mkpart primary
0 10M mkpart primary
10M
20M mkpart primary
20M
30M
84 list_parts part_msdos
${imgfile} ${outfile}
85 check_output
${outfile} hd0 hd0
,msdos1 hd0
,msdos2 hd0
,msdos3
88 create_disk_image
${imgfile} 128M
89 ${parted} -a none
-s ${imgfile} mklabel msdos mkpart primary
0 10M mkpart primary
10M
20M mkpart primary
20M
30M mkpart primary
30M
40M
90 list_parts part_msdos
${imgfile} ${outfile}
91 check_output
${outfile} hd0 hd0
,msdos1 hd0
,msdos2 hd0
,msdos3 hd0
,msdos4
93 # 1 primary, 1 extended
94 create_disk_image
${imgfile} 128M
95 ${parted} -a none
-s ${imgfile} mklabel msdos mkpart primary
0 10M mkpart primary
10M
20M mkpart extended
20M
100%
96 list_parts part_msdos
${imgfile} ${outfile}
97 check_output
${outfile} hd0 hd0
,msdos1
99 # 1 primary, 1 extended, 1 logical
100 create_disk_image
${imgfile} 128M
101 ${parted} -a none
-s ${imgfile} mklabel msdos mkpart primary
0 10M mkpart primary
10M
20M mkpart extended
20M
100% mkpart logical
20M
30M
102 list_parts part_msdos
${imgfile} ${outfile}
103 check_output
${outfile} hd0 hd0
,msdos1 hd0
,msdos5
105 # 1 primary, 1 extended, 2 logical
106 create_disk_image
${imgfile} 128M
107 ${parted} -a none
-s ${imgfile} mklabel msdos mkpart primary
0 10M mkpart primary
10M
20M mkpart extended
20M
100% mkpart logical
20M
30M mkpart logical
30M
40M
108 list_parts part_msdos
${imgfile} ${outfile}
109 check_output
${outfile} hd0 hd0
,msdos1 hd0
,msdos5 hd0
,msdos6
111 # 1 primary, 1 extended, 3 logical
112 create_disk_image
${imgfile} 128M
113 ${parted} -a none
-s ${imgfile} mklabel msdos mkpart primary
0 10M mkpart primary
10M
20M mkpart extended
20M
100% mkpart logical
20M
30M mkpart logical
30M
40M mkpart logical
40M
50M
114 list_parts part_msdos
${imgfile} ${outfile}
115 check_output
${outfile} hd0 hd0
,msdos1 hd0
,msdos5 hd0
,msdos6 hd0
,msdos7
117 # 1 primary, 1 extended, 4 logical
118 create_disk_image
${imgfile} 128M
119 ${parted} -a none
-s ${imgfile} mklabel msdos mkpart primary
0 10M mkpart primary
10M
20M mkpart extended
20M
100% mkpart logical
20M
30M mkpart logical
30M
40M mkpart logical
40M
50M mkpart logical
50M
60M
120 list_parts part_msdos
${imgfile} ${outfile}
121 check_output
${outfile} hd0 hd0
,msdos1 hd0
,msdos5 hd0
,msdos6 hd0
,msdos7 hd0
,msdos8
125 # GPT partition types
128 echo "Checking GPT partition types..."
131 create_disk_image
${imgfile} 64M
132 ${parted} -a none
-s ${imgfile} mklabel gpt
133 list_parts part_gpt
${imgfile} ${outfile}
134 check_output
${outfile} hd0
137 create_disk_image
${imgfile} 64M
138 ${parted} -a none
-s ${imgfile} mklabel gpt mkpart
1 0 10M
139 list_parts part_gpt
${imgfile} ${outfile}
140 check_output
${outfile} hd0 hd0
,gpt1
143 create_disk_image
${imgfile} 128M
144 ${parted} -a none
-s ${imgfile} mklabel gpt mkpart
1 0 10M mkpart
2 10M
20M
145 list_parts part_gpt
${imgfile} ${outfile}
146 check_output
${outfile} hd0 hd0
,gpt1 hd0
,gpt2
149 create_disk_image
${imgfile} 128M
150 ${parted} -a none
-s ${imgfile} mklabel gpt mkpart
1 0 10M mkpart
2 10M
20M mkpart
3 20M
30M
151 list_parts part_gpt
${imgfile} ${outfile}
152 check_output
${outfile} hd0 hd0
,gpt1 hd0
,gpt2 hd0
,gpt3
155 create_disk_image
${imgfile} 128M
156 ${parted} -a none
-s ${imgfile} mklabel gpt mkpart
1 0 10M mkpart
2 10M
20M mkpart
4 20M
30M mkpart
5 30M
40M
157 list_parts part_gpt
${imgfile} ${outfile}
158 check_output
${outfile} hd0 hd0
,gpt1 hd0
,gpt2 hd0
,gpt3 hd0
,gpt4
161 create_disk_image
${imgfile} 128M
162 ${parted} -a none
-s ${imgfile} mklabel gpt mkpart
1 0 10M mkpart
2 10M
20M mkpart
3 20M
30M mkpart
4 30M
40M mkpart
5 40M
50M
163 list_parts part_gpt
${imgfile} ${outfile}
164 check_output
${outfile} hd0 hd0
,gpt1 hd0
,gpt2 hd0
,gpt3 hd0
,gpt4 hd0
,gpt5
167 create_disk_image
${imgfile} 128M
168 ${parted} -a none
-s ${imgfile} mklabel gpt mkpart
1 0 10M mkpart
2 10M
20M mkpart
3 20M
30M mkpart
4 30M
40M mkpart
5 40M
50M mkpart
6 50M
60M
169 list_parts part_gpt
${imgfile} ${outfile}
170 check_output
${outfile} hd0 hd0
,gpt1 hd0
,gpt2 hd0
,gpt3 hd0
,gpt4 hd0
,gpt5 hd0
,gpt6
174 # SUN partition types
176 # It seems partition #3 is reserved for whole disk by parted.
179 echo "Checking SUN partition types..."
182 create_disk_image
${imgfile} 64M
183 ${parted} -a none
-s ${imgfile} mklabel sun
184 list_parts part_sun
${imgfile} ${outfile}
185 check_output
${outfile} hd0
188 create_disk_image
${imgfile} 64M
189 ${parted} -a none
-s ${imgfile} mklabel sun mkpart
0 10M
190 list_parts part_sun
${imgfile} ${outfile}
191 check_output
${outfile} hd0 hd0
,sun1
194 create_disk_image
${imgfile} 128M
195 ${parted} -a none
-s ${imgfile} mklabel sun mkpart
0 10M mkpart
10M
20M
196 list_parts part_sun
${imgfile} ${outfile}
197 check_output
${outfile} hd0 hd0
,sun1 hd0
,sun2
200 create_disk_image
${imgfile} 128M
201 ${parted} -a none
-s ${imgfile} mklabel sun mkpart
0 10M mkpart
10M
20M mkpart
20M
30M
202 list_parts part_sun
${imgfile} ${outfile}
203 check_output
${outfile} hd0 hd0
,sun1 hd0
,sun2 hd0
,sun4
206 create_disk_image
${imgfile} 128M
207 ${parted} -a none
-s ${imgfile} mklabel sun mkpart
0 10M mkpart
10M
20M mkpart
20M
30M mkpart
30M
40M
208 list_parts part_sun
${imgfile} ${outfile}
209 check_output
${outfile} hd0 hd0
,sun1 hd0
,sun2 hd0
,sun4 hd0
,sun5
212 create_disk_image
${imgfile} 128M
213 ${parted} -a none
-s ${imgfile} mklabel sun mkpart
0 10M mkpart
10M
20M mkpart
20M
30M mkpart
30M
40M mkpart
40M
50M
214 list_parts part_sun
${imgfile} ${outfile}
215 check_output
${outfile} hd0 hd0
,sun1 hd0
,sun2 hd0
,sun4 hd0
,sun5 hd0
,sun6
218 create_disk_image
${imgfile} 128M
219 ${parted} -a none
-s ${imgfile} mklabel sun mkpart
0 10M mkpart
10M
20M mkpart
20M
30M mkpart
30M
40M mkpart
40M
50M mkpart
50M
60M
220 list_parts part_sun
${imgfile} ${outfile}
221 check_output
${outfile} hd0 hd0
,sun1 hd0
,sun2 hd0
,sun4 hd0
,sun5 hd0
,sun6 hd0
,sun7
225 # Apple partition types
227 # Partition table itself is part of some partition, so there is always
228 # a partition by default. But I don't understand why GRUB displays
229 # two partitions by default :-(
232 echo "Checking APPLE partition types..."
235 create_disk_image
${imgfile} 64M
236 ${parted} -a none
-s ${imgfile} mklabel mac
237 list_parts part_apple
${imgfile} ${outfile}
238 check_output
${outfile} hd0 hd0
,apple1 hd0
,apple2
241 create_disk_image
${imgfile} 64M
242 ${parted} -a none
-s ${imgfile} mklabel mac mkpart a
1M
10M
243 list_parts part_apple
${imgfile} ${outfile}
244 check_output
${outfile} hd0 hd0
,apple1 hd0
,apple2 hd0
,apple3
247 create_disk_image
${imgfile} 128M
248 ${parted} -a none
-s ${imgfile} mklabel mac mkpart a
1M
10M mkpart b
10M
20M
249 list_parts part_apple
${imgfile} ${outfile}
250 check_output
${outfile} hd0 hd0
,apple1 hd0
,apple2 hd0
,apple3 hd0
,apple4
253 create_disk_image
${imgfile} 128M
254 ${parted} -a none
-s ${imgfile} mklabel mac mkpart a
1M
10M mkpart b
10M
20M mkpart c
20M
30M
255 list_parts part_apple
${imgfile} ${outfile}
256 check_output
${outfile} hd0 hd0
,apple1 hd0
,apple2 hd0
,apple4 hd0
,apple5
259 create_disk_image
${imgfile} 128M
260 ${parted} -a none
-s ${imgfile} mklabel mac mkpart a
1M
10M mkpart b
10M
20M mkpart c
20M
30M mkpart d
30M
40M
261 list_parts part_apple
${imgfile} ${outfile}
262 check_output
${outfile} hd0 hd0
,apple1 hd0
,apple2 hd0
,apple4 hd0
,apple5 hd0
,apple6
265 create_disk_image
${imgfile} 128M
266 ${parted} -a none
-s ${imgfile} mklabel mac mkpart a
1M
10M mkpart b
10M
20M mkpart c
20M
30M mkpart d
30M
40M mkpart e
40M
50M
267 list_parts part_apple
${imgfile} ${outfile}
268 check_output
${outfile} hd0 hd0
,apple1 hd0
,apple2 hd0
,apple4 hd0
,apple5 hd0
,apple6 hd0
,apple7
271 create_disk_image
${imgfile} 128M
272 ${parted} -a none
-s ${imgfile} mklabel mac mkpart a
1M
10M mkpart b
10M
20M mkpart c
20M
30M mkpart d
30M
40M mkpart e
40M
50M mkpart f
50M
60M
273 list_parts part_apple
${imgfile} ${outfile}
274 check_output
${outfile} hd0 hd0
,apple1 hd0
,apple2 hd0
,apple4 hd0
,apple5 hd0
,apple6 hd0
,apple7 hd0
,apple8