0

I need to merge tow partitions with Gparted.

My main partition is: /dev/sda6 And i want to merge /dev/sda5 partition into the main partition. sda5 is empty and unused partition. Please see the follwing screenshot:

enter image description here

Can someone instruct me how to do that? I'm afraid to lost the data in my main partition.

5
  • You mean your main partition is sda6, sda5 is empty and unused, and you want to merge it into sda6, correct?
    – Alaa Ali
    Dec 20, 2014 at 15:09
  • Yes. I fixed it. It was a typo.
    – Omri
    Dec 20, 2014 at 15:19
  • "I'm afraid to lost the data in my main partition." you understand what a "backup" is?
    – Rinzwind
    Dec 20, 2014 at 16:16
  • It's not just about the data itself. I have a lot a configurations in my Ubuntu, configuration of development environment and many other things. Backup the data won't help in this case. I need to make an image of the entire operating system.
    – Omri
    Dec 20, 2014 at 16:34
  • I don't think they understand "backup" --- changing a disk like this has a risk of losing data, if there's anything you absolutely must keep on the HD, make a copy of it first! And a compressed backup might be relatively small.
    – Xen2050
    Dec 20, 2014 at 18:30

1 Answer 1

1

Here is the general approach you would be taking. You first have to boot into a live Ubuntu environment. To do that, burn an Ubuntu image on a CD/DVD/USB and boot from it as if you're installing Ubuntu but choose "Try Ubuntu" instead of "Install Ubuntu", then open GParted.

  1. Right click on sda5 and Delete. So you'll end up with sda6, sda7, followed by a big unallocated space.

  2. Right click on sda7 (swap) and Delete (if Delete is grayed out, choose Swapoff first). We'll recreate it later. So now you'll end up with sda6 followed by a big unallocated space.

  3. Right click on sda6 and choose Resize/Move, and drag the right arrow to the right to fill up that space. Now you're "expanding" sda6, but don't expand it til the end. Leave 8 GBs in the end. Once done, click OK. Now you'll end up with a larger sda6 and 8 GB of unallocated space.

  4. Right click the unallocated space, choose New, then choose linux-swap as the filesystem. Click OK.

  5. Now your table in GParted should show your merged (and large) sda6, followed by (I think it might be) sda8 which is the swap partition. If you made any mistakes, close GParted and start over again. But if all looks good, click apply to apply all the changes we did. This might take sometime.

  6. Once done, reboot and remove the CD/DVD/USB to go back into your Ubuntu. Open a terminal and type sudo blkid /dev/sda8 (I'm assuming that sda8 is the partition number for the new swap partition we created). Copy the UUID=#### part. Type sudo nano /etc/fstab. Look for the line that looks like this:

    # swap was on /dev/sda7 during installation
    UUID=###### none            swap    sw              0       0
    

    And change that UUID to the one you copied from the previous command. Save and close by Ctrl+X, Y, then Enter.

  7. Reboot and you're done.

You must log in to answer this question.

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