Page 2 of 2

Re: How do I use a bigger sd card for the Raspberry Pi?

Posted: Sun May 18, 2014 7:34 pm
by DougieLawson
If you start with non-NOOBS raspbian booted in the RPi there's three special files: /dev/mmcblk0 /dev/mmcblk0p1 and /dev/mmcblk0p2 which are the whole card, the FAT /boot filesystem and the ext4 root filesystem.

When you mount a blank SDCard in your USB reader that (normally) appears as /dev/sda and /dev/sda1 (full card FAT filesystem)

So we can start by copying /dev/mmcblk0 to /dev/sda
sudo dd if=/dev/mmcblk0 of=/dev/sda bs=20M # give it 20MB to play in.

You now have
/dev/sda, /dev/sda1 (FAT) and /dev/sda2 (ext4) in the first 4GB of the new card and xxxGB of unused/unassigned space.

You need to pop the card out and back in to get Linux to spot that the partition table has been updated by that sudo dd copy.

sudo fdisk /dev/sda # re-write the partition table
Note: Here's the arcane commands (my comments are in parentheses)
p (print the current partition table you need some numbers from that later)
d (delete a partition)
2 (partition #2)
n (new)
p (primary - same type as from the p command)
2 (partition #2)
122880 (use the starting value from p command for the start of the second partition)
[enter] (use the rest of the card)
w (write)

sudo e2fsck -f /dev/sda2 # runs a checkdisk process
sudo resize2fs /dev/sda2 # stretches it out to fill the second partition.

sudo shutdown -h now
pop both cards out. Pop the bigger card in the normal slot.

Job done. Time to get a beer.

Re: How do I use a bigger sd card for the Raspberry Pi?

Posted: Sun May 18, 2014 9:00 pm
by MattHawkinsUK
I'm running Windows 7 64-bit.