# fallocate -l 256M disk.bin
# zpool create filepool /root/disk.bin
# zfs set mountpoint=/root/filepool filepool
# df -h /root/filepool
Filesystem Size Used Avail Use% Mounted on
filepool 208M 0 208M 0% /root/filepoolMounting partitions from a dd image
21–30 of 37 posts
Re: Mounting partitions from a dd image
#22This is doing it the hard way. Make the image a loop device: losetup /dev/loop0 /path/to/your/image.img Now you can use /dev/loop0 like it's a normal disk. If you're not seeing your partitions (/dev/loop0p1, etc.): partprobe /dev/loop0 When you're done, detach the loop device: losetup -d /dev/loop0 I use this trick to transparently compress ddrescue images with brtfs: https://brashear.me/blog/2017/11/14/how-to-create…
Thanks, not OP but that looks useful to me. For context, I've used the strategy in OP to debug a small linux system running on an SD card, if I have one version that has a bug and one that doesn't, and I don't know the difference, I can image them both, mount them and diff the whole system (i.e. with meld.) And it can be done with the same card over time. I'd like to figure out how to do this with VM disks as well bu…
Re: Mounting partitions from a dd image
#23I think ZFS has the easiest way to do this sort of thing: # fallocate -l 256M disk.bin # zpool create filepool /root/disk.bin # zfs set mountpoint=/root/filepool filepool # df -h /root/filepool Filesystem Size Used Avail Use% Mounted on filepool 208M 0 208M 0% /root/filepool
Re: Mounting partitions from a dd image
#24This is doing it the hard way. Make the image a loop device: losetup /dev/loop0 /path/to/your/image.img Now you can use /dev/loop0 like it's a normal disk. If you're not seeing your partitions (/dev/loop0p1, etc.): partprobe /dev/loop0 When you're done, detach the loop device: losetup -d /dev/loop0 I use this trick to transparently compress ddrescue images with brtfs: https://brashear.me/blog/2017/11/14/how-to-create…
Re: Mounting partitions from a dd image
#25This is doing it the hard way. Make the image a loop device: losetup /dev/loop0 /path/to/your/image.img Now you can use /dev/loop0 like it's a normal disk. If you're not seeing your partitions (/dev/loop0p1, etc.): partprobe /dev/loop0 When you're done, detach the loop device: losetup -d /dev/loop0 I use this trick to transparently compress ddrescue images with brtfs: https://brashear.me/blog/2017/11/14/how-to-create…
Re: Mounting partitions from a dd image
#26Is it also possible to repartition the image with conventional tools? How about setting a boot flag and writing it back to e.g. an USB stick?
fallocate -l 1G disk.img
parted ./disk.imgRe: Mounting partitions from a dd image
#27This is doing it the hard way. Make the image a loop device: losetup /dev/loop0 /path/to/your/image.img Now you can use /dev/loop0 like it's a normal disk. If you're not seeing your partitions (/dev/loop0p1, etc.): partprobe /dev/loop0 When you're done, detach the loop device: losetup -d /dev/loop0 I use this trick to transparently compress ddrescue images with brtfs: https://brashear.me/blog/2017/11/14/how-to-create…
Re: Mounting partitions from a dd image
#28 > sudo kpartx -a test.raw
> lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop0 7:0 0 4G 0 loop
└─loop0p1 253:0 0 4G 0 part
> sudo kpartx -d test.rawRe: Mounting partitions from a dd image
#29I.E. libguestfs is safer when dealing with images of unknown origin, and losetup has inbuilt support now for partition scanning.
Here's an old fdisk/parted wrapper I used to use:
Re: Mounting partitions from a dd image
#30This is doing it the hard way. Make the image a loop device: losetup /dev/loop0 /path/to/your/image.img Now you can use /dev/loop0 like it's a normal disk. If you're not seeing your partitions (/dev/loop0p1, etc.): partprobe /dev/loop0 When you're done, detach the loop device: losetup -d /dev/loop0 I use this trick to transparently compress ddrescue images with brtfs: https://brashear.me/blog/2017/11/14/how-to-create…
# losetup -Pf /path/to/disk.img
# mount /dev/loop0pX /mnt