Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have a separate / and /home partition. Both have the same filesystem (ext4.)
How can I merge them? (What is the easiest way to merge them?)

share|improve this question
1  
I only know about using GParted and a live CD. Resize my /home, and then expand /. Move the /home files into the /, and finally delete the /home and expand /. –  Shiki Mar 29 '12 at 11:48
1  
I would say copy/backup your entire /home to an external drive, reinstall Ubuntu with a single partition, then copy your home back in. –  Marius Mar 29 '12 at 11:54
    
@Marius, it turns out, what I wrote works perfectly. (Which is what htorque said in his answer.) So I'll accept his. :) –  Shiki Mar 29 '12 at 12:33

2 Answers 2

up vote 5 down vote accepted

I don't think there's an easier way. You need to copy the data from one partition to the other. You need to delete the old home partition and resize the root partition. That cannot be done on a running system, so a live CD seems like as good as it gets.

  • Boot the live CD.
  • Mount the root partition to /mnt/root.
  • Mount the home partition to /mnt/oldhome.
  • Copy the data using rsync:

    sudo rsync -avz --hard-links --numeric-ids /mnt/oldhome/ /mnt/root/home
    
  • Open /mnt/root/etc/fstab and delete the entry for your home partition.

  • Unmount the root and home partition and reboot the system. If everything works as expected you can reboot again into the live system and then:
  • Open Gparted.
  • Delete the old home partition, resize the root partition.

That should be it.

share|improve this answer
1  
There are a few improvements which can be made to that rsync command. First of all you will want a slash at the end of the from path, or you will end up with an oldhome, within the homefolder. You might also want to add --hard-links, in case you have any of those under /home. To be on the safe side --numer-ids won't hurt either, depending on what is in /etc/{passwd,group} on the Live CD. –  andol Mar 29 '12 at 13:42
    
Also, do you really expect much benefit from compression when doing a local rsync? –  andol Mar 29 '12 at 13:45
    
Thanks. I added those to the above mentioned rsync call. –  qbi Mar 29 '12 at 13:46
    
@andol: Thanks, I was too sloppy with my answer. As for local compression: yes, I've seen a bit of a performance increase, so as long there's no performance hit, I tend to enable compression. –  htorque Mar 29 '12 at 14:34

I dont know about the easiest or the best approach but here is how I would do it. I would just create folder in / and then copy all data from /home to it. Then I will reboot my system using live cd and delete the partition for /home and rename the folder that I created in / to home and then delete entry for /home in fstab. And the last step would be to resize my root partition to consume empty space created by deleting partition for /home.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.