Mounting partitions from a dd image
assafmo.github.io
Mounting partitions from a dd image
1–10 of 37 posts
Re: Mounting partitions from a dd image
#2How about setting a boot flag and writing it back to e.g. an USB stick?
Re: Mounting partitions from a dd image
#3Re: Mounting partitions from a dd image
#4 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-a-compress...Re: Mounting partitions from a dd image
#5Is 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?
~# 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-manipulatio...
also, losetup can now scan the device for partition tables and make partition-specific loopbacks! https://stackoverflow.com/a/15200862
Re: Mounting partitions from a dd image
#6This 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
#7Re: Mounting partitions from a dd image
#8 # vnconfig vnd0 install63.fs
Then you can treat vnd0 as if it was a disk: # disklabel vnd0
# /dev/rvnd0c:
type: vnd
disk: vnd device
label: fictitious
duid: 138b4f2a2e184426
flags:
bytes/sector: 512
sectors/track: 100
tracks/cylinder: 1
sectors/cylinder: 100
cylinders: 7382
total sectors: 738240
boundstart: 1024
boundend: 737280
drivedata: 0
16 partitions:
# size offset fstype [fsize bsize cpg]
a: 736256 1024 4.2BSD 2048 16384 16142
c: 738240 0 unused
i: 960 64 MSDOS
For instance, to mount the 'a' partition: # mount /dev/vnd0a /mnt
You can also associate an encryption key with the device. All data written to the diskimage will then be encrypted.Re: Mounting partitions from a dd image
#9> mount -t -o ro,offset=$((51296390)) x.dd partition_2
Isn't the mount type "-t" value missing?
Re: Mounting partitions from a dd image
#10Despite reading all of the documentation I could find, and even going so far as to read kernel source code, I could never get the system to recognize my striped block data. That is, I tried to generate three files composing a RAID-5 "by hand", but mdadm would refuse to mount them. I never figured out if there was some additional id-block I was missing, or if my striping algorithm was not correct.