1

This question already has an answer here:

it is possible to move some partition(entire) before another? I need to resize my root partition, but the free space is too far away.(I want to move the free space near the root part.)

Can this be done somehow, or have I to backup the data and start from begining?

GParted screenshot showing current disk layout

marked as duplicate by Thomas Dickey, garethTheRed, Jeff Schaller, Jakuje, dr01 May 6 '16 at 21:32

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • How much free space do you have vs. the size of your partitions? – derobert May 6 '16 at 16:23
  • gparted-screenshot it look like this, 11gb freespace, thanks for reply – linearSpin May 6 '16 at 16:33
3

I don't think most of the partition management programs for Linux will move a partition unless there is no overlap, and you can't do that because the ~90.8G extended partition (sda2) will not fit inside the ~11.7G free space. (You can't just move swap, sda5, because of how extended partitions work).

Please read and understand the whole thing before starting. And also, make a backup. Just in case.

What you could do though, is create a a new primary partition, sda3, for the free space. Then use that as a physical volume for LVM. Use LVM to create a volume group with it, then create a logical volume on that. Copy your root filesystem over. This is probably best done from a Live CD/USB.

Then you need to get the system to boot off your logical volume. Hopefully that is as simple as changing /etc/fstab (on the copy on the LV), chrooting to that copy, rebuilding the initramfs, and then finally running update-grub. That'll hopefully give you a grub menu with two choices of what to boot—both the install on /dev/sda1 and on your logical volume.

Reboot to the logical volume. Be very sure you've booted from that, not sda1 (and that the copy worked!). Now you can turn sda1 in to a physical volume, and add it to the same volume group.

You've now got LVM combining sda1 and your new sda3 into one "partition." It doesn't matter that they're not contiguous on disk; you can lvextend your logical volume (with the system running, even) to add more space to your rootfs.

The above requires a fair bit of Linux experience—you may find backing up and reinstalling easier. If you do, I recommend you use LVM when you re-install. It makes growing/shrinking partitions trivial, and growing can almost always be done with the system up.

  • thanks for a big reply. I need to read more about primary/extanded/LVM, but the reainstall seems to do more clean job here. Thanks ones again. – linearSpin May 6 '16 at 17:52

Not the answer you're looking for? Browse other questions tagged or ask your own question.