For this part of the process, and as a follow-up to my previous post, I will be using the beautifully clear and concise post at http://serverfault.com/questions/281628/combine-partitions-to-one-disk-image.
I have two filesystem images that I want to combine into a single 16G image file. The above post mentions kpartx and I made the mistake of thinking that it was a KDE version of parted (!) except that it doesn’t work with the -av options.
A wee bit of digging hinted at kpartx being part of the multipath-tools package, but pacman couldn’t find it.
A quick word with one of my kids (who is more of an Arch whizz than I) suggested that the problem was that multipath-tools is part of the AUR (Arch Use Repository) and can be installed using the command,
$ yaourt -S multipath-tools
Note, as a unprivileged user. So we continue with the process.
# truncate --size 16G r-pi-16gb.img # fdisk r-pi-16gb.img
With two partitions: 100M and 15.9 G.
# kpartx -av r-pi-16gb.img add map loop2p1 (254:0): 0 204800 linear /dev/loop2 2048 add map loop2p2 (254:1): 0 33347584 linear /dev/loop2 206848 # dd if=rpi-arch-root.img of=/dev/mapper/loop2p1 bs=1M 100+0 records in 100+0 records out # dd if=rpi-arch-ext4.img of=/dev/mapper/loop2p2 bs=1M dd: error writing ‘/dev/mapper/loop2p2’: No space left on device 16284+0 records in 16283+0 records out 17073963008 bytes (17 GB) copied, 509.39 s, 33.5 MB/s
Not what I was expecting. I have checked my sums and they all seem to match up: the ext4 image is 15.9 GiB (16284 M) and the combined size should match the 16G image file.
A closer check of fdisk does seem to highlight a discrepancy:
- r-pi-16gb.img2 has 33347584 sectors for 15.9G
- rpi-arch-ext4.img: 15.9 GiB, 17075011584 bytes with 33349632 sectors
So, perhaps the problem here is because there is an offset at the start, but extending the 16G disk image won’t work because that is then bigger than the size of the SD card. Back to the drawing board and out with the calculator.