13

Straight forward, as the title says but, I've never moved a partition with GParted and I'm concerned that I will damage the drive. I have a screen shot.

Gparted screenshot

I'm trying to get the sda2 partition to use the unallocated space. I believe that I have to move sda2 to the end of the hard drive but, I'm not sure and I don't know how.

Any help would be appreciated!

2
  • Do you want to resize sda2 to just 218 GB, or to entire 363 GB? Oct 18, 2012 at 19:25
  • @grawity the entire 363.
    – tijko
    Oct 18, 2012 at 19:27

2 Answers 2

6

Partitions must be contiguous (you cannot use two separate disk areas for a single /dev/sda2), so you will first need to move sda3 to the end of the disk, using GParted's "Move/resize" function.

|1|------sda2------|           free space           |-----------sda3-----------|

Afterwards, use the same function to expand sda2 into the free space in the middle:

|1|----------------------sda2-----------------------|-----------sda3-----------|

However, since sda3 is your system partition, you cannot move or resize it from the same system. You will have to boot from the Ubuntu CD instead.

Moving (or, in rare cases, resizing) partitions can cause all files to be lost – for example, if the power goes out during moving (it takes a long time to move a partition). It never causes physical damage, however.

4
  • Thanks for the reply grawity, I was worried that this would be what I have to do. I'm thinking grub will be damaged in the process too, right?
    – tijko
    Oct 18, 2012 at 19:57
  • @tijko: If it's in sda1, then it should remain untouched... but yes, there's a chance you'll need to reinstall it using the CD. Oct 18, 2012 at 22:39
  • 2
    my concerns up ended up being unfounded :) I was getting a mixed up with how to use GParted but, in the end Gparted couldn't have been more straight-forward. I had been thinking I needed to specify numerically where I wanted to place sda2, when all it came down to was to slide sda3 to the right.
    – tijko
    Oct 19, 2012 at 9:42
  • so to be doubly clear, if I move a partition that contains, say, an ext4 filesystem, the filesystem will be intact afterwards? And this is true even if I need to trim a bit off the end of the partition without needing to run some kind of filesystem "defrag" to make sure no data is in that part of the partition that is being trimmed off?
    – Michael
    Dec 11, 2018 at 4:55
8

grawity's answer is not entirely complete for this question. It is possible to move the contents of partition 2 to the end of the device. Simply right-click and copy the partition, and paste it at the end. After that succeeds, delete partition 2.

It will cause partition 2 and partition 3 to switch in naming. After moving sda2 to the end of the device- sda3 will be renamed to sda2, and sda2 renamed to sda3.

You will need inform the system of this change. If sda2 or sda3 are referenced in /etc/fstab, then you will need to change any references of sda2 to sda3 and sda3 to sda2. Also, you will have to reinstall the Grub bootloader so it knows about the changes.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .