Skip to main content
Added info about `--partscan`
Source Link
Daniel B
  • 63.9k
  • 9
  • 128
  • 176

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.

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 /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. If it’s not working, you may have to run 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.

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.

Your version of losetup may not support --partscan. Instead, you can use sudo partprobe /dev/loop0. 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.

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 /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. If it’s not working, you may have to run 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.

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 /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. If it’s not working, you may have to run sudo partprobe, 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.

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 /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. If it’s not working, you may have to run 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.

Source Link
Daniel B
  • 63.9k
  • 9
  • 128
  • 176

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 /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. If it’s not working, you may have to run sudo partprobe, 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.