1

I have a micro sd card that contains these partitions:

Disk /dev/sdb: 29,7 GiB, 31914983424 bytes, 62333952 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: 0xa6202af7

Device     Boot  Start      End  Sectors Size Id Type
/dev/sdb1         8192   122879   114688  56M  c W95 FAT32 (LBA)
/dev/sdb2       122880 10608639 10485760   5G 83 Linux

I would like to clone it but just cloning those two partitions, not the entire 29,7GB. So I used this command:

dd bs=1M count=$((5431623169 / (1024*1024) + 1)) if=/dev/sdb of=myimage.img
truncate -s 5431623169

This should create a image with the two partitions. Now I would like to mount the second partition of myimage.img to modify it. I'm therefore running the command:

sudo mount -t ext4 -o loop,offset=62914560 myimage.img mount/

however this produces the following output:

mount: wrong fs type, bad option, bad superblock on /dev/loop1,
       missing codepage or helper program, or other error

       In some cases useful info is found in syslog - try
       dmesg | tail or so.

sdb1 instead mounts just fine. I'm sure it is ext4 as blkid returns that.

This micro sd card is a comlpete firmware for a Raspberry Pi Linux system. If I flash myimage.img to a new sd card and run it, the system seems to work properly, which means it is able to mount it.

Any idea why I'm not able to mount it manually using the mount command as I shown above?

2

Problem was that I didn't copy the last 512 bytes of the last sector. This way the last partition was incomplete. By copying one more sector everything mounted properly.

| improve this answer | |

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.