3 ms·
Yes, you can use losetup. ~# dd if=/dev/zero of=image.img bs=1M count=100 ~# LODEVICE=$(losetup --find --show image.img) ~# fdisk $LODEVICE ~# losetup
by peterwwillis 9y ago
Yes, you can use losetup.
~# dd if=/dev/zero of=image.img bs=1M count=100
~# LODEVICE=$(losetup --find --show image.img)
~# fdisk $LODEVICE
~# losetup -d $LODEVICE
^ The above creates a 100MB disk image, binds it to a loopback device, runs fdisk, and then detaches it. I'm not sure how formatting the partition would work but presumably those tools have an offset option too?
edit: this page explains using offsets for mke2fs and doesn't require losetup: https://superuser.com/questions/737072/userspace-manipulation-of-partition-and-disk-images https://superuser.com/questions/737072/userspace-manipulatio...
also, losetup can now scan the device for partition tables and make partition-specific loopbacks! https://stackoverflow.com/a/15200862 https://stackoverflow.com/a/15200862
- jschwartzi 9y agoI have built block-level bootable system images for the TS-7800 using this mechanism. https://www.embeddedarm.com/products/TS-7800 https://www.embeddedarm.com/products/TS-7800 That was before I found multistrap.
- regularfry 9y agoExtlinux on an ext4 partition doesn't need an offset. Or at least didn't when I wrote this: http://www.blackkettle.org/posts/archive/2013-08-19-bootable-mountable-vm-images/ http://www.blackkettle.org/posts/archive/2013-08-19-bootable...