[solved] About "growing" and "merging" patitions

Quick to answer questions about finding your way around Linux Mint as a new user.
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions use the other forums in the support section.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
ivan_rookie

[solved] About "growing" and "merging" patitions

Post by ivan_rookie »

Hi, so few weeks ago I finally deleted all my Windows system partitions and I installed LinuxMint, no dual-boot any more.
I have a 500GB SATA drive divided into two partitions: a 50GB one (my ex-Windows "system" partition where I installed Mint) and a 450GB one (my ex-Windows "storage" partition):

Image

I also have an old 40GB ATA drive I assigned as my /urs/local because back then I read that it's good to have your /usr/local on a separate drive (???).

Image

So, my questions are:
  • Can I "merge" my sda1 and sda5 partitions into a single partition so I can have all my 500GB for my LinuxMint without the need of mounting, etc.?
  • Can I move my /usr/local to my main hard drive so I can remove this old ATA drive from my machine?
  • Why is it "good" to have my /usr/local on a separate drive?
I have GParted and Storage Device Manager installed, but I can't seem to find a way how to manage these tasks.
Thanks in advance and excuse my poor English, I hope you understand.

P.S. Oh, and I would really love to know how can I make a complete image of my system (a sort of backup, I don't know how you people call it) so if something f**ks up I can just restore my whole system - boot, settings, projects, personal files, etc. Is it easy to do? Will CloneZilla do the job? And, after that, how easy is to "restore" my system?
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
germanix

Re: About "growing" and "merging" patitions, moving /usr/loc

Post by germanix »

Allow me to tell you what I would do if this was my system.
First I would not merge the the sda1 and the sda5 into one partition. It is always good to have a separate /home partition for your "Data". I would however change the file system of sda1 from nfts to ext4 and then mount it as /home. (after this you would not have to mount it every time you wish to get to your files, it is then automatically mounted) You would however need to backup your files on that partition beforehand to make sure you do not lose any files in the process.
You can move your /usr/local to /home.
To have /usr/local on a separate partition is not necessary.
I always backup my /home partition but have never bothered with a complete image. I do not see the need for that. When /home is on its own partition I can quickly install the OS if need be and all my settings are in /home, so why bother. I use the backup program in Mint and works fine for me. I think clonezilla will work but have never tried it.
seeley

Re: About "growing" and "merging" patitions, moving /usr/loc

Post by seeley »

Hi!
Only one answer: sda1 + sda 5 -> sdaX?
There are different file systems, so you have to save data of one partition, delete this partition and resize (grow) the other one.
What about sda2?
Could you please post the output of Terminal

Code: Select all

sudo parted -l print
l like list
and

Code: Select all

sudo fdisk -l
seeley
ivan_rookie

Re: About "growing" and "merging" patitions, moving /usr/loc

Post by ivan_rookie »

germanix wrote:...
Thanks so much for your reply, I understand the idea now. I already formatted sda1 to ext4. I don't really have any of my files in /home (I moved them to my external drive) so I don't have anything to backup (or do I?). Could you just tell me in detail how to move my /home and /usr/local to it? Sorry, I'm a real beginner :/
seeley wrote:...
Thanks for your reply, but I decided to take germanix's approach. Please help with that if you like ^
germanix

Re: About "growing" and "merging" patitions, moving /usr/loc

Post by germanix »

OK, I will try to help you as much as I can but whilst I type up what I want to say please go to this link and read through it. This will help you to understand better and maybe afterwards you wont need any help or much less.
http://www.howtogeek.com/howto/35676/ho ... -linux-pc/
Seeley, please feel free to help with, I have never claimed to be an expert and I would appreciate if you will at least control what I say as I would not like to give false advice.
germanix

Re: About "growing" and "merging" patitions, moving /usr/loc

Post by germanix »

Ok. There are simple ways to do things and some not so simple.
Again if it was me, and as you have already indicated you do not have any real backup to do, I would do a new install, choosing to partition manually during the install and basically follow the advice of the link that I gave you. This is the simple way and you can hardly do anything wrong.
Then there is this way. You do not do a new install but now have to use the command line and the chances of not understanding or making mistakes are increased. (but you do learn something about the command line and if all fails then you just abort and do a new install anyway - ha ha)
So if you want to be brave then do this:

Creating a new partition
Setting up /home on a separate partition is beneficial because your settings, files, and desktop will be maintained if you upgrade, (re)install Ubuntu or another distro. This works because /home has a sub-folder for each user's settings and files which contain all the data & settings of that user. Also, fresh installs for linux typically like to wipe whatever partition they are being installed to so either the data & settings need to be backed-up elsewhere or else avoid the fuss each time by having /home on a different partition.
Find the uuid of the Partition
The uuid (Universally Unique Identifier) reference for all partitions can be found by opening a command-line to type the following: (copy and paste so you do not make mistakes when typing)
sudo blkid

Now you just need to take note (copy&paste into a text-file) the uuid of the partition that you have set-up ready to be the new /home partition.

Setup Fstab
Your fstab is a file used to tell Ubuntu what partitions to mount at boot. The following commands will duplicate your current fstab, append the year-month-day to the end of the file name, compare the two files and open the original for editing.
1. Duplicate your fstab file:
sudo cp /etc/fstab /etc/fstab.$(date +%Y-%m-%d)

2. Compare the two files to confirm the backup matches the original:
cmp /etc/fstab /etc/fstab.$(date +%Y-%m-%d)

3. Open the original fstab in a text editor:
gksu gedit /etc/fstab
and add these lines into it
# (identifier) (location, eg sda5) (format, eg ext3 or ext4) (some settings)
UUID=???????? /media/home ext4 nodev,nosuid 0 2
and replace the "????????" with the UUID number of the intended /home partition.
4. Save and Close the file, and then restart your machine. It should now auto-mount the new partition as /media/home. We will edit the fstab again later so this arrangement of the partition is only temporary.
To ensure your partition is mounted, mount all file systems declared in fstab with:
sudo mount -a

Copy /home to the New Partition
Next we will copy all files, directories and sub-directories from your current /home folder into the new partition:

sudo rsync -axS --exclude='/*/.gvfs' /home/. /media/home/.
The --exclude='/*/.gvfs' prevents rsync from complaining about not being able to copy .gvfs, but I believe it is optional. Even if rsync complains, it will copy everything else anyway. )

Check Copying Worked
You should now have two duplicate copies of all the data within your Home Folder; the original being located in /home and the new duplicate located in /media/home. You should confirm all files and folders copied over successfully. One way to do this is by using the diff command:

diff -r /home /media/home
The only difference that should exist is the excluded /.gvfs directory mentioned above.

Preparing fstab for the switch
We now need to modify the fstab again to point to the new partition and mount it as /home. So again on a command-line
gksu gedit /etc/fstab
and now edit the lines you added earlier, changing the "/media/home" part to simply say "/home" so that it looks like this:
# (identifier) (location, eg sda5) (format, eg ext3 or ext4) (some settings)
UUID=???????? /home ext3 nodev,nosuid 0 2
Then, press Save, close the file but don't reboot just yet.

Moving /home into /old_home
As long as you have not rebooted yet, you will still see 2 copies of your /home folder; the new one on the new partition (currently mounted as /media/home) and the old one still in the same partition it was always in (currently mounted as /home). We need to move the contents of the old home folder out of the way and create an empty "placeholder" folder to act as a mount point for our new partition.
Type the following string of commands in to do all this at once:
cd / && sudo mv /home /old_home && cd / && sudo mkdir -p /home

By default, when you open a terminal window it places you within your home folder. Typing cd / takes us to the root folder and out of home so we can then use the sudo mv command to essentially rename /home into /old_home, and finally create a new, empty /home placeholder.
With your fstab now edited to mount your new partition to our /home placeholder and the original /home now called /old_home, reboot your computer. Your new partition will mount as /home and everything should look exactly the same as it did before you started.

Deleting the old Home
You can delete your old home directory with:
cd /
sudo rm -r /old_home
Be careful with the above command as mistyping it could result in the deletion of other files and folders.
germanix

Re: About "growing" and "merging" patitions, moving /usr/loc

Post by germanix »

I need to add the following.
If you do a new install you can first delete this /usr/local file on the other Drive as by new installing a new such file will be created and you dont want a second such file to exist.
If you follow the other advice with the command line (fools rush in where angels fear to treat . ha ha) this moves your home but does not solve the problem with the /usr/local file. Frankly I am not so sure how to move this via the command line. . I would probably delete it and create it new under /home (or copy it over and then delete) but there is probably other ways and I am not so sure if my way works properly.
germanix

Re: About "growing" and "merging" patitions, moving /usr/loc

Post by germanix »

Hi ivan-rookie, I assume you are very busy trying out the solutions I have offered and I would be very interested to hear how it went. Unfortunately I will not be online for much longer. I do not know where you are from, but I am in Germany and the time here is nearly 22:00 hours. May not sound to late but I need to get up at 05:30 to drive 40 kilometers through the snow to my place of work and need my beauty sleep . (I am turning 60 next birthday so I seem to get tired more easily now days - ha ha).
I hope you get your system the way you want. I will be back tomorrow evening to see if you posted your progress. Should you need further help tonight there are many "experts" on the forum here who I am sure will help if needed.
Keep at it, I am sure you will succeed.
ivan_rookie

Re: About "growing" and "merging" patitions, moving /usr/loc

Post by ivan_rookie »

germanix wrote:Hi ivan-rookie, I assume you are very busy trying out the solutions I have offered and I would be very interested to hear how it went. Unfortunately I will not be online for much longer. I do not know where you are from, but I am in Germany and the time here is nearly 22:00 hours. May not sound to late but I need to get up at 05:30 to drive 40 kilometers through the snow to my place of work and need my beauty sleep . (I am turning 60 next birthday so I seem to get tired more easily now days - ha ha).
I hope you get your system the way you want. I will be back tomorrow evening to see if you posted your progress. Should you need further help tonight there are many "experts" on the forum here who I am sure will help if needed.
Keep at it, I am sure you will succeed.
Thank you so much for the detailed guide and happy birthday, Germanix!!! I bet this step-by-step instructions will help a lot of people. Also, thanks to all of you out there who cared to read my topic. I ran this console and tried this, and tried that, and I finally f**ked my system up so bad, that I felt I was the luckiest guy alive to have a recent (2 days old) mintbackup of my /home and my software list. So I just made a fresh install and now these 50GB are my / and the 450 - my /home. Then I restored my software and my /home and I was amazed to see that after a reboot even my desktop background was the same as before - I love Mint! So, today's lesson is: "If you're not sure about the things you may enter in Terminal, better do not enter anything at all."
germanix

Re: [solved] About "growing" and "merging" patitions

Post by germanix »

Hi Ivan-rookie, glad to hear you have sorted out your problem and that your system is up and running. You are so right about the Terminal. It is fast and very powerful but as you say, you have to know what you are doing. It takes an effort to learn but is worth it in the end. In the beginning though, when one is new to Linux it is better to keep things simple/stupid as much as possible. I started with linux in April 2008 (Ubuntu 8.04) and I am still learning everyday but having a lot of fun doing so. I love Mint and it is also my sole OS on my laptop which I use for work. I only update the main and security updates (not even the recommended updates) to ensure that my system runs smooth as I cannot afford to mess it up. I do however want to get a cheap second computer that I can mess with and to teach myself more of the command line. I found a great book that teaches this step by step.
Hang in there and keep visiting the forums. Here you can learn a lot.
(Edit) only just realized you are based in Berlin! I am in Hannover
Locked

Return to “Beginner Questions”