Moving /home/osmc to another drive

I have a very small sd card (4GB) so I would like to move my home folder to the usb drive.
How to do it?

Move the folder and than to create a symbolic link?
Something like this:

mv /home/osmc /mnt/usb32
ln -s /home/osmc /mnt/usb32/osmc
chmod 755 /home/osmc

Is that enough?

You should ideally use /etc/fstab for this

Sam

I don’t want to use the whole disk for home so that is not an option.

Who said anything about the whole disk ?

Fstab can mount additional mount points. You could add a mount point for /home/osmc on the external disk.

It would be somewhat fiddly and tricky to migrate your home directory across though, as you would need to mount it to a temporary path, copy everything over (while mediacenter is shut down) then somehow empty your home directory and change the mount point so that on next boot it would mount as /home/osmc.

In fstab I am mounting device to the folder. In my case device is usb drive and folder is /home/osmc
If I do it in that way the whole usb disk will be mounted to the /home/osmc if I understand everything correctly.

Please do correct me if I am wrong.

Another solution came to my mind. :smile:

What would happen if I create a /mnt/usb32/home/osmc folder (it is on the usb drive), than rsync all files from /home/osmc to the /mnt/usb32/home/osmc and than in /etc/passwd file change the line:
osmc:x:1000:1000::/home/osmc:/bin/bash

to

osmc:x:1000:1000::/mnt/usb32/home/osmc:/bin/bash

Would this work?

Now I got it. I thought that in fstab we can mount only devices.
I never heard about bind mounts, but after reading a little bit about it (for example on How to use bind mounts in linux - Backdrift Backdrift) now I got it.

Thanks.

Bind mounts are for mounting a directory on one file system to another location on the same file system.

Make a symbolic link with ln -s