Monday, September 16, 2019

partitioning - How to migrate SD Card with Linux?




My scenario is simple: my android phone has internal microSD card with size of 2Gb and I run out of space. Now I bought a new 16Gb microSD card where I want to migrate.



Steps:
1. Insert old sd card, use dd to make backup



# dd if=/dev/mmcblk0 of=backup.img bs=1M



  1. Insert new sd card, dd old image




# dd if=backup.img of/dev/mmcblk0 bs=1M



  1. Resize the partition...wait I can't see partitions there




# fdisk /dev/mmcblk0

Welcome to fdisk (util-linux 2.21.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Command (m for help): p

Disk /dev/mmcblk0: 16.0 GB, 16001269760 bytes
4 heads, 16 sectors/track, 488320 cylinders, total 31252480 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
Disk identifier: 0x00000000

Device Boot Start End Blocks Id System

Command (m for help):




Ok, let's try resize?




# resize2fs /dev/mmcblk0
resize2fs 1.42.3 (14-May-2012)
resize2fs: Bad magic number in super-block while trying to open /dev/mmcblk0
Couldn't find valid filesystem superblock.


GParted shows 16Gb fat16 partition, but the available size is still old 2Gb size from old microSD.




What I'm doing wrong?


Answer



Create a new file system, rsync files over. You don't need dd and rsync will be quicker and copy everything anyway if you use '-a' option.



It is odd that you cannot either resize2fs or see a partition. The only thing is, is this a FAT32 SD card? It is unlikely it is ext2/3/4, which is the only filesystems resize2fs supports. Have you tried fatresize instead?


No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...