Edit Partitions

At this point, your “setup” system should be up and running the Raspbian graphical desktop, with networking, keyboard and mouse connected, with the “target” system's SD card in a USB reader connected to one of the setup system’s USB ports.

We’ll use the gparted utility to edit the partition table. This is not installed with Raspbian by default, hence the need for a network connection.

It’s usually fastest and easiest to open a Terminal window and type:

sudo apt-get install -y gparted
sudo gparted

If you insist on using a GUI to install the software, click Pi Menu→Preferences→Add / Remove Software. You’ll find gparted in the “Gnome Desktop” section, or use the search field to locate it. Tick the check box and click “Apply” to install.

You can then run gparted via Pi Menu→Preferences→GParted. You’ll be asked for the root password, since this is a system-level operation.

But really, the Terminal way is much quicker.

Select Device

When you first run gparted, it will select the internal SD card by default.

We want to edit the card in the USB reader. To do this, use the pop-up menu near the top-right of the window, or the GParted→Devices menu.

It should appear as /dev/sda or similar…the name’s not important, just make sure you’re not selecting /dev/mmcblk0, which is the internal card.

Save /boot Partition Contents

You’ll see a graph and list of at least two partions on the card — the tiny boot partition, and a much larger partition taking up the bulk of the card — and perhaps one or more small “unallocated” spaces.

The unallocated spaces are used to align partitions to specific start and end points on the card. You can ignore these.

The first “real” partition is a FAT16 filesystem…that’s the boot partition on the target system SD card. Note the mount point of this partition…it’s probably /media/pi/boot or similar. We’ll need this exact path in a moment.

Open a Terminal window if you don’t already have one running, and type the following commands…

cd
sudo cp -r /media/pi/boot .

You may need to change “/media/pi/boot” if a different mount point was shown in gparted. Also, there should be a space between “boot” and the final period.

This copies the full contents of the /boot partition (from the card in the USB reader, not the setup system’s card) to a directory called “boot” in your home folder. This is a temporary measure…we’ll move these files back later.

Unmount Partitions Before Editing

You can not edit partitions while mounted (e.g. accessing files). If there’s a key icon next to one or both partitions, it’s necessary to unmount these filesystems first…

Highlight the /boot partition, then select Partition→Unmount.

As a shortcut, you can also right-click on a partition in the graph or list and select Unmount there.

Repeat for the second (root) partition. There should be no key icons in the list…everything’s editable now.

When everything’s ready, it should look something like this…

Resize the Root Partition

To increase the /boot partition, we first need to shrink the root partition to make space.

Highlight the root partition (/dev/sda2) and select Partition→Resize/Move (or use the right-click shortcut).

The Resize/Move dialog visually shows the full partition size (white) and the amount of data actually present within (yellow).

Because this is a Linux system, there needs to be some space left for caches and log files…or for future updates and additions…we can’t shrink it down to an exact fit.

There’s no hard-and-fast rule for exactly how much should be kept free. One third to one half felt “safe”…with Raspbian Jessie Lite, I rounded to an even 2000 MB.

Any surplus should go to the Free space preceding field…Free space following should be 0.

You can do this either with the numeric fields or by dragging and moving the partition graph with the mouse. When it’s adjusted to your liking, click the “Resize/Move” button.

A pop-up dialog will warn about moving partitions. It’s all good, just click “OK.”

Afterward, it should look something like this (though your partition sizes may vary with card capacity and installed operating system version):

The partition map isn’t actually changed on the card yet. Several operations can be queued up and applied all at once…

Create a Larger Boot Partition

This next sequence is the secret sauce that makes this guide work…

Using gparted’s Resize/Move feature on the boot partition renders the card unreadable on Windows and Mac systems (though it still works with Linux). So the trick here is to delete the existing boot partition, create a new one with the desired size, then restore the files there that we backed up earlier.

Highlight the boot partition (/dev/sda1) and select Partition→Delete (or use the right-click shortcut).

You’ll then have the root partition on the right, and a lot of unallocated space on the left.

Then select Partition→New to begin creating a replacement…

The Create new Partition dialog is similar to the Resize/Move dialog, but with some additional options…

Adjust the size (using the mouse or text fields) to fill the available space, but note that there is an upper limit to the /boot partition size…it cannot exceed 32GB, even on a very large SD card. If there’s room left over, you can edit the root partition again, enlarging it to claim this space, or create extra partition(s) there (these will appear as separate drives, not a contiguous space).

For the other options, select/enter the following exactly:

  • Create as: Primary Partition
  • File system: fat32
  • Label: boot

Then click the “Add” button.

When you’re done, the partition map should look something like the following. It may or may not include small “unallocated” blocks — either way is completely normal, it varies with partition sizes and SD card capacity.

Apply Changes

Nothing has actually changed yet; all operations are queued up. Clicking the “Apply” button (the green check mark) will commence reorganizing the data and partitions on the card…

…but not without warning you first. Take heed, if something goes amiss you might end up with a scrambled card and have to start over from scratch. This is why it’s a good idea to make a backup before any serious disk editing.

Once you click “Apply,” the system will be moving around a lot of data…these operations can take a long time, so this is a good opportunity to take a break or tidy up your desk or something.

Once those operations are complete, you’ll see the same partition map again, but without the “pending” messages at the bottom…everything is now “real” on the card.

To mount the new partitions, it’s easiest just to unplug and re-plug the USB card adapter. You’ll get a “Removable medium” dialog box when you do this (two, actually…one for the boot partition, one for root). Just click “Cancel” for each. We want the partitions mounted but don’t need to browse the files.

Back in gparted now, select GParted→Refresh Devices and then select /dev/sda from the device list.

It should resemble the following, with a key next to each partition (indicating that it’s mounted). This is with an 8 GB card, with Raspbian Jessie Lite in the root partition, the rest allocated to the /boot partition. There might be one or more small unallocated spaces depending on your card.

Restore /boot Data

Last step now is to restore the data we saved from the original /boot partition. In a Terminal window, type the following commands.

(If you encounter an error, do not continue with the next command, since the last step deletes all the saved data! Check your typing and that the named directories exist, etc.)

cd
sudo cp -r boot /media/pi
sudo umount /media/pi/*
sudo rm -r boot

Done!

You can quit from gparted now and unplug the SD card reader.

Perform an orderly shutdown of your setup system (Pi Menu→Shutdown…), then swap the SD cards and confirm the system can still boot from the newly-reconfigured card.

Since mine was a Jessie Lite system, this boots to a command line. I can log in and type “df -k” to see the partition sizes and free space, in kilobytes (the mount points “/” and “/boot” are of interest — the root and boot partitions, respectively).

This guide was first published on May 30, 2016. It was last updated on Sep 20, 2018. This page (Edit Partitions) was last updated on May 27, 2016.