Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
    
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.) –  SmallClanger Nov 30 '10 at 17:31

3 Answers 3

up vote 1 down vote accepted

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

share|improve this answer
    
I have tried this and all seems to be fine so far. Thanks shellholic. –  nicholas.alipaz Nov 30 '10 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 '10 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. –  nicholas.alipaz Nov 30 '10 at 18:42
    
Perhaps make a new question describing the purpose of your case and you could come with great answers. –  shellholic Nov 30 '10 at 18:45

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.

share|improve this answer
  • Boot from any available Linux LiveCD
  • mount /dev/sda1 and /dev/sda9
  • move /root content to /home
  • edit /etc/fstab to reflect changes
share|improve this answer
    
booting from a live cd is unfortunately not an option for a remote server, which this is the case here. –  nicholas.alipaz Nov 30 '10 at 17:54

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.