mount loop offset not working anymore

0

I always mounted complete disk images with mount -o loop,offeset=$((START * BLOCKSIZE)) image.raw /mnt

It's not working with the last 2 images. I always get the "mount: wrong fs type, bad option, bad superblock on /dev/loop0," message.

With this image the offset should be 1048576

Disk sm.img1: 39.1 GiB, 41943040000 bytes, 81920000 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: 0x0000aa2b

Device     Boot    Start      End  Sectors  Size Id Type
sm.img11    *        2048 79691775 79689728   38G 83 Linux
....

The image is working, I can boot it in qemu.

The mount cmd I am using: mount from util-linux 2.29.1 (libmount 2.29.1: btrfs, assert, debug)

What am I doing wrong?

gj13

Posted 2017-03-01T09:10:42.823

Reputation: 278

Answers

1

TLDR: Most likely your sectors are not 512 bytes-long. The most common alternative value is 4096 bytes per sector, hence the offset should be 2048x4096= 8,388,608. You may try this value, or..

you may determine it:

# ls -lt debian-testing-amd64-DVD-1.iso -rw-rw-r-- 1 mario mario 3981279232 mar  1 10:58 debian-testing-amd64-DVD-1.iso
# hexdump -s 446 -n 64 -v -e '1/1 "Partition:| %02x" 3/1 " | %3u" 1/1 " | %02x" 3/1 " | %3u" 2/4 " | %9u" "\n"' debian-testing-amd64-DVD-1.iso 
Partition:| 80 |   0 |   1 |   0 | 00 | 237 | 224 | 252 |         0 |   7775936
Partition:| 00 | 254 | 255 | 255 | ef | 254 | 255 | 255 |     19984 |       832
Partition:| 00 |   0 |   0 |   0 | 00 |   0 |   0 |   0 |         0 |         0
Partition:| 00 |   0 |   0 |   0 | 00 |   0 |   0 |   0 |         0 |         0
#

Thus the size of this disk is exactly 3981279232 bytes, and it contains 7775936 sectors, each one of which is then 3981279232/7775936 = 512 bytes long. You may learn more by reading here.

MariusMatutiae

Posted 2017-03-01T09:10:42.823

Reputation: 41 321

The size is 512. Binwalk found an ext4 signature at 1048576. – gj13 – 2017-03-01T11:11:07.220

The ext4 was not clean and if you use the ro flag ext4 simply doesn't mount it. My dmesg log output terminal was hanging so I did not get the ext4 kernel warning about this. I accept your answer because it is the best method if the blocksize is unknown. – gj13 – 2017-03-01T11:19:08.003

0

I just think you have a typo in the command used.

mount -o loop,offeset=$((START * BLOCKSIZE)) image.raw /mnt

Replacing offeset with offset works for me.

mount -o loop,offset=$((2048 * 512)) image.raw /mnt

Another way is to use losetup:

losetup /dev/loop0 image.raw -o $((2048 * 512))
mount /dev/loop0 /mnt

Hope it helps.

Pavol Cupka

Posted 2017-03-01T09:10:42.823

Reputation: 1