2

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?

1
  • Do you need to have /root on a separate partition, or would it be enough to simply copy the contents somewhere else and set up a symbolic link? (Disclaimer: I've never tried this, but it should work.) Nov 30, 2010 at 17:31

3 Answers 3

4

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

4
  • I have tried this and all seems to be fine so far. Thanks shellholic. Nov 30, 2010 at 18:34
  • 1
    You're welcome. But remember moving /root is a bad practice. Perhaps you could change a bit and make /home/bigrootfiles and mount/link it to some directory inside /root. If your "big files" are for some service. The best practice on Debian is to put them in /var/lib/somename
    – shellholic
    Nov 30, 2010 at 18:40
  • 1
    I see. Ultimately root login should not be used IMO. I guess I still might forgo moving /root entirely since it is not really very good to do. I just need to setup some new sudoer users with directories on the right partition and setup keyed authentication for better security. That would be the best solution I think. Nov 30, 2010 at 18:42
  • Perhaps make a new question describing the purpose of your case and you could come with great answers.
    – shellholic
    Nov 30, 2010 at 18:45
1

Never tried it, but you shouldn't have a problem with:
cd / to make sure you're not in the directory to be moved
mv /root /home/root
ln -s /home/root /root symlink it back to the original location.

0
  • Boot from any available Linux LiveCD
  • mount /dev/sda1 and /dev/sda9
  • move /root content to /home
  • edit /etc/fstab to reflect changes
2
  • booting from a live cd is unfortunately not an option for a remote server, which this is the case here. Nov 30, 2010 at 17:54
  • I think that worked in the past - if you do update-grub and grub-install at the end. However, with debian 10 grub sends me back to have my old partition as the root.
    – user855443
    Jun 11, 2020 at 22:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .