0

I've created a disk image (not just a partition) of an SD card using dd. It contains one ext4 partition.

parallels@debian-gnu-linux-10:/media/psf/Irfan$ file -k old_armbian.img
old_armbian.img: Linux rev 1.0 ext4 filesystem data, UUID=62974604-6430-48bc-9f66-90d77651e3bf (extents) (large files) (huge files) (Lepton 3.x), scale 0-0, spot sensor temperature 0.000000, unit celsius, color scheme 0, calibration: offset 0.000000, slope 0.000000 (Lepton 2.x), scale 0-0, spot sensor temperature 0.000000, unit celsius, color scheme 0, calibration: offset 0.000000, slope 0.000000\012- data

I've been trying to mount this img on Debian via a loopback mount, but it refuses to detect and mount the ext4 that is contained in it.

The only way I was able to mount it was through a VM where I attached this img file to the CDROM device. After which I was able to mount it through the CDROM block device (/dev/sr0)

The issue:

$ sudo mount -t ext4 -o loop,ro ./old_armbian.img /mnt/PEND/
mount: /mnt/PEND: wrong fs type, bad option, bad superblock on /dev/loop0, missing codepage or helper program, or other error.
$ sudo mount ./old_armbian.img /mnt/PEND/
mount: /mnt/PEND: can't read superblock on /dev/loop0.

I've also tried doing losetup:

$ sudo losetup --partscan -f old_armbian.img
$ sudo mount -t ext4 /dev/loop0 /mnt/test
mount: /mnt/test: wrong fs type, bad option, bad superblock on /dev/loop0, missing codepage or helper program, or other error.

Only this one worked:

$ sudo mount -t ext4 -o ro /dev/sr0 /mnt/PEND

What gives?

2
  • you're trying to mount /dev/loop0 at /mnt/PEND, but /mnt/PEND is already a mountpoint of /dev/sr0 Jul 5, 2021 at 21:30
  • @MarcusMüller I've made a new directory and also tried to mount there as well but no luck.
    – Irfan
    Jul 6, 2021 at 1:59

1 Answer 1

1

With -o loop mount creates a loop device and tries to mount it, but the device doesn't contain an ext4 filesystem, it contains a partition table which is not mountable. You need to mount the partition on the image and mount can't do that, you need to create the loop device manually first with --partscan to tell kernel to probe the partition table and the mount the partition:

# losetup --partscan -f old_armbian.img

# mount /dev/loop0p1 /mnt/PEND

I'm not sure why this works with the virtual CD, it should have the same problem (it's possible the virtual CD is created with an offset and actually starts at the first partition or something like that).

3
  • I've tried this but /dev/loop0p1 doesn't exist (updated my question to post screenshots)
    – Irfan
    Jul 5, 2021 at 15:42
  • Are you sure the image contains a partition? What does blkid -p /dev/loop0 prints? Jul 5, 2021 at 15:56
  • It doesn't print anything for blkid -p /dev/loop0. And yes, I'm certain this image contains an ext4 fs because blkid -p /dev/sr0 gives me /dev/sr0: UUID="62974604-6430-48bc-9f66-90d77651e3bf" VERSION="1.0" TYPE="ext4" USAGE="filesystem"
    – Irfan
    Jul 5, 2021 at 16:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.