Posts Tagged ‘embedded’

Make squashfs Disk Image

January 17th, 2013 1 comment

Raspberry Pi (and Cubieboard) SD disk images typically have two (or three) partitions: the first is Fat32 (50-100MB) and includes the boot files, while the second (>1GB) contains the main Linux image. With compression, the combined image can be reduced from several GB (of mostly empty space) to a couple hundred MB.

With a regular Linux desktop computer that has kpartx and mksquashfs installed, you can convert the second partition to SquashFS like this:

$ sudo kpartx -av image_you_want_to_convert.img
add map loop0p1 (252:5): 0 117187 linear /dev/loop0 1
add map loop0p2 (252:6): 0 3493888 linear /dev/loop0 118784
$ sudo mount /dev/mapper/loop0p2 /mnt
$ sudo mksquashfs /mnt converted_image.img -comp lzo -e lib/modules
$ sudo umount /mnt
$ sudo kpartx -d image_you_want_to_convert.img