I am trying to understand what I did wrong with the following mount command.Take the following file from here:http://elinux.org/CI20_Distros#Debian_8_2016-02-02_BetaSimply download the img file from here.Then I verified the md5sum is correct per the upstream page:$ md5sum nand_2016_06_02.img3ad5e53c7ee89322ff8132f800dc5ad3  nand_2016_06_02.imgHere 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 0x0So let's check the start of the first partition of this image:$ /sbin/fdisk -l nand_2016_06_02.imgDisk nand_2016_06_02.img: 1.6 GiB, 1702887424 bytes, 3325952 sectorsUnits: sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisklabel type: dosDisk identifier: 0x0212268dDevice               Boot Start     End Sectors  Size Id Typenand_2016_06_02.img1       4096 3325951 3321856  1.6G 83 LinuxIn 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,sfdiskWhat did I missed ?Some other experiments that I tried:$ dd bs=2097152 skip=1 if=nand_2016_06_02.img of=trunc.imgwhich 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 blocksThe physical size of the device is 415232 blocksEither the superblock or the partition table is likely to be corrupt!Abort<y>? yes
bad geometry: block count 967424 exceeds size of device (415232 blocks)
mount;ext4;disk image;resize2fs;sfdisk
Once you have extracted the filesystem you are interested in (using dd), simply adapt the file size (967424*4096=3962568704):$ truncate -s 3962568704 trunc.imgAnd then simply:$ sudo mount -o loop trunc.img /tmp/img/$ sudo find /tmp/img//tmp/img//tmp/img/u-boot-spl.bin/tmp/img/u-boot.img/tmp/img/root.ubifs.9/tmp/img/root.ubifs.4/tmp/img/root.ubifs.5/tmp/img/root.ubifs.7/tmp/img/root.ubifs.2/tmp/img/root.ubifs.6/tmp/img/lost+found/tmp/img/root.ubifs.3/tmp/img/boot.ubifs/tmp/img/root.ubifs.0/tmp/img/root.ubifs.1/tmp/img/root.ubifs.8Another simpler solution is to truncate directly on the original img file:$ truncate -s 3964665856 nand_2016_06_02.img$ sudo mount -o loop,offset=2097152 nand_2016_06_02.img /tmp/img/Where 3962568704 + 2097152 = 3964665856 