Is there a way to merge two linux partitions without losing data? [SOLVED]

Rafaelys

Member
Joined
Jan 29, 2020
Messages
47
Reaction score
24
Credits
464
Hi there! So, here's the thing:

I have a 1 Terabyte HDD on a Dell inspiron notebook (64 bit). I was using a dual boot with an old Ubuntu distro + Windows 7, which I kept for work reasons (I was obliged to use some windows software).

The partitioning was 605 GB for Ubuntu (sda 2) and 67 GB for Windows 7 (sda 4), dedicating 12 GB for Swap (sda 3) and leaving a free partition with 300 GB (unused).

All the important personal data was on Linux, and I stayed like that for a few years. Now that the job is finished, I intend to use linux again, leaving Windows only in case that I get new jobs.

However, I realized that the Ubuntu distro used was very outdated (I think it's 16.04 Xenial Xerus; actually it's discontinued and so old that apparently it didn't allow me to try an update directly from terminal, neither update java on browsers, etc). Edit: actually it was a 15.04 Ubuntu version.

So, I installed the elementary OS on the 300 gb partition (sda 1), the one which was not being used. Since it feels like a nice OS from my perspective, I have already moved all the personal files that were on the old Ubuntu partition to the new partition (Elementary), because I want to keep using it.

Now I would like to know if it is possible to merge the two linux partitions (the old in sda 2 with 600 gb on Ubuntu + the new one on sda 1 with 300 gb, on elementary), without losing the personal data that is already on the new partition (sda 1).

The idea is to continue using Elementary OS.

Just for an easy viewing, here's the partitions according to the terminal. Please note that I want to keep workin on sda1 (Elementary) while adding sda2 (old Ubuntu) on it; also keeping sda4 (Windows 7).

Partições em 29-01-2020.jpeg


P.s: As for sda3 and sda5 I sincerely don't know what to do with, but I'd accept suggestions / advises.

Thank you very much for any help!
 
Last edited:


G'day @Rafaelys and welcome to linux.org :)

I have to leave for my evening in Australia shortly but will be back tomorrow with ideas.

Don't do anything for the moment with /dev/sda3, it is your Extended Partition housing your Swap at /dev/sda5.

1. Do I take it that you installed the old Ubuntu before adding Windows 7, or did you simply clear a partition or two afterwards?

2. You may have the wrong version of Ubuntu in mind. 16.04 is still supported until April 2021. 14.04 however reached end of life April 2019.

Brazil or Portugal? Might help us with timing.

Cheers

Chris Turner
wizardfromoz
 
G'day @Rafaelys and welcome to linux.org :)

I have to leave for my evening in Australia shortly but will be back tomorrow with ideas.

Hi Chris, thanks! :)

Don't do anything for the moment with /dev/sda3, it is your Extended Partition housing your Swap at /dev/sda5.

That's easy, lol I'm actually too scared to touch anything and losing personal data

1. Do I take it that you installed the old Ubuntu before adding Windows 7, or did you simply clear a partition or two afterwards?

Now that you mentioned it, you reminded me that there was a break where I uninstalled Windows 7 completely, using just Ubuntu for a few weeks, after that I ended reinstalling Windows 7 again once I've founded that this Ubuntu version became outdated and/or was malfunctioning for some reason.

2. You may have the wrong version of Ubuntu in mind. 16.04 is still supported until April 2021. 14.04 however reached end of life April 2019.

Sorry I didn't checked this before posting, it's a 15.04 Ubuntu version. So if this version is still supported, probably it may be some other kind of error I could not address or understand at all.

Brazil or Portugal? Might help us with timing.

Brazil.
 
As a non-LTS release, 15.04 has a 9-month month support cycle and, as such, the support period is now nearing its end and Ubuntu 15.04 will reach end of life on Thursday, February 4th. At that time, Ubuntu Security Notices will no longer include information or updated packages for Ubuntu 15.04.Jan 14, 2016...!!!!
 
I think the question of what Ubuntu it is/was is possibly academic, Brian. :)

I have already moved all the personal files that were on the old Ubuntu partition to the new partition (Elementary), because I want to keep using it.

Rafael I am guessing you wish to add, not the Ubuntu partition on /dev/sda2 to your Elementary on /dev/sda1, but rather, recover the space Ubuntu takes up and use it for Elementary.

Is that so?

Wizard
 
Also, are you aware that support for Windows 7 finished 14 January?

Wiz
 
As you know, I am all for the academia portion of the topic.....(one more beer should do it...)
 
Rafael I am guessing you wish to add, not the Ubuntu partition on /dev/sda2 to your Elementary on /dev/sda1, but rather, recover the space Ubuntu takes up and use it for Elementary.

Is that so?
That's it! o_O lol I couldn't explain it better. Main concern here is that when I tried to figure how to merge two different partitions from GParted It seems that It requires to format them both, therefore losing data. I've searched some posts about it but I couldn't find any advice about this specific case.

Also, are you aware that support for Windows 7 finished 14 January?

Yes, I have been thinking about pirating windows 10 one of these days, even if I don't plan to use it.
 
Last edited:
As a non-LTS release, 15.04 has a 9-month month support cycle and, as such, the support period is now nearing its end and Ubuntu 15.04 will reach end of life on Thursday, February 4th. At that time, Ubuntu Security Notices will no longer include information or updated packages for Ubuntu 15.04.Jan 14, 2016...!!!!

LMAO that explains a lot
 
Yes, I have been thinking about pirating windows 10 one of these days, even if I don't plan to use it.

May be no need to pirate. See

https://www.digitaltrends.com/computing/how-to-get-windows-10-for-free/

If you follow that route, you will need to install Windows 10 (at the expense of both EOS and Ubuntu), and then install EOS again. To do that you would want to either have a backup of your personal data, or else install Timeshift on EOS and take a full snapshot, saved onto an external medium such as USB stick (large enough) or external drive.

Have a read of my Thread on Timeshift HERE - and ask any specific questions on it over there.

You have GParted on your Elementary. It will tell you the space consumed by your install, and as Timeshift creates a snapshot with no compression (1:1) that is the minimum amount of space you would need on your Timeshift partition.

Main concern here is that when I tried to figure how to merge two different partitions from GParted It seems that It requires to format them both, therefore losing data.

A valid concern, and I see you have had some experience with GParted, that is good.

Understandable thought, but not necessary. A two-part operation with GParted would sort it out.

You can use GParted from within your Elementary to delete the /dev/sda2 Ubuntu, this will be replaced by unallocated space. However you cannot manipulate your Elementary partition with GParted from within your Elementary session (safety feature) so you would have to use an external form of GParted.

If you still have the EOS install medium (usb stick or DVD) it has GParted on it and you could use that. Or else you can make up a GParted Live stick

https://gparted.org/liveusb.php

... and boot from it. You would then identify your /dev/sda1 and grow it to include all the unallocated space freed by deleting Ubuntu. For that matter, you could do both operations either from the GParted live stick or EOS install medium.

Have a bit of a think about it and come back to us with any questions or decisions before taking any action.

Saturday here in Oz, so to all and sundry

Enjoy your Linux, and

Avagudweegend

Wizard
 
May be no need to pirate. See

https://www.digitaltrends.com/computing/how-to-get-windows-10-for-free/

If you follow that route, you will need to install Windows 10 (at the expense of both EOS and Ubuntu), and then install EOS again. To do that you would want to either have a backup of your personal data, or else install Timeshift on EOS and take a full snapshot, saved onto an external medium such as USB stick (large enough) or external drive.

Have a read of my Thread on Timeshift HERE - and ask any specific questions on it over there.

You have GParted on your Elementary. It will tell you the space consumed by your install, and as Timeshift creates a snapshot with no compression (1:1) that is the minimum amount of space you would need on your Timeshift partition.
Thank you so much for all these tips; including pointing out the possibility of installing what could be the first original copy of Windows in my life, lol

I found the Timeshift functionality interesting and would like to have the knowledge to use it, but I don't think I would have the time and resources at the moment to dedicate myself to this, mainly due to the size of the media to make the backup. I even thought about migrating personal data from EOS to Windows 7 and upgrading to Windows 10 if it were not at risk, but that would also seem too much. If there is another possibility I prefer to save it for later reading and understanding

You can use GParted from within your Elementary to delete the /dev/sda2 Ubuntu, this will be replaced by unallocated space. However you cannot manipulate your Elementary partition with GParted from within your Elementary session (safety feature) so you would have to use an external form of GParted.

If you still have the EOS install medium (usb stick or DVD) it has GParted on it and you could use that. Or else you can make up a GParted Live stick

https://gparted.org/liveusb.php

... and boot from it. You would then identify your /dev/sda1 and grow it to include all the unallocated space freed by deleting Ubuntu. For that matter, you could do both operations either from the GParted live stick or EOS install medium.

Have a bit of a think about it and come back to us with any questions or decisions before taking any action.

So if I'm getting this right, If I delete sda2 now with GParted on EOS session, restart my computer and try to access GParted again from an external source (from my bootable EOS from usb for example), it will allow me to just add all free space sda2 left to sda1, without formating/losing personal data already saved on sda1.

Maybe I'm just rewriting your own words, but that's the fear of doing something wrong
 
Last edited:
1. Let me check this - with Windows and 2 Linux onboard, you have a Grub Menu, is that so?

If so, let me know the content of the lines in the Menu.

2. GNOME Screenshot (aka Screenshot) is likely in your Menu. Can you open GParted to show us the state of the partitions, and either attach it up to us, or follow my video here (sound is crap) for Posting Images here?

https://linux.org/threads/posting-screenshots-at-this-site-read-this-for-easy-way.21722/

...(from my bootable EOS from usb for example), it will allow me to just add all free space sda2 left to sda1, without formating/losing personal data already saved on sda1.

Basically, yes. Hold on to that USB stick, they are valuable in that regard. :)

...possibility of installing what could be the first original copy of Windows in my life, lol

At a previous Forum I was at I made friends with a fellow Jaime from LIma, Peru - he was in the same category ;)

Cheers

Wizard
 
it will allow me to just add all free space sda2 left to sda1, without formating/losing personal data already saved on sda1.
There is ALWAYS a risk, sometimes smaller, sometimes greater, of losing data.
Always, always, always make a backup copy of any important data which you do not want to risk losing, whichever backup method you choose. A simple drag and drop copy will work too.
 
1. Let me check this - with Windows and 2 Linux onboard, you have a Grub Menu, is that so?

If so, let me know the content of the lines in the Menu.

On boot screen there are five options:

*elementary
Advanced options for elementary
Ubuntu 15.04 (in /dev/sda2)
Advanced options for Ubuntu 15.04 (in /dev/sda2)
Windows 7 (in /dev/sda4)

2. GNOME Screenshot (aka Screenshot) is likely in your Menu. Can you open GParted to show us the state of the partitions, and either attach it up to us, or follow my video here (sound is crap) for Posting Images here?


GParted .jpeg
 
There is ALWAYS a risk, sometimes smaller, sometimes greater, of losing data.
Always, always, always make a backup copy of any important data which you do not want to risk losing, whichever backup method you choose. A simple drag and drop copy will work too.

Thanks for the warning. I must make a copy of the most important files then.
 
Thanks, Rafael, for providing that information - it places you in an ideal position to use that course of action I proposed :)

I would advise taking this in two (2) stages, confirming in between that everything is working OK.

First stage would be to delete the Ubuntu partition, to redeem that 600 Gig as, initially, unallocated space - não alocada

Second stage would be to resize the /dev/sda1 partition to account for that extra 600 GB.

Your data should not be affected, but what friend Vrai has said is sensible.

STAGE 1
Preparation - first check in Ubuntu's Home folder that there are no documents, pictures, videos or downloads that you wish to keep - if so, copy them to Elementary.

Then

1. In Elementary, open GParted. If it looks as your screenshot above, we are good to go. If there is one of those small icons of a key between partição and sistema, on the line that shows /dev/sda2 Ubuntu, then that means the partition is mounted, and we will have to unmount it first, by right-clicking and choosing unmount.

2. If that is all good, click the line with /dev/sda2 on it and it will highlight.

3. Right-click it and choose Delete and OK it. At the bottom left of the window pane will appear "1 operação pendentes". If you see that,

4. Go to top of window, and underneath Help will be an icon of a tick or check mark, perhaps green - running your mouse over it will generate a Smart Tip "Apply" or "Apply All Operations". Click that.

At the end of this, your /dev/sda2 Ubuntu should be deleted.

5. Exit GParted, and open Terminal

6. Type in and enter (you will be prompted for your password)

Code:
sudo update-grub

When that is completed, type exit to exit Terminal.

7. Reboot your computer.

If the above has gone to plan, you should have a revised Grub Menu with just Elementary and Windows on it.

8. Enter Elementary OS and see that all is safe with your data.

Report back here with outcomes or problems, and if all is good we'll go to Stage 2 and get that empty space back for you.

Cheers

Wizard
 
Seems ok untill now. Meanwhile I`m doing backup just in case

GParted.jpeg



Edit: now we`re here, is there any changes I should make on Swap partition? I searched about it and it seems that the EOS swap partition size requirement (for any sistem with above 1 GB RAM) is calculate by equal RAM size + 2 GB (in this case 6 + 2 = 8 GB). Back then when I installed 15.04 Ubuntu the recommendation was 2x RAM. But actually I`m assuming it won`t be bad to leave as it is.
 
Last edited:
just in case

Always look after Justin (Justin Case :), play on words) and he'll look after you ;)

That's looking perfect, Rafael - I'll swing over to EOS a little later in my day and deliver Stage 2.

Cheers

Wiz

EDIT - added BTW

BTW - I haven't overlooked your question on Swap, I'll come back to it after Stage 2 is a success - it does not impact on Stage 2. Wiz
 
Last edited:
So Stage 2 looks like this, and bear in mind that we are doing this from your Elementary Live burned USB stick, not from EOS itself.


e0evrV5.png


SCREENSHOT 1 - WIZARD'S SOLID STATE DRIVE

My SSD is the easiest to illustrate, as it is the smallest and least populated of my drives.

We'll imagine that I want to grow Robolinux on /dev/sdc11 to use that unallocated 17.97 GiB.


iqRFkf6.png


SCREENSHOT 2 - choosing the operation

Right-click the highlighted entry (/dev/sda1 for you) and choose

Resize/Move

A small window will appear

6OICnxN.png


SCREENSHOT 3 - CHOOSE YOUR RESIZING FIGURES

The minimum size of 8350 MiB is the space consumed by my Robolinux filesystem (yellow) - obviously I could not reduce or shrink to below that figure.

The maximum size (in my case 38884 MiB) is the sum of my 20 GiB Robolinux partition, plus the 17.97 GiB (18404 MiB) of my unallocated space.

In your case, your 2nd and 3rd fields should show

247.92 x 1024 = 253870

and

605.36 x 1024 = 619888

for a maximum size of

873759 MB (or close to)

At this point you can either type in the relevant figures, or you can drag a handle with your mouse.

Typing:

The first field "Free Space Preceding" is usually 0 (zero) in UEFI computers, may be 1 (one) in MBR computers such as yours. Does not matter.

In Field 2, replace that figure currently allocated to Elementary with the maximum amount figure.

Then press Tab and watch the figure in the 3rd field switch to 0 (zero).

Proceed.

Dragging with the mouse:

With the graphical size at the top of the window pane, there is an arrow at left and an arrow at right. You can drag the arrow at right as far as possible to the right and watch the figures change, then drop it.

Proceed.

(The Align to: MB option - leave as is, another option for Cylinders is obsolete).

Once you have done that to your satisfaction,

Press the Resize/Move button. That will bring you back to our main screen.


bKuc81H.png


SCREENSHOT 4 - OPERATION SUMMARY SCREEN

You can see that you are going to grow the partition from Figure 1 to Figure 2, also at the bottom that there is one (1) operation pending.

If you are not happy with that - next to my green checkmark is a curved yellow arrow, I can click that to cancel out.

If you are happy, click the green checkmark and apply all operations, and follow any prompts to completion.

Once that is complete, you should now have a very large /dev/sda1 for your EOS.

You know the drill - report back here with outcomes or problems. :)

Cheers

Wiz
 


Top