Linux – Merge Unallocated Hard Disk Space to Partition

gpartedhard-disklinux-mintpartition

I am currently dualbooted between Windows 8 and Linux Mint 18

Using GParted, I see this following:
enter image description here

The selection partition is unallocated for a size of 25 GB, I would like to merge this with my dev/sda6 (linux partition), so that I can make my linux partition about 50GB. I'm not really sure about the process though on how to do this? I try to resize dev/sda6, but I see that the maximum size and minimum size are the same. How do I merge the unaccolated space?
enter image description here

Best Answer

The free space and your existing Linux partition are not contiguous, so you can't simply merge them. Linux's own partition scheme, LVM, allows a filesystem to be split between separate location on the disk or even between disks. But native MBR or GPT partitions have to be a single contiguous area.

Moving the partition in the middle would be complicated because there isn't enough space for a non-overlapping move. Unless you move it to another disk and then back, I recommend switching Linux to use LVM, which has other benefits as well.

The tool blocks (formerly lvmify) by Gabriel can convert an existing partition in place. Run it from a live CD/USB.

blocks to-lvm --vg-name=mint /dev/sda6
lvrename mint sda6 root

This will make your system unbootable, so you need to do one more thing before you reboot. Mount the volume and get ready to run commands in Mint via chroot:

mkdir /media/root
mount /dev/mapper/mint-root /media/root
mount --rbind /proc /media/root/proc
mount --rbind /dev /media/root/dev
mount --rbind /sys /media/root/sys
chroot /media/root

Run update-grub and update-initramfs. Now your system will have the necessary drivers at boot time to boot from LVM.

You can now reboot to your Linux installation and add more space to the LVM volume. Create a partition /dev/sda8 encompassing the space you want to use. If asked for a partition type, select LVM physical volume. Then run the following commands to add the space to your root partition.

pvcreate /dev/sda8
vgextend mint /dev/sda8
lvextend mint/root /dev/sda8
resize2fs /dev/mapper/mint-root
Related Question