Merge lp:~dpigott/lava-master-image-scripts/move-partitioning-to-first-boot into lp:lava-master-image-scripts
- move-partitioning-to-first-boot
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Dave Pigott |
Approved revision: | 61 |
Merged at revision: | 59 |
Proposed branch: | lp:~dpigott/lava-master-image-scripts/move-partitioning-to-first-boot |
Merge into: | lp:lava-master-image-scripts |
Diff against target: |
469 lines (+211/-145) 8 files modified
NEWS (+2/-1) README (+5/-22) contrib/lava-partition-disk (+0/-118) contrib/preEnv.txt (+0/-1) lava-create-master (+12/-2) master-rootfs-extras/bin/lava-partition-disk (+184/-0) master-rootfs-extras/lib/lava/common (+1/-0) master-rootfs-extras/lib/lava/lava-master-init (+7/-1) |
To merge this branch: | bzr merge lp:~dpigott/lava-master-image-scripts/move-partitioning-to-first-boot |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Michael Hudson-Doyle (community) | Approve | ||
Review via email:
|
Commit message
Description of the change
Get rid of the contrib, second stage code, and make it all happen on first boot. Re-write and tidy the partitioning code. Add a new option to lava-create-
Also put the image size back to 1GB. The 3GB was unnecessary, since we deploy onto testrootfs, which is usually 4G and in the LAVA farm is always 8GB.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Zygmunt Krynicki (zyga) wrote : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Michael Hudson-Doyle (mwhudson) wrote : | # |
I tested this branch and it seems to work. Nice :)
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Dave Pigott (dpigott) wrote : | # |
> 450 -LAVA_PKGS="wget dosfstools u-boot-tools bzip2 python ntpdate"
> 451 +LAVA_PKGS="wget dosfstools u-boot-tools bzip2 python ntpdate parted"
>
> Do we need parted? We use fdisk, we also need partprobe and mkfs.ext4 (they
> may be already contained in other packages)
>
> Otherwise it looks fine on first read +2
It was purely because of partprobe. Wasn't aware of another package that contains it.
- 61. By Dave Pigott
-
Add a little more commentary
Preview Diff
1 | === modified file 'NEWS' | |||
2 | --- NEWS 2012-05-04 11:46:04 +0000 | |||
3 | +++ NEWS 2012-05-15 08:44:18 +0000 | |||
4 | @@ -1,11 +1,12 @@ | |||
5 | 1 | 2012.05: | 1 | 2012.05: |
6 | 2 | 2 | ||
7 | 3 | * Unreleased | 3 | * Unreleased |
9 | 4 | * Increase the size of the default image to 3G | 4 | * Increase the size of the default image to 3G - now back at 1G |
10 | 5 | * Add support for partitioning SD cards via both native mmc interface and | 5 | * Add support for partitioning SD cards via both native mmc interface and |
11 | 6 | USB adapters | 6 | USB adapters |
12 | 7 | * Rename run-beagle-master-in-qemu.sh to boot-snaphot-in-qemu.sh and allow | 7 | * Rename run-beagle-master-in-qemu.sh to boot-snaphot-in-qemu.sh and allow |
13 | 8 | the user to point it at any image pathname | 8 | the user to point it at any image pathname |
14 | 9 | * Add partitioning on boot up rather than as a seperate phase | ||
15 | 9 | 10 | ||
16 | 10 | 2u12.04: | 11 | 2u12.04: |
17 | 11 | 12 | ||
18 | 12 | 13 | ||
19 | === modified file 'README' | |||
20 | --- README 2012-05-03 09:53:27 +0000 | |||
21 | +++ README 2012-05-15 08:44:18 +0000 | |||
22 | @@ -32,25 +32,8 @@ | |||
23 | 32 | from the Linaro website. Once prepared the caches "vanilla" image can be reused | 32 | from the Linaro website. Once prepared the caches "vanilla" image can be reused |
24 | 33 | over and over. The tool creates a single file <board>-master.img. | 33 | over and over. The tool creates a single file <board>-master.img. |
25 | 34 | 34 | ||
48 | 35 | This image is not complete: it lacks the special partitioning layout required by | 35 | The first boot of a device with this card is special. It will initialize the |
49 | 36 | LAVA dispatcher. To finish the process copy the image to an SD card as instructed | 36 | master image, including partitioning and labeling, and will likely take a few |
50 | 37 | by the tool and run: | 37 | extra minutes to finish. The interactive serial console will be activated after |
51 | 38 | 38 | this process has finished. Once this process is done it is *not recommended* to | |
52 | 39 | $ ./contrib/lava-partition-disk <board type> <device path> <boot mount> | 39 | clone the SD card anymore. |
31 | 40 | |||
32 | 41 | Replace <board type> with one of: beagle, imx53, origen, panda, snowball | ||
33 | 42 | or vexpress. | ||
34 | 43 | |||
35 | 44 | Replace <device path> with the name of the system device that represents your | ||
36 | 45 | SD card, typically this is /dev/sdX or /dev/mmcblkX (with X being a number or | ||
37 | 46 | letter representing subsequent devices in your system). | ||
38 | 47 | |||
39 | 48 | Replace <boot mount> with the mount point for the boot partition, typically on | ||
40 | 49 | Ubuntu this will be /media/boot. | ||
41 | 50 | |||
42 | 51 | This step will be integrated into the tool in the future. At this time the card | ||
43 | 52 | is now ready and can be cloned (like a template). The first boot of a device | ||
44 | 53 | with this card is special. It will initialize the master image and will likely | ||
45 | 54 | take a few extra minutes to finish. The interactive serial console will be | ||
46 | 55 | activated after this process has finished. Once this process is done it is *not | ||
47 | 56 | recommended* to clone the SD card anymore. | ||
53 | 57 | 40 | ||
54 | === removed directory 'contrib' | |||
55 | === removed file 'contrib/lava-partition-disk' | |||
56 | --- contrib/lava-partition-disk 2012-05-14 08:38:47 +0000 | |||
57 | +++ contrib/lava-partition-disk 1970-01-01 00:00:00 +0000 | |||
58 | @@ -1,118 +0,0 @@ | |||
59 | 1 | #!/bin/bash | ||
60 | 2 | |||
61 | 3 | show_usage() { | ||
62 | 4 | echo "Usage: $0 <board type> <device path> <boot mount> {testrootfs partition size}" | ||
63 | 5 | echo "Where <board typei> is one of: beagle, imx53, origen, panda," | ||
64 | 6 | echo " snowball or vexpress" | ||
65 | 7 | echo | ||
66 | 8 | echo "<device path> is the path to your sd card (e.g. /dev/sdb)" | ||
67 | 9 | echo "<boot mount> is where the boot partition of the sd card is (e.g. /media/boot" | ||
68 | 10 | echo | ||
69 | 11 | echo "The testrootfs partition size is optional and defauts to 4G." | ||
70 | 12 | echo "Make sure you specify the \"G\" in uppercase" | ||
71 | 13 | } | ||
72 | 14 | |||
73 | 15 | if [ "$3" = "" ] | ||
74 | 16 | then | ||
75 | 17 | show_usage | ||
76 | 18 | exit 1 | ||
77 | 19 | fi | ||
78 | 20 | |||
79 | 21 | PRE_ENV= | ||
80 | 22 | |||
81 | 23 | case $1 in | ||
82 | 24 | beagle) | ||
83 | 25 | PRE_ENV=Y | ||
84 | 26 | SCHEME=2part;; | ||
85 | 27 | |||
86 | 28 | imx53) | ||
87 | 29 | SCHEME=3part;; | ||
88 | 30 | |||
89 | 31 | origen) | ||
90 | 32 | SCHEME=3part;; | ||
91 | 33 | |||
92 | 34 | panda) | ||
93 | 35 | PRE_ENV=Y | ||
94 | 36 | SCHEME=2part;; | ||
95 | 37 | |||
96 | 38 | snowball) | ||
97 | 39 | SCHEME=2part;; | ||
98 | 40 | |||
99 | 41 | vexpress) | ||
100 | 42 | SCHEME=2part;; | ||
101 | 43 | |||
102 | 44 | *) | ||
103 | 45 | echo "Board type \"$1\" not recognised" | ||
104 | 46 | exit 1;; | ||
105 | 47 | esac | ||
106 | 48 | |||
107 | 49 | DEVICE=$2 | ||
108 | 50 | |||
109 | 51 | BOOT_MOUNT=$3 | ||
110 | 52 | |||
111 | 53 | if [ "$4" = "" ] | ||
112 | 54 | then | ||
113 | 55 | # SIZE is the size of the testrootfs partition. On an 8G sd you can fit | ||
114 | 56 | # 4G - put it up to 8G on a 16GB. The rest is allocated to sdcard for | ||
115 | 57 | # android | ||
116 | 58 | SIZE="4G" | ||
117 | 59 | else | ||
118 | 60 | SIZE=$4 | ||
119 | 61 | fi | ||
120 | 62 | |||
121 | 63 | if [ "$PRE_ENV" = "Y" ] | ||
122 | 64 | then | ||
123 | 65 | cp ./contrib/preEnv.txt $BOOT_MOUNT | ||
124 | 66 | if [ "$?" != "0" ] | ||
125 | 67 | then | ||
126 | 68 | echo "Failed to copy preEnv.txt. Is the disk read only?" | ||
127 | 69 | exit 1 | ||
128 | 70 | fi | ||
129 | 71 | fi | ||
130 | 72 | |||
131 | 73 | # origen and imx53 have a different original layout with 3 partitions | ||
132 | 74 | # all others are the same (so far) | ||
133 | 75 | |||
134 | 76 | if [ $SCHEME = "2part" ] | ||
135 | 77 | then | ||
136 | 78 | TESTBOOT_PART=3 | ||
137 | 79 | TESTROOTFS_PART=5 | ||
138 | 80 | SDCARD_PART=6 | ||
139 | 81 | LAST_BLOCK=2 | ||
140 | 82 | else | ||
141 | 83 | TESTBOOT_PART=5 | ||
142 | 84 | TESTROOTFS_PART=6 | ||
143 | 85 | SDCARD_PART=7 | ||
144 | 86 | LAST_BLOCK=3 | ||
145 | 87 | fi | ||
146 | 88 | |||
147 | 89 | if [[ $DEVICE =~ 'mmc' ]]; | ||
148 | 90 | then | ||
149 | 91 | PARTITION_PREFIX="p" | ||
150 | 92 | else | ||
151 | 93 | PARTITION_PREFIX="" | ||
152 | 94 | fi | ||
153 | 95 | |||
154 | 96 | FIRST_BLOCK_START=`sudo fdisk -S 63 -H 255 -lc $DEVICE | grep "${DEVICE}${PARTITION_PREFIX}${LAST_BLOCK}" | awk '{print $3 + 1}'` | ||
155 | 97 | |||
156 | 98 | if [ "$FIRST_BLOCK_START" = "" ] | ||
157 | 99 | then | ||
158 | 100 | echo "Device specification error: $DEVICE" | ||
159 | 101 | exit 1 | ||
160 | 102 | fi | ||
161 | 103 | |||
162 | 104 | if [ $SCHEME = "2part" ] | ||
163 | 105 | then | ||
164 | 106 | EXTENDED_BLOCK_START=`echo $FIRST_BLOCK_START | awk '{print $1 + 131072}'` | ||
165 | 107 | FDISK_SCRIPT="n\np\n3\n$FIRST_BLOCK_START\n+64M\nt\n3\nc\nn\ne\n$EXTENDED_BLOCK_START\n\nn\n\n+$SIZE\nn\n\n\nt\n6\nc\np\nw\n" | ||
166 | 108 | else | ||
167 | 109 | FDISK_SCRIPT="n\ne\n$FIRST_BLOCK_START\n\nn\n\n+64M\nt\n5\nc\nn\n\n+$SIZE\nn\n\n\nt\n7\nc\np\nw\n" | ||
168 | 110 | fi | ||
169 | 111 | |||
170 | 112 | echo -e $FDISK_SCRIPT | sudo fdisk -S 63 -H 255 -c $DEVICE | ||
171 | 113 | |||
172 | 114 | sudo partprobe $DEVICE | ||
173 | 115 | sudo mkfs.vfat -n testboot "${DEVICE}${PARTITION_PREFIX}${TESTBOOT_PART}" | ||
174 | 116 | sudo mkfs.vfat -n sdcard "${DEVICE}${PARTITION_PREFIX}${SDCARD_PART}" | ||
175 | 117 | sudo mkfs.ext3 -L testrootfs "${DEVICE}${PARTITION_PREFIX}${TESTROOTFS_PART}" | ||
176 | 118 | sync | ||
177 | 119 | 0 | ||
178 | === removed file 'contrib/preEnv.txt' | |||
179 | --- contrib/preEnv.txt 2012-05-03 09:52:40 +0000 | |||
180 | +++ contrib/preEnv.txt 1970-01-01 00:00:00 +0000 | |||
181 | @@ -1,1 +0,0 @@ | |||
182 | 1 | bootdelay=10 | ||
183 | 2 | 0 | ||
184 | === modified file 'lava-create-master' | |||
185 | --- lava-create-master 2012-05-14 08:38:47 +0000 | |||
186 | +++ lava-create-master 2012-05-15 08:44:18 +0000 | |||
187 | @@ -16,6 +16,10 @@ | |||
188 | 16 | # When non-empty the tool will stop just before jumping into the rootfs | 16 | # When non-empty the tool will stop just before jumping into the rootfs |
189 | 17 | export DEBUG= | 17 | export DEBUG= |
190 | 18 | 18 | ||
191 | 19 | # Used during partitioning on first boot - size of the testrootsfs partition | ||
192 | 20 | # defaults to 4G (4 GigaBytes) | ||
193 | 21 | export ROOTFS_SIZE="4G" | ||
194 | 22 | |||
195 | 19 | # TODO: change to BOARD | 23 | # TODO: change to BOARD |
196 | 20 | dev= | 24 | dev= |
197 | 21 | 25 | ||
198 | @@ -58,7 +62,7 @@ | |||
199 | 58 | 62 | ||
200 | 59 | show_usage() { | 63 | show_usage() { |
201 | 60 | # Display the usage line | 64 | # Display the usage line |
203 | 61 | echo "Usage: lava-create-master [--rebuild-vanilla] [--verbose] (--help | --version | DEVICE) [ --output|-o IMAGE]" | 65 | echo "Usage: lava-create-master [--rebuild-vanilla] [--verbose] (--help | --version | DEVICE) [ --output|-o IMAGE] [--rootfs-size|-r SIZE]" |
204 | 62 | } | 66 | } |
205 | 63 | 67 | ||
206 | 64 | 68 | ||
207 | @@ -73,6 +77,7 @@ | |||
208 | 73 | printf -- " %-9s - %s\n" "--verbose" "Display additional messages" | 77 | printf -- " %-9s - %s\n" "--verbose" "Display additional messages" |
209 | 74 | printf -- " %-9s - %s\n" "--output" "Save the output as IMAGE" | 78 | printf -- " %-9s - %s\n" "--output" "Save the output as IMAGE" |
210 | 75 | printf -- " %-9s - %s\n" "--rebuild-vanilla" "Always rebuild vanilla image" | 79 | printf -- " %-9s - %s\n" "--rebuild-vanilla" "Always rebuild vanilla image" |
211 | 80 | printf -- " %-9s - %s\n" "--rootfs-size" "Size of the testrootfs partition (default 4G)" | ||
212 | 76 | echo | 81 | echo |
213 | 77 | echo "supported devices:" | 82 | echo "supported devices:" |
214 | 78 | echo | 83 | echo |
215 | @@ -119,6 +124,10 @@ | |||
216 | 119 | OUTPUT_IMAGE="$2" | 124 | OUTPUT_IMAGE="$2" |
217 | 120 | shift 2 | 125 | shift 2 |
218 | 121 | ;; | 126 | ;; |
219 | 127 | --rootfs-size|-r) | ||
220 | 128 | ROOTFS_SIZE="$2" | ||
221 | 129 | shift 2 | ||
222 | 130 | ;; | ||
223 | 122 | *) | 131 | *) |
224 | 123 | if [ -n "$dev" ]; then | 132 | if [ -n "$dev" ]; then |
225 | 124 | show_usage | 133 | show_usage |
226 | @@ -335,7 +344,7 @@ | |||
227 | 335 | --dev $LMC_DEV \ | 344 | --dev $LMC_DEV \ |
228 | 336 | --rootfs ext4 \ | 345 | --rootfs ext4 \ |
229 | 337 | --image-file $CACHE_DIR/pristine-images/$dev-vanilla.img \ | 346 | --image-file $CACHE_DIR/pristine-images/$dev-vanilla.img \ |
231 | 338 | --image-size 3G \ | 347 | --image-size 1G \ |
232 | 339 | --align-boot-part \ | 348 | --align-boot-part \ |
233 | 340 | --binary $CACHE_DIR/image-pieces/$ROOTFS \ | 349 | --binary $CACHE_DIR/image-pieces/$ROOTFS \ |
234 | 341 | --hwpack $CACHE_DIR/image-pieces/$HWPACK \ | 350 | --hwpack $CACHE_DIR/image-pieces/$HWPACK \ |
235 | @@ -408,6 +417,7 @@ | |||
236 | 408 | sed \ | 417 | sed \ |
237 | 409 | -e "s!@LAVA_VERSION@!$LAVA_VERSION!" \ | 418 | -e "s!@LAVA_VERSION@!$LAVA_VERSION!" \ |
238 | 410 | -e "s!@LAVA_URL@!$LAVA_URL!" \ | 419 | -e "s!@LAVA_URL@!$LAVA_URL!" \ |
239 | 420 | -e "s!@LAVA_ROOTFS_SIZE@!$ROOTFS_SIZE!" \ | ||
240 | 411 | -i \ | 421 | -i \ |
241 | 412 | $MASTER_MNT/lib/lava/common | 422 | $MASTER_MNT/lib/lava/common |
242 | 413 | 423 | ||
243 | 414 | 424 | ||
244 | === added file 'master-rootfs-extras/bin/lava-partition-disk' | |||
245 | --- master-rootfs-extras/bin/lava-partition-disk 1970-01-01 00:00:00 +0000 | |||
246 | +++ master-rootfs-extras/bin/lava-partition-disk 2012-05-15 08:44:18 +0000 | |||
247 | @@ -0,0 +1,184 @@ | |||
248 | 1 | #!/bin/bash | ||
249 | 2 | |||
250 | 3 | # By default we build a 4GByte partition. Specifiy on the command line for | ||
251 | 4 | # anything different | ||
252 | 5 | ROOTFS_SIZE="4G" | ||
253 | 6 | |||
254 | 7 | show_usage() { | ||
255 | 8 | echo "Usage: $0 [--rootfs-size|-r SIZE]" | ||
256 | 9 | } | ||
257 | 10 | |||
258 | 11 | show_help() { | ||
259 | 12 | show_usage | ||
260 | 13 | echo | ||
261 | 14 | echo "available options:" | ||
262 | 15 | echo | ||
263 | 16 | printf -- " %-9s - %s\n" "--help" "Show this message" | ||
264 | 17 | printf -- " %-9s - %s\n" "--rootfs-size" "Size of the testrootfs partition (default 4G)" | ||
265 | 18 | echo | ||
266 | 19 | echo "See: $LAVA_URL for more information" | ||
267 | 20 | } | ||
268 | 21 | |||
269 | 22 | parse_argv() { | ||
270 | 23 | while test -n "$1"; do | ||
271 | 24 | case "$1" in | ||
272 | 25 | --help) | ||
273 | 26 | show_help | ||
274 | 27 | exit 0 | ||
275 | 28 | ;; | ||
276 | 29 | --rootfs-size|-r) | ||
277 | 30 | ROOTFS_SIZE=$2; | ||
278 | 31 | shift 2 | ||
279 | 32 | ;; | ||
280 | 33 | *) | ||
281 | 34 | show_usage | ||
282 | 35 | echo "Too many arguments, see --help for details" | ||
283 | 36 | exit 1 | ||
284 | 37 | ;; | ||
285 | 38 | esac | ||
286 | 39 | done | ||
287 | 40 | } | ||
288 | 41 | |||
289 | 42 | # Basically, there are just enough differences between boards that you need | ||
290 | 43 | # to specify which schemes and actions need to take place. | ||
291 | 44 | # | ||
292 | 45 | # PRE_ENV: means that we can put a preEnv.txt in the boot partition and it | ||
293 | 46 | # will be read on boot and used, so we get a default bootdelay of 10s | ||
294 | 47 | # | ||
295 | 48 | # SCHEME: Basically describes the topology of the disk at the start. Some | ||
296 | 49 | # boards have 2 partitions, others 3: TODO Make it sense which one, and even | ||
297 | 50 | # detect that the card doesn't conform (e.g. already partitioned) | ||
298 | 51 | # | ||
299 | 52 | # DEVICE: Fairly self explanatory - the device that will be partitioned | ||
300 | 53 | set_device() { | ||
301 | 54 | DEVICE_TYPE=`lava-device-info --device-type` | ||
302 | 55 | |||
303 | 56 | case $DEVICE_TYPE in | ||
304 | 57 | lava:beagle) | ||
305 | 58 | PRE_ENV=Y | ||
306 | 59 | SCHEME=2part | ||
307 | 60 | DEVICE="/dev/mmcblk0" | ||
308 | 61 | ;; | ||
309 | 62 | lava:imx53) | ||
310 | 63 | PRE_ENV=N | ||
311 | 64 | SCHEME=3part | ||
312 | 65 | DEVICE="/dev/mmcblk0" | ||
313 | 66 | ;; | ||
314 | 67 | lava:origen) | ||
315 | 68 | PRE_ENV=N | ||
316 | 69 | SCHEME=3part | ||
317 | 70 | DEVICE="/dev/mmcblk0" | ||
318 | 71 | ;; | ||
319 | 72 | lava:panda) | ||
320 | 73 | PRE_ENV=Y | ||
321 | 74 | SCHEME=2part | ||
322 | 75 | DEVICE="/dev/mmcblk0" | ||
323 | 76 | ;; | ||
324 | 77 | lava:snowball) | ||
325 | 78 | PRE_ENV=N | ||
326 | 79 | SCHEME=2part | ||
327 | 80 | DEVICE="/dev/mmcblk1" | ||
328 | 81 | ;; | ||
329 | 82 | lava:vexpress) | ||
330 | 83 | PRE_ENV=N | ||
331 | 84 | SCHEME=2part | ||
332 | 85 | DEVICE="/dev/mmcblk0" | ||
333 | 86 | ;; | ||
334 | 87 | *) | ||
335 | 88 | echo "Board type \"$1\" not supported" | ||
336 | 89 | exit 1 | ||
337 | 90 | ;; | ||
338 | 91 | esac | ||
339 | 92 | |||
340 | 93 | # origen and imx53 have a different original layout with 3 partitions | ||
341 | 94 | # all others are the same (so far). All we're doing is defining the | ||
342 | 95 | # partition numbers for the partitions we're going to add | ||
343 | 96 | |||
344 | 97 | if [ $SCHEME = "2part" ] | ||
345 | 98 | then | ||
346 | 99 | TESTBOOT_PART=3 | ||
347 | 100 | TESTROOTFS_PART=5 | ||
348 | 101 | SDCARD_PART=6 | ||
349 | 102 | LAST_BLOCK=2 | ||
350 | 103 | else | ||
351 | 104 | TESTBOOT_PART=5 | ||
352 | 105 | TESTROOTFS_PART=6 | ||
353 | 106 | SDCARD_PART=7 | ||
354 | 107 | LAST_BLOCK=3 | ||
355 | 108 | fi | ||
356 | 109 | |||
357 | 110 | if [[ $DEVICE =~ 'mmc' ]]; | ||
358 | 111 | then | ||
359 | 112 | PARTITION_PREFIX="p" | ||
360 | 113 | else | ||
361 | 114 | PARTITION_PREFIX="" | ||
362 | 115 | fi | ||
363 | 116 | |||
364 | 117 | } | ||
365 | 118 | |||
366 | 119 | |||
367 | 120 | write_preenv() { | ||
368 | 121 | mkdir -p /mnt/boot | ||
369 | 122 | mount /dev/disk/by-label/boot /mnt/boot | ||
370 | 123 | echo "bootdelay=10" >> /mnt/boot/preEnv.txt | ||
371 | 124 | if [ "$?" != "0" ]; then | ||
372 | 125 | echo "Failed to copy preEnv.txt. Is the disk read only?" | ||
373 | 126 | exit 1 | ||
374 | 127 | fi | ||
375 | 128 | umount /mnt/boot | ||
376 | 129 | } | ||
377 | 130 | |||
378 | 131 | # Basically, we need the following scheme: | ||
379 | 132 | # /dev/disk/by-label/boot - the master boot image | ||
380 | 133 | # /dev/disk/by-label/rootfs - the master root filing system | ||
381 | 134 | # /dev/disk/by-label/testboot - the deployed test boot image will go here | ||
382 | 135 | # /dev/disk/by-label/testrootfs - the deployed test rootfs will go here | ||
383 | 136 | # /dev/disk/by-label/sdcard - the Android sdcard partition goes here | ||
384 | 137 | # | ||
385 | 138 | # so first we partition the disk, if it's 2part, then 3 will be the testboot | ||
386 | 139 | # and 4 will be an extended partition containing 5 as the testrootfs and 6 | ||
387 | 140 | # as sdcard. | ||
388 | 141 | # For 3part then 4 will be an extended partition containing 5/testboot, | ||
389 | 142 | # 6/testrootfs and 7/sdcard | ||
390 | 143 | partition_disk() { | ||
391 | 144 | FIRST_BLOCK_START=`fdisk -S 63 -H 255 -lc $DEVICE | grep "${DEVICE}${PARTITION_PREFIX}${LAST_BLOCK}" | awk '{print $3 + 1}'` | ||
392 | 145 | |||
393 | 146 | if [ "$FIRST_BLOCK_START" = "" ] | ||
394 | 147 | then | ||
395 | 148 | echo "Device specification error: $DEVICE" | ||
396 | 149 | exit 1 | ||
397 | 150 | fi | ||
398 | 151 | |||
399 | 152 | if [ $SCHEME = "2part" ] | ||
400 | 153 | then | ||
401 | 154 | # 131072 = 65536 * 2 - fdisk works in 512K blocks, and we want a 64M | ||
402 | 155 | # partition for testboot. | ||
403 | 156 | EXTENDED_BLOCK_START=`echo $FIRST_BLOCK_START | awk '{print $1 + 131072}'` | ||
404 | 157 | FDISK_SCRIPT="n\np\n3\n$FIRST_BLOCK_START\n+64M\nt\n3\nc\nn\ne\n$EXTENDED_BLOCK_START\n\nn\n\n+$ROOTFS_SIZE\nn\n\n\nt\n6\nc\np\nw\n" | ||
405 | 158 | else | ||
406 | 159 | FDISK_SCRIPT="n\ne\n$FIRST_BLOCK_START\n\nn\n\n+64M\nt\n5\nc\nn\n\n+$ROOTFS_SIZE\nn\n\n\nt\n7\nc\np\nw\n" | ||
407 | 160 | fi | ||
408 | 161 | |||
409 | 162 | echo -e $FDISK_SCRIPT | fdisk -S 63 -H 255 -c $DEVICE | ||
410 | 163 | } | ||
411 | 164 | |||
412 | 165 | # Do the partition labelling | ||
413 | 166 | make_fs() { | ||
414 | 167 | partprobe $DEVICE | ||
415 | 168 | mkfs.vfat -n testboot "${DEVICE}${PARTITION_PREFIX}${TESTBOOT_PART}" | ||
416 | 169 | mkfs.vfat -n sdcard "${DEVICE}${PARTITION_PREFIX}${SDCARD_PART}" | ||
417 | 170 | mkfs.ext3 -L testrootfs "${DEVICE}${PARTITION_PREFIX}${TESTROOTFS_PART}" | ||
418 | 171 | sync | ||
419 | 172 | } | ||
420 | 173 | |||
421 | 174 | main() { | ||
422 | 175 | parse_argv "$@" | ||
423 | 176 | set_device | ||
424 | 177 | if [ "$PRE_ENV" = "Y" ]; then | ||
425 | 178 | write_preenv | ||
426 | 179 | fi | ||
427 | 180 | partition_disk | ||
428 | 181 | make_fs | ||
429 | 182 | } | ||
430 | 183 | |||
431 | 184 | main "$@" | ||
432 | 0 | 185 | ||
433 | === modified file 'master-rootfs-extras/lib/lava/common' | |||
434 | --- master-rootfs-extras/lib/lava/common 2012-03-22 17:46:56 +0000 | |||
435 | +++ master-rootfs-extras/lib/lava/common 2012-05-15 08:44:18 +0000 | |||
436 | @@ -1,6 +1,7 @@ | |||
437 | 1 | # Replaced by lava-create-master | 1 | # Replaced by lava-create-master |
438 | 2 | LAVA_VERSION=@LAVA_VERSION@ | 2 | LAVA_VERSION=@LAVA_VERSION@ |
439 | 3 | LAVA_URL=@LAVA_URL@ | 3 | LAVA_URL=@LAVA_URL@ |
440 | 4 | LAVA_ROOTFS_SIZE=@LAVA_ROOTFS_SIZE@ | ||
441 | 4 | 5 | ||
442 | 5 | # Persistent device configuration file | 6 | # Persistent device configuration file |
443 | 6 | LAVA_DEVICE_CONF=/var/lib/lava/device.conf | 7 | LAVA_DEVICE_CONF=/var/lib/lava/device.conf |
444 | 7 | 8 | ||
445 | === modified file 'master-rootfs-extras/lib/lava/lava-master-init' | |||
446 | --- master-rootfs-extras/lib/lava/lava-master-init 2012-05-14 07:05:18 +0000 | |||
447 | +++ master-rootfs-extras/lib/lava/lava-master-init 2012-05-15 08:44:18 +0000 | |||
448 | @@ -14,7 +14,7 @@ | |||
449 | 14 | LAVA_FIRST_BOOT_LOG=/var/log/lava/first-boot.log | 14 | LAVA_FIRST_BOOT_LOG=/var/log/lava/first-boot.log |
450 | 15 | 15 | ||
451 | 16 | # Set of packages to install on first boot | 16 | # Set of packages to install on first boot |
453 | 17 | LAVA_PKGS="wget dosfstools u-boot-tools bzip2 python ntpdate" | 17 | LAVA_PKGS="wget dosfstools u-boot-tools bzip2 python ntpdate parted" |
454 | 18 | 18 | ||
455 | 19 | DEVICE_TYPE=`lava-device-info --device-type` | 19 | DEVICE_TYPE=`lava-device-info --device-type` |
456 | 20 | 20 | ||
457 | @@ -54,6 +54,12 @@ | |||
458 | 54 | echo "Unable to synchronize time" >&2 | 54 | echo "Unable to synchronize time" >&2 |
459 | 55 | return 1 | 55 | return 1 |
460 | 56 | fi | 56 | fi |
461 | 57 | # Do disk partitioning | ||
462 | 58 | echo "Partitioning disk to LAVA format" >> "$LAVA_FIRST_BOOT_LOG" | ||
463 | 59 | if ! lava-partition-disk -r $LAVA_ROOTFS_SIZE >> "$LAVA_FIRST_BOOT_LOG" 2>&1; then | ||
464 | 60 | echo "Unable to partition disk" >&2 | ||
465 | 61 | return 1 | ||
466 | 62 | fi | ||
467 | 57 | if [ "$DEVICE_TYPE" = "lava:panda" ]; then | 63 | if [ "$DEVICE_TYPE" = "lava:panda" ]; then |
468 | 58 | echo "Applying sysctl fix for streaming errors on Panda" >> "$LAVA_FIRST_BOOT_LOG" | 64 | echo "Applying sysctl fix for streaming errors on Panda" >> "$LAVA_FIRST_BOOT_LOG" |
469 | 59 | echo vm.min_free_kbytes = 32768 >> /etc/sysctl.conf | 65 | echo vm.min_free_kbytes = 32768 >> /etc/sysctl.conf |
450 -LAVA_PKGS="wget dosfstools u-boot-tools bzip2 python ntpdate"
451 +LAVA_PKGS="wget dosfstools u-boot-tools bzip2 python ntpdate parted"
Do we need parted? We use fdisk, we also need partprobe and mkfs.ext4 (they may be already contained in other packages)
Otherwise it looks fine on first read +2