.oO turn on ~ tune in ~ drop out Oo.
Resize Linux Partitions / Relocate Mount Points
Resize Linux Partitions / Relocate Mount Points

Resize Linux Partitions / Relocate Mount Points

Sometimes when dealing with SD card based Linux images (i.e. Raspberry Pi images), the image doesn’t make use of the total amount of free space which can be used on your SD card. You might run into a problem where your disk space gets insufficient for further updates or installations.

The easiest way to resize your default partition, is to use GParted, a GNOME based partition editor for graphically managing your disk partitions. Using this tool your are able to resize, copy, and move partitions without data loss. If GParted is not already part of your system, just make it yours 😉

apt-get install gparted

Once installed, you can easily adjust the size of your default partition. Highlight the affected partition and choose: Partition -> Resize/Move


If you would like to create a dedicated partition for a top level folder or if your disk is full and you would like to relocate a folder to another disk you need to

  1. Create & format a partition (if target is not yet available)
  2. Copy the folder
  3. Update the file system table (/etc/fstab)
  4. Reboot
  5. Delete the old folder

You can easily check the storage which is being consumed by each top level folder or mount point

df -h

Create a partition

fdisk vs. parted

Copy the folder

cp -a SOURCE DEST

Update /etc/fstab

Get (& note) dev location or UUID of new partition

ls -l /dev/disk/by-uuid/

Edit /etc/fstab like

UUID=0ecbcf53-42ae-4edb-a5c3-20ca4b648a79   /usr   ext4   defaults   0   0

The syntax is like

[Device] [Mount Point] [File System Type] [Options] [Dump] [Pass]

Device: Can be /dev location or UUID
Options: Mount options to access the partition
Dump: Enable (1) or disable (0) device dump backup
Pass: Enables fsck checks on the device/partition for errors at boot time. (1) should be set for the root device, other partitions should be set to (2). Setting (0) disables checking.

Delete old folder

Remounting (binding) the file hierarchy again, allows to remove the “old” content
Be sure to use the correct order at the mount statement -> mount -B olddir newdir

sudo mkdir /mnt/hiddenroot
sudo mount -B / /mnt/hiddenroot (correct order is important -> mount -B olddir newdir)
sudo rm -rf  /mnt/hiddenroot/usr
sudo umount /mnt/mnt/hiddenroot