Increase Raspberry Pi’s boot partition size

Like many of you, I have a Raspberry Pi that I’ve been using for a while. The only issue I’ve ever had with the Raspberry Pi is having to increase the boot partition from 44M to something descent, say 250M. Without the extra space, I’m stuck on older kernels.

The first thing you will want to do is backup your Raspberry. In my case, I back up to a NFS share [you can search the internet now to mount/setup a NFS share for Raspberry]. I then backup both boot and root partitions, for example [/mnt/backup points to a NFS share]:

# tar c / -b 8192 –one-file-system –totals | pigz -4 > /mnt/backup/root.tgz

and

# tar c /boot -b 8192 –one-file-system –totals | pigz -4 > /mnt/backup/boot.tgz

You may have noticed I use pigz for compression, again, you can look it up on the internet.

Once I have my backups, I copied the backups to my Linux Desktop system. On the Linux Desktop, I create a new SD card [larger] since SD cards a cheap, it’s much easier to have the old card ready to go back in if failure hits.

Placing the new SD card in my Linux Desktop system, I use “etcher” on my Linux desktop to build the SD card. Just pick a raspberry distro and let it load onto the card. This will create the needed “boot” and “root” with the larger sizes.

Now comes the surgery, we need to use the partitions that “etcher” created to put our data into. The first thing you will need to do is mount up to get the partition names from the SD Card:

# blkid /dev/sdb  [assuming sdb is your USB SD card]

/dev/mmcblk0p1: LABEL_FATBOOT=”boot” LABEL=”boot” UUID=”1234-1234″ TYPE=”vfat” PARTUUID=”a1234567-01″
/dev/mmcblk0p2: LABEL=”rootfs” UUID=”ffffffff-aaaa-bbbb-cccc-dddddddddddd” TYPE=”ext4″ PARTUUID=”a1234567-02″
/dev/mmcblk0: PTUUID=”a1234567″ PTTYPE=”dos”

You will need to write down the PARTUUID for each partition [in my example: boot is a1234567-01, root is a1234567-02].

Now, mount up the SD card’s boot partition:

# mkdir root

# mkdir boot

# mount /dev/sdb1 boot

move down to the boot directory

# cd boot

# unalias rm   [this means if anything was defined as “rm” command, clear/delete it]

# rm -r *      [This will delete everything under the boot partition]

move back up a level/directory and lets restore our “boot” partition

# cd ..

# tar xvzf /mnt/backup/boot.tgz .

[That will restore the boot.tgz file from above to your boot directory].

# vi boot/cmdline.txt

Look for “root=PARTUUID=”

Change the part after PARTUUID to match root blkid above, in this example, that would be a1234567-02 making it look like “root=PARTUUID=a1234567-02”

# umount boot

Now, lets do the root partition:

# mount /dev/sdb2 root

# cd root

# rm -r *      [This will delete everything under the boot partition]

# tar xvzf /mnt/backup/root.tgz .

[That will restore the root.tgz file from above to your root directory].

Now for the critical surgery to the root files:

# cd etc

# vi fstab

[edit the fstab file, find the mounts for boot and root. From our example, change the PARTUUID to match the blkid you got from above]

PARTUUID=a1234567-01 /boot vfat defaults 0 2
PARTUUID=a1234567-02 / ext4 defaults,noatime 0 1

# cd ../..

# umount root

Now, your SD card [example /dev/sdb] should have a restored copy of your boot partition [with proper PARTUUID fixes] and your root partition [with etc/fstab fixed PARTUUID changes].

You should be able to now remove the card from your Linux desktop and boot up in your Raspberry pi.