How can I merge unallocated hard disk space to my linux partition?

12,329

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
Share:
12,329

Related videos on Youtube

K Split X
Author by

K Split X

Updated on September 18, 2022

Comments

  • K Split X
    K Split X over 1 year

    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

    • Fox
      Fox about 7 years
      Partitions can't use non-contiguous space, so first you'll need to move the partitions adjacent to it over and make the space contiguous. You might have to do this from live media, as it could very well prevent you from doing this while the partitions are in use
    • Fox
      Fox about 7 years
      The free space is separated from the Linux partition — there is another partition between them. You need to move that intervening partition to the end, so that the free space is right beside the partition you want to enlarge
    • K Split X
      K Split X about 7 years
      Yes I read about this but how exactly do I "move" a partition?
  • psusi
    psusi about 7 years
    Neat, I didn't know there was a tool that could convert to LVM in place, however, gparted can just move the ntfs partition to the right, though it will take quite a while as it is rather large, and if interrupted, will trash all the files in that partition.