I am trying to understand what I did wrong with the following mount command.
Take the following file from here:
Simply download the img file from here.
Then I verified the md5sum is correct per the upstream page:
$ md5sum nand_2016_06_02.img
3ad5e53c7ee89322ff8132f800dc5ad3 nand_2016_06_02.img
Here is what file has to say:
$ file nand_2016_06_02.img
nand_2016_06_02.img: x86 boot sector; partition 1: ID=0x83, starthead 68, startsector 4096, 3321856 sectors, extended partition table (last)\011, code offset 0x0
So let's check the start of the first partition of this image:
$ /sbin/fdisk -l nand_2016_06_02.img
Disk nand_2016_06_02.img: 1.6 GiB, 1702887424 bytes, 3325952 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: 0x0212268d
Device Boot Start End Sectors Size Id Type
nand_2016_06_02.img1 4096 3325951 3321856 1.6G 83 Linux
In my case Units size is 512, and Start is 4096, which means offset is at byte 2097152. In which case, the following should just work, but isn't:
$ mkdir /tmp/img
$ sudo mount -o loop,offset=2097152 nand_2016_06_02.img /tmp/img/
mount: wrong fs type, bad option, bad superblock on /dev/loop0,
missing codepage or helper program, or other error
In some cases useful info is found in syslog - try
dmesg | tail or so.
And, dmesg reveals:
$ dmesg | tail
[ 1632.732163] loop: module loaded
[ 1854.815436] EXT4-fs (loop0): mounting ext2 file system using the ext4 subsystem
[ 1854.815452] EXT4-fs (loop0): bad geometry: block count 967424 exceeds size of device (415232 blocks)
None of the solutions listed here worked for me:
- resize2fs or,
- sfdisk
What did I missed ?
Some other experiments that I tried:
$ dd bs=2097152 skip=1 if=nand_2016_06_02.img of=trunc.img
which leads to:
$ file trunc.img
trunc.img: Linux rev 1.0 ext2 filesystem data (mounted or unclean), UUID=960b67cf-ee8f-4f0d-b6b0-2ffac7b91c1a (large files)
and same goes the same story:
$ sudo mount -o loop trunc.img /tmp/img/
mount: wrong fs type, bad option, bad superblock on /dev/loop2,
missing codepage or helper program, or other error
In some cases useful info is found in syslog - try
dmesg | tail or so.
I cannot use resize2fs since I am required to run e2fsck first:
$ /sbin/e2fsck -f trunc.img
e2fsck 1.42.9 (28-Dec-2013)
The filesystem size (according to the superblock) is 967424 blocks
The physical size of the device is 415232 blocks
Either the superblock or the partition table is likely to be corrupt!
Abort<y>? yes