Page 1 of 1

Moving /home partition

PostPosted: Dec 2nd, '15, 22:26
by lightblue
Hi amigos,

I have an SSD and an HDD,
I used to have my /home and swap partition on my HDD and my /root on SSD,
as Doktor mentioned
doktor5000 wrote:If I where you, put /, swap and a small /home on the SSD, and then add a symlink inside your /home to the HDD for folders where you need more space.
Otherwise the SSD benefits are wasted halfway.

It's better to move them on SSD and use a symlink,
I moved my swap to SSD, fixed fstab and ..., and finally it works just fine,

now I wanna move my /home and use a symlink,
How can i do so?

I found these two links useful, but I think there might be a better way to so so:
https://help.ubuntu.com/community/MoveMountpointHowto
https://help.ubuntu.com/community/Parti ... ome/Moving


thanks

Re: Moving /home partition

PostPosted: Dec 2nd, '15, 22:44
by doktor5000
Why do you want to use a symlink?

lightblue wrote:I found these two links useful, but I think there might be a better way to so so:
https://help.ubuntu.com/community/MoveMountpointHowto
https://help.ubuntu.com/community/Parti ... ome/Moving

The first link is only about changing mount points, not about transferring contents.
The second link is about moving the contents of /home to a separate partition. If I understood correctly, you currently have a separate /home partition, right?

Basically it's just a matter of creating a new partition and filesystem on top.
Then go to single-user mode via init 1 as root or by appending 1 to the kernel options at boot.
Mount your new partition somewhere ( e.g. to /mnt/newpartition ) and then copy the contents of /home to the new partition, via e.g.
Code: Select all
cp -a /home/* /mnt/newpartition/

or
Code: Select all
rsync -avzP /home/* /mnt/newpartition/


Get the UUID of your new partition via blkid or lsblk -f and adjust the UUID of /home to the one of the new partition in /etc/fstab.
Reboot and you should be done. You can then remove the old /home partition.

This is described via e.g.
http://unix.stackexchange.com/questions ... -partition
http://askubuntu.com/a/50539

Re: Moving /home partition

PostPosted: Dec 3rd, '15, 01:00
by jiml8
Why do you want to use a symlink?


Why not? That is how I have done it for many years on my workstation. It is just easier when I want to move things.

My /home is a directory on an encrypted partition (sdd5) and /home is a symlink (/home->/mnt/sdd5/home). It works very well.

As for moving stuff from an old /home partition to a new /home directory on some other partition, it's easy enough. Just be logged in as root, and have no human user (who has a home directory in /home) be logged in. Probably a good idea to drop to init 1 for this, just to make sure nothing is being used in /home.

Establish the directory home wherever you want it and copy everything from /home to /path/to/home. Once the copy is complete, umount /home, delete the /home mountpoint from /, remove the entry from fstab, and replace with ln -s /path/to/home home.

If you are unable to umount /home because something is using it, just remove the entry from fstab and reboot into init 1 in order to delete the mountpoint and create the symlink.

Because I choose to not encrypt my / partition (it is just a PITA if recovery is needed) I also symlink /var and /tmp to directories on other encrypted partitions in order to guard against information leaks.

Re: Moving /home partition

PostPosted: Dec 3rd, '15, 17:07
by lightblue
Hi Doctor and thanks for your reply,
I'm going t to do whatever you said, :)

Just 2 short questions,
Is that okay to have a home with xfs file system for Mageia? (Does it have any advantage over ext4?)
how can i share my /home with 2 distros?


Regards

Re: Moving /home partition

PostPosted: Dec 3rd, '15, 18:09
by lightblue
Hi jiml8 and thanks for your solution,

I'm not sure that I got all the steps :D,
but i'm gonna do it and try my best to make it work :)
As i think it's really handy

Re: Moving /home partition

PostPosted: Dec 3rd, '15, 21:10
by doktor5000
FWIW, basically jiml8 describe the same as I did, but more high-level. The only difference he does is using a symlink to another mountpoint instead of directly mounting it as /home,
as he has an encrypted partition where he probably has several folder including home, var and maybe more. If you simply want to move home to a new partition, I don't see the necessity for using a symlink.

Also you can use any filesystem you like. E.g. I'm using btrfs for /home and / . xfs has advantages with bigger files, you can use it if you think it works better for you.