How do I mount a raw image?

Fer39

New Member
Dec 18, 2017
3
1
1
36
root@virt1:/home# losetup /dev/loop22 disk-drive-ide0.raw

root@virt1:/home#fdisk -l

Disk /dev/loop22: 32 GiB, 34359738368 bytes, 67108864 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x3b2dcc21

Device Boot Start End Sectors Size Id Type
/dev/loop22p1 * 2048 64286719 64284672 30.7G 83 Linux
/dev/loop22p2 64288766 67106815 2818050 1.4G 5 Extended
/dev/loop22p5 64288768 67106815 2818048 1.4G 82 Linux swap / Solaris


root@virt1:/home# mount /dev/loop22p1 /mnt/123
mount: special device /dev/loop22p1 does not exist
 
Thanks helped !!!!

losetup /dev/loop22 disk-drive-ide0.raw
partx -v --add /dev/loop22
mount /dev/loop22p1 /mnt/123
 
  • Like
Reactions: take
Code:
 losetup -o offset=1048576 /dev/loop22 disk-drive-ide0.raw
mount /dev/loop22 /mnt/123
 
I signed up to these forums just to thank you guys for helping me fix an issue. My home lost power this morning while I was sleeping (6/26/2022). All VM's and containers save for one, came up without issue. It just figures that the one that didn't, was the only one I hadn't backed up and the one with data I really didn't want to lose. Thankfully, I was able to use the info above to fix the errors and now that container is up once again. And yes, I am going to back it up after I write this message!
 
Thanks helped !!!!

losetup /dev/loop22 disk-drive-ide0.raw
partx -v --add /dev/loop22
mount /dev/loop22p1 /mnt/123

thx alot! it helped me out too

but there is a shorter way to loop all block-device partitions as `man losetup` says:

Bash:
losetup --partscan /dev/loop22 disk-drive-ide0.raw 
mount /dev/loop22p1 /mnt/123

so it is --partscan or -P key