How to combine partitions

Questions about Grub, UEFI,the liveCD and the installer
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
bushyiii
Level 4
Level 4
Posts: 258
Joined: Thu Apr 07, 2016 12:42 am

How to combine partitions

Post by bushyiii »

I currently have two partitions on my HDD, one has Mint 17.x and the other 18.2. I want to eliminate 17 and expand 18.2 to occupy the entire drive. I cannot seem to find a way with GParted. Can it be done?
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
JerryF
Level 16
Level 16
Posts: 6571
Joined: Mon Jun 08, 2015 1:23 pm
Location: Rhode Island, USA

Re: How to combine partitions

Post by JerryF »

Can you run this command, then copy and paste the result:

Code: Select all

sudo parted -l
or give a snapshot of the disk in Gparted
bushyiii
Level 4
Level 4
Posts: 258
Joined: Thu Apr 07, 2016 12:42 am

Re: How to combine partitions

Post by bushyiii »

Model: ATA ADATA SP550 (scsi)
Disk /dev/sda: 120GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number Start End Size Type File system Flags
1 1049kB 69.2GB 69.2GB primary ext4 boot
2 69.2GB 120GB 50.9GB extended
6 69.2GB 116GB 46.6GB logical ext4
5 116GB 120GB 4282MB logical linux-swap(v1)
User avatar
JerryF
Level 16
Level 16
Posts: 6571
Joined: Mon Jun 08, 2015 1:23 pm
Location: Rhode Island, USA

Re: How to combine partitions

Post by JerryF »

Actually, you have 3 partitions, #1 is a Primary partition which is the boot partition.
#6 and #5 are Logical partitions that are contained within #2 which is an Extended partition.

I don't think it'll be easy to move the Extended partition, but someone with more experience may have the answer.
bushyiii wrote:

Code: Select all

Model: ATA ADATA SP550 (scsi)
Disk /dev/sda: 120GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start   End     Size    Type      File system     Flags
 1      1049kB  69.2GB  69.2GB  primary   ext4            boot
 2      69.2GB  120GB   50.9GB  extended
 6      69.2GB  116GB   46.6GB  logical   ext4
 5      116GB   120GB   4282MB  logical   linux-swap(v1)
bushyiii
Level 4
Level 4
Posts: 258
Joined: Thu Apr 07, 2016 12:42 am

Re: How to combine partitions

Post by bushyiii »

Gparted screenshot is attached
fabien85
Level 7
Level 7
Posts: 1877
Joined: Tue Mar 11, 2014 4:30 pm

Re: How to combine partitions

Post by fabien85 »

Which partition correspond to which system ?
One way to say, would be to tell us on which system you were booted when you made the gparted screenshot.

The easy situation is if LM 18.2 is on sda1 and you want to get rid of sda6.
The harder one is if LM 18.2 is on sda6 and you want to get rid of sda1.

In all cases, backup your data beforehand.

Easy case:
- boot on a live USB and open gparted
- select sda6 Partition > delete > apply
you have deleted LM 17. We are now going to grow sda1 and relocate the swap on a primary partition
- select sda5 Partition > swapoff > apply , then Partition > delete > apply
- select sda1 Partition > Resize/Move, grow it as you wish, just leave 4097MiB free fro swap, Apply
- select the remaining free space, Partition > New , create as primary partition, file system: linux-swap, make it 4096MiB (=4GB), Apply
- select the swap partition you just created. Partition > Information, see the field "UUID" it's a sequence of 36 characters, copy it somewhere (e.g. by selecting it and click-pasting it in a text editor)
- quit gparted, open the file manager, mount sda1 which should be visible as a device in the left column
- open the folder "etc" as root, open the file "fstab" with a text editor (still as root), find the line looking like this:

Code: Select all

# Swap
UUID=blabla  none  swap  defaults  0  0
and correct the uuid by putting the new value found two steps above
- save, close the text editor, close the root window of the file manager, unmount sda1, shutdown, unplug the live USB
- boot to LM 18.2 and update grub

Code: Select all

sudo update-grub
- you're done

Harder case:
as JerryF, I dont know if it's easy to move and resize an extended partition. Also I'm not sure if deleting sda1 is a good move, since it's the partition which has the boot flag and thus probably all the bootloading code. Deleting it directly runs the risk of making the system not booting anymore.
So I would wait for someone with more experience
Mute Ant

Re: How to combine partitions

Post by Mute Ant »

Join the 'Four Partitions or Fewer' queue. When it starts, the gdisk command will assume you want GPT and convert that drive to GPT. That will discard the 'extended' status and make them all real. Still in gdisk, convert the drive back to MBR and write the changes. You'll end up with three 'real' partitions and gparted can handle that.
Locked

Return to “Installation & Boot”