Linux – How to move the /root directory on Debian

debianlinuxuser-management

I would like to move my root user's directory to a larger partition. Sometimes "he" runs out of space when performing tasks.

Here are my partitions:

host3:~# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda1               334460    320649         0 100% /
tmpfs                   514128         0    514128   0% /lib/init/rw
udev                     10240       720      9520   8% /dev
tmpfs                   514128         0    514128   0% /dev/shm
/dev/sda9            228978900   1534900 215812540   1% /home
/dev/sda8               381138     10305    351155   3% /tmp
/dev/sda5              4806904    956852   3605868  21% /usr
/dev/sda6              2885780   2281584    457608  84% /var

The root user's home directory is /root. I would like to relocate this, and any other user's home directories to a new location, perhaps on sda9. How do I go about this?

Best Answer

You should avoid symlinks, it can make nasty bugs to appear... one day. And very hard to debug.

Use mount --bind:

# as root
cp -a /root /home/
echo "" >> /etc/fstab
echo "/home/root /root none defaults,bind 0 0" >> /etc/fstab

# do it now
cd / ; mv /root /root.old; mkdir /root; mount -a

it will be made at every reboots which you should do now if you want to catch errors soon