I have followed Cloning an SD card onto a larger SD card to clone a 2G SD card to a 32G SD card, and the file system is ext4. However, on the 32G SD card I only can see 2G space available. Is there a way to maximize it out? Here is the output of fdisk:

Command (m for help): p

Disk /dev/sdb: 32.0 GB, 32026656768 bytes
64 heads, 32 sectors/track, 30543 cylinders, total 62552064 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: 0x000e015a

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *          32      147455       73712    c  W95 FAT32 (LBA)
/dev/sdb2          147456     3994623     1923584   83  Linux

I want to make /dev/sdb2 use up the remaining space. I try resize2fs /dev/sdb after dd, but get message below:

$ sudo resize2fs /dev/sdb
resize2fs 1.42 (29-Nov-2011)
resize2fs: Bad magic number in super-block while trying to open /dev/sdb
Couldn't find valid filesystem superblock.

Any idea on what I am doing wrong? Thanks.

Edit 1

Now I use gparted to resize the sd card, and it works. I think it's possible to do this in command line. In my example, you should umount /dev/sdb2 first, then resize2fs /dev/sdb2 I guess. At least in gparted GUI I need to umount /dev/sdb2 first.

Edit 2

Reboot will cause "init not found" error. Even if I specify init path, it doesn't find /root/dev/console then kernel panic. Error message below:

/init: line 352: can't open /root/dev/console: no such file

/dev/sdb is the device node pointing to the entire hard drive, and it starts at the first sector of the HDD. You need to point resize2fs to the specific partition you want to resize (apparently, in your case, /dev/sdb2).

FYI, using the console is not necessary if you have a graphical desktop. Just install gparted (you didn't indicate your Linux distro, so I don't know if it's available or, if so, what steps to install it). It will provide a user-friendly way to do this. You could also probably do it with the palimpsest Disk Utility on modern OSes.

| improve this answer | |
  • Because I am using a virtual machine, I prefer to using command line rather than GUI. ;-) resize2fs /dev/sdb2 shows me: "The filesystem is already 1923584 blocks long. Nothing to do!". I guess I need to modify partition table first? – chenwj Sep 21 '12 at 3:01
  • I'm having this problem myself, but this answer isn't working. resize2fs /dev/sdb2 on an unmounted filesystem (after resizing with parted still produces "Bad magic number in super-block while trying to open /dev/sdb2") – Doktor J Apr 20 at 15:12

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.