If image.img
is indeed the image containing the Ubuntu root partition and it is indeed raw, things are very simple.
sudo losetup --find --show --partscan /path/to/image.img
# This will print something like /dev/loop0
sudo mount /dev/loop0p3 /mnt/ubuntu
You need to use the correct partition number, of course, which may not be p3
. If it’s
Your version of losetup
may not workingsupport --partscan
. Instead, you may have to runcan use sudo partprobe /dev/loop0
, too. You can list partitions using sudo fdisk -l /dev/loop0
(or using similar tools).
Once you’re done:
sudo umount /mnt/ubuntu
sudo losetup --detach /dev/loop0
If it’s a different image format, you may try qemu-nbd or libguestfs-tools, both of which I unfortunately have no experience with. If you’re using QEMU, you probably already have qemu-nbd.