Merging two partitions

computerzoo

New Member
Joined
Aug 13, 2021
Messages
8
Reaction score
2
Credits
72
Hello there, I've gotten myself into a pickle and need some help.

My laptop used to have two partitions, both Linux, one for general use and one for work. I decided that I did not need to keep them separate and have deleted the second Linux set up to merge it with my main OS. The only issue is that I have no idea where to go now. Can anyone help me with this?
Here's a pick of how the partitioning looks.
1683741672827.png
 


osprey

Well-Known Member
Joined
Apr 15, 2022
Messages
920
Reaction score
863
Credits
8,749
There are several ways of doing this.

Use the GUI program Gparted to form a partition from the free space, write a filesystem to it. Then allocate a mount point for the new partition and write a configuration line in the /etc/fstab file to mount it at boot so it's immediately available for use on booting up.

Another route is to try and make the free space contiguous with Partition1 which involves moving the current Partition2 (looks like the EFI partition) and swap partition to the end of the disk. Gparted can do that. There's an example here: https://www.baeldung.com/linux/resize-partitions. This process is best accomplished from a live disk which can run Gparted on the unbooted, hence unmounted, installation.

Another alternative is to use LVM which would enable changing partition sizes quite flexibly. You would need to convert the existing root filesystem to a LVM partition type and with a few other adjustments then have flexibility in resizing all partitions. There's a learning curve to it. It may be overkill for a home system that only needs one change such as described in this situation, but it can accomplish the task. Perhaps have a look here to see what's involved as an initial step: https://www.system-rescue.org/lvm-guide-en/Moving-the-linux-rootfs-to-an-LVM-volume/.

There are numerous other means of achieving the task with various cli tools including fdisk, gdisk, mkefs, linux utilities and any text editor.

Bear in mind, when one chooses any means to accomplish tasks such as these, one needs to know what one is doing. Mistakes can ruin data, so before any actual processing, it's advisable to back up what one doesn't wish to lose.
 
Last edited:

Condobloke

Well-Known Member
Joined
Apr 30, 2017
Messages
6,649
Reaction score
5,545
Credits
43,119
If you like a more round about way......

Make a full image backup of your OS. Store it on an external drive. Make sure it can be restored.

Take a Timeshift snapshot and store it on an external hard drive

Make a bootable thumb drive of your current OS. Make sure it works by booting to it.

WIpe the drive completely...format it to ext4

Restore the Image you made to that entire drive

(The Timeshift snapshot and bootable usb stick are just in case of an emergency....in case something goes south with the backup you made)
 

Members online


Top