]>
Commit | Line | Data |
---|---|---|
56672f4a | 1 | #! /bin/sh -e |
2 | ||
3 | parted=/sbin/parted | |
4 | grubshell=@builddir@/grub-shell | |
5 | ||
6 | create_disk_image () { | |
7 | name=$1 | |
8 | size=$2 | |
9 | qemu-img create ${name} ${size} >/dev/null | |
10 | } | |
11 | ||
12 | check_output () { | |
13 | outfile=$1 | |
14 | shift | |
15 | ||
16 | for disk in $@; do | |
17 | if ! grep "($disk)" ${outfile} >/dev/null | |
18 | then | |
19 | echo "($disk): disk/partiton not found" | |
20 | exit 1 | |
21 | fi | |
22 | done | |
23 | } | |
24 | ||
25 | list_parts () { | |
26 | mod=$1; | |
27 | shift; | |
28 | imgfile=$1 | |
29 | shift | |
30 | outfile=$1 | |
31 | shift | |
32 | ||
33 | echo ls | ${grubshell} --boot=cd --qemu-opts="-hda ${imgfile}" \ | |
34 | --modules=$mod | tr -d "\n\r" > ${outfile} | |
35 | cat ${outfile} | |
36 | echo | |
37 | } | |
38 | ||
39 | imgfile=`mktemp` | |
40 | outfile=`mktemp` | |
41 | ||
42 | # | |
43 | # MSDOS partition types | |
44 | # | |
45 | ||
46 | echo "Checking MSDOS partition types..." | |
47 | ||
48 | # 0 primary | |
49 | create_disk_image ${imgfile} 64M | |
50 | ${parted} -a none -s ${imgfile} mklabel msdos | |
51 | list_parts part_msdos ${imgfile} ${outfile} | |
52 | check_output ${outfile} hd0 | |
53 | ||
54 | # 1 primary | |
55 | create_disk_image ${imgfile} 64M | |
56 | ${parted} -a none -s ${imgfile} mklabel msdos mkpart primary 0 10M | |
57 | list_parts part_msdos ${imgfile} ${outfile} | |
58 | check_output ${outfile} hd0 hd0,msdos1 | |
59 | ||
60 | # 2 primary | |
61 | create_disk_image ${imgfile} 128M | |
62 | ${parted} -a none -s ${imgfile} mklabel msdos mkpart primary 0 10M mkpart primary 10M 20M | |
63 | list_parts part_msdos ${imgfile} ${outfile} | |
64 | check_output ${outfile} hd0 hd0,msdos1 hd0,msdos2 | |
65 | ||
66 | # 3 primary | |
67 | create_disk_image ${imgfile} 128M | |
68 | ${parted} -a none -s ${imgfile} mklabel msdos mkpart primary 0 10M mkpart primary 10M 20M mkpart primary 20M 30M | |
69 | list_parts part_msdos ${imgfile} ${outfile} | |
70 | check_output ${outfile} hd0 hd0,msdos1 hd0,msdos2 hd0,msdos3 | |
71 | ||
72 | # 4 primary | |
73 | create_disk_image ${imgfile} 128M | |
74 | ${parted} -a none -s ${imgfile} mklabel msdos mkpart primary 0 10M mkpart primary 10M 20M mkpart primary 20M 30M mkpart primary 30M 40M | |
75 | list_parts part_msdos ${imgfile} ${outfile} | |
76 | check_output ${outfile} hd0 hd0,msdos1 hd0,msdos2 hd0,msdos3 hd0,msdos4 | |
77 | ||
78 | # 1 primary, 1 extended | |
79 | create_disk_image ${imgfile} 128M | |
80 | ${parted} -a none -s ${imgfile} mklabel msdos mkpart primary 0 10M mkpart primary 10M 20M mkpart extended 20M 100% | |
81 | list_parts part_msdos ${imgfile} ${outfile} | |
82 | check_output ${outfile} hd0 hd0,msdos1 | |
83 | ||
84 | # 1 primary, 1 extended, 1 logical | |
85 | create_disk_image ${imgfile} 128M | |
86 | ${parted} -a none -s ${imgfile} mklabel msdos mkpart primary 0 10M mkpart primary 10M 20M mkpart extended 20M 100% mkpart logical 20M 30M | |
87 | list_parts part_msdos ${imgfile} ${outfile} | |
88 | check_output ${outfile} hd0 hd0,msdos1 hd0,msdos5 | |
89 | ||
90 | # 1 primary, 1 extended, 2 logical | |
91 | create_disk_image ${imgfile} 128M | |
92 | ${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 | |
93 | list_parts part_msdos ${imgfile} ${outfile} | |
94 | check_output ${outfile} hd0 hd0,msdos1 hd0,msdos5 hd0,msdos6 | |
95 | ||
96 | # 1 primary, 1 extended, 3 logical | |
97 | create_disk_image ${imgfile} 128M | |
98 | ${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 | |
99 | list_parts part_msdos ${imgfile} ${outfile} | |
100 | check_output ${outfile} hd0 hd0,msdos1 hd0,msdos5 hd0,msdos6 hd0,msdos7 | |
101 | ||
102 | # 1 primary, 1 extended, 4 logical | |
103 | create_disk_image ${imgfile} 128M | |
104 | ${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 | |
105 | list_parts part_msdos ${imgfile} ${outfile} | |
106 | check_output ${outfile} hd0 hd0,msdos1 hd0,msdos5 hd0,msdos6 hd0,msdos7 hd0,msdos8 | |
107 | ||
108 | ||
109 | # | |
110 | # GPT partition types | |
111 | # | |
112 | ||
113 | echo "Checking GPT partition types..." | |
114 | ||
115 | # 0 parts | |
116 | create_disk_image ${imgfile} 64M | |
117 | ${parted} -a none -s ${imgfile} mklabel gpt | |
118 | list_parts part_gpt ${imgfile} ${outfile} | |
119 | check_output ${outfile} hd0 | |
120 | ||
121 | # 1 parts | |
122 | create_disk_image ${imgfile} 64M | |
123 | ${parted} -a none -s ${imgfile} mklabel gpt mkpart 1 0 10M | |
124 | list_parts part_gpt ${imgfile} ${outfile} | |
125 | check_output ${outfile} hd0 hd0,gpt1 | |
126 | ||
127 | # 2 parts | |
128 | create_disk_image ${imgfile} 128M | |
129 | ${parted} -a none -s ${imgfile} mklabel gpt mkpart 1 0 10M mkpart 2 10M 20M | |
130 | list_parts part_gpt ${imgfile} ${outfile} | |
131 | check_output ${outfile} hd0 hd0,gpt1 hd0,gpt2 | |
132 | ||
133 | # 3 parts | |
134 | create_disk_image ${imgfile} 128M | |
135 | ${parted} -a none -s ${imgfile} mklabel gpt mkpart 1 0 10M mkpart 2 10M 20M mkpart 3 20M 30M | |
136 | list_parts part_gpt ${imgfile} ${outfile} | |
137 | check_output ${outfile} hd0 hd0,gpt1 hd0,gpt2 hd0,gpt3 | |
138 | ||
139 | # 4 parts | |
140 | create_disk_image ${imgfile} 128M | |
141 | ${parted} -a none -s ${imgfile} mklabel gpt mkpart 1 0 10M mkpart 2 10M 20M mkpart 4 20M 30M mkpart 5 30M 40M | |
142 | list_parts part_gpt ${imgfile} ${outfile} | |
143 | check_output ${outfile} hd0 hd0,gpt1 hd0,gpt2 hd0,gpt3 hd0,gpt4 | |
144 | ||
145 | # 5 parts | |
146 | create_disk_image ${imgfile} 128M | |
147 | ${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 | |
148 | list_parts part_gpt ${imgfile} ${outfile} | |
149 | check_output ${outfile} hd0 hd0,gpt1 hd0,gpt2 hd0,gpt3 hd0,gpt4 hd0,gpt5 | |
150 | ||
151 | # 6 parts | |
152 | create_disk_image ${imgfile} 128M | |
153 | ${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 | |
154 | list_parts part_gpt ${imgfile} ${outfile} | |
155 | check_output ${outfile} hd0 hd0,gpt1 hd0,gpt2 hd0,gpt3 hd0,gpt4 hd0,gpt5 hd0,gpt6 | |
156 | ||
157 | ||
158 | # | |
159 | # SUN partition types | |
160 | # | |
161 | # It seems partition #3 is reserved for whole disk by parted. | |
162 | # | |
163 | ||
164 | echo "Checking SUN partition types..." | |
165 | ||
166 | # 0 parts | |
167 | create_disk_image ${imgfile} 64M | |
168 | ${parted} -a none -s ${imgfile} mklabel sun | |
169 | list_parts part_sun ${imgfile} ${outfile} | |
170 | check_output ${outfile} hd0 | |
171 | ||
172 | # 1 parts | |
173 | create_disk_image ${imgfile} 64M | |
174 | ${parted} -a none -s ${imgfile} mklabel sun mkpart 0 10M | |
175 | list_parts part_sun ${imgfile} ${outfile} | |
176 | check_output ${outfile} hd0 hd0,sun1 | |
177 | ||
178 | # 2 parts | |
179 | create_disk_image ${imgfile} 128M | |
180 | ${parted} -a none -s ${imgfile} mklabel sun mkpart 0 10M mkpart 10M 20M | |
181 | list_parts part_sun ${imgfile} ${outfile} | |
182 | check_output ${outfile} hd0 hd0,sun1 hd0,sun2 | |
183 | ||
184 | # 3 parts | |
185 | create_disk_image ${imgfile} 128M | |
186 | ${parted} -a none -s ${imgfile} mklabel sun mkpart 0 10M mkpart 10M 20M mkpart 20M 30M | |
187 | list_parts part_sun ${imgfile} ${outfile} | |
188 | check_output ${outfile} hd0 hd0,sun1 hd0,sun2 hd0,sun4 | |
189 | ||
190 | # 4 parts | |
191 | create_disk_image ${imgfile} 128M | |
192 | ${parted} -a none -s ${imgfile} mklabel sun mkpart 0 10M mkpart 10M 20M mkpart 20M 30M mkpart 30M 40M | |
193 | list_parts part_sun ${imgfile} ${outfile} | |
194 | check_output ${outfile} hd0 hd0,sun1 hd0,sun2 hd0,sun4 hd0,sun5 | |
195 | ||
196 | # 5 parts | |
197 | create_disk_image ${imgfile} 128M | |
198 | ${parted} -a none -s ${imgfile} mklabel sun mkpart 0 10M mkpart 10M 20M mkpart 20M 30M mkpart 30M 40M mkpart 40M 50M | |
199 | list_parts part_sun ${imgfile} ${outfile} | |
200 | check_output ${outfile} hd0 hd0,sun1 hd0,sun2 hd0,sun4 hd0,sun5 hd0,sun6 | |
201 | ||
202 | # 6 parts | |
203 | create_disk_image ${imgfile} 128M | |
204 | ${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 | |
205 | list_parts part_sun ${imgfile} ${outfile} | |
206 | check_output ${outfile} hd0 hd0,sun1 hd0,sun2 hd0,sun4 hd0,sun5 hd0,sun6 hd0,sun7 | |
207 | ||
208 | ||
209 | # | |
210 | # Apple partition types | |
211 | # | |
212 | # Partition table itself is part of some partition, so there is always | |
213 | # a partition by default. But I don't understand why GRUB displays | |
214 | # two partitions by default :-( | |
215 | # | |
216 | ||
217 | echo "Checking APPLE partition types..." | |
218 | ||
219 | # 0 parts | |
220 | create_disk_image ${imgfile} 64M | |
221 | ${parted} -a none -s ${imgfile} mklabel mac | |
222 | list_parts part_apple ${imgfile} ${outfile} | |
223 | check_output ${outfile} hd0 hd0,apple1 hd0,apple2 | |
224 | ||
225 | # 1 parts | |
226 | create_disk_image ${imgfile} 64M | |
227 | ${parted} -a none -s ${imgfile} mklabel mac mkpart a 1M 10M | |
228 | list_parts part_apple ${imgfile} ${outfile} | |
229 | check_output ${outfile} hd0 hd0,apple1 hd0,apple2 hd0,apple3 | |
230 | ||
231 | # 2 parts | |
232 | create_disk_image ${imgfile} 128M | |
233 | ${parted} -a none -s ${imgfile} mklabel mac mkpart a 1M 10M mkpart b 10M 20M | |
234 | list_parts part_apple ${imgfile} ${outfile} | |
235 | check_output ${outfile} hd0 hd0,apple1 hd0,apple2 hd0,apple3 hd0,apple4 | |
236 | ||
237 | # 3 parts | |
238 | create_disk_image ${imgfile} 128M | |
239 | ${parted} -a none -s ${imgfile} mklabel mac mkpart a 1M 10M mkpart b 10M 20M mkpart c 20M 30M | |
240 | list_parts part_apple ${imgfile} ${outfile} | |
241 | check_output ${outfile} hd0 hd0,apple1 hd0,apple2 hd0,apple4 hd0,apple5 | |
242 | ||
243 | # 4 parts | |
244 | create_disk_image ${imgfile} 128M | |
245 | ${parted} -a none -s ${imgfile} mklabel mac mkpart a 1M 10M mkpart b 10M 20M mkpart c 20M 30M mkpart d 30M 40M | |
246 | list_parts part_apple ${imgfile} ${outfile} | |
247 | check_output ${outfile} hd0 hd0,apple1 hd0,apple2 hd0,apple4 hd0,apple5 hd0,apple6 | |
248 | ||
249 | # 5 parts | |
250 | create_disk_image ${imgfile} 128M | |
251 | ${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 | |
252 | list_parts part_apple ${imgfile} ${outfile} | |
253 | check_output ${outfile} hd0 hd0,apple1 hd0,apple2 hd0,apple4 hd0,apple5 hd0,apple6 hd0,apple7 | |
254 | ||
255 | # 6 parts | |
256 | create_disk_image ${imgfile} 128M | |
257 | ${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 | |
258 | list_parts part_apple ${imgfile} ${outfile} | |
259 | check_output ${outfile} hd0 hd0,apple1 hd0,apple2 hd0,apple4 hd0,apple5 hd0,apple6 hd0,apple7 hd0,apple8 |