Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 11-23-2005, 11:39 AM   #1
Registered: Jan 2004
Posts: 307

Rep: Reputation: 33
moving /home /root & /var to new partition

I have only 4.2G on my / partition (hda8) & am constantly running out of space, however I have a now empty 3.0G partition (hda5) so I want to move /home, /root and /var to hda5.

I have copied /home/crashedagain (the only user) to hda5 & mounted it via fstab as /home. (fstab entry: /dev/hda5 /home ext3 auto,users,exec 0 0). This seems to be OK & is now working.

Now I want to move /root and /var. These will now become /home/root and /home/var since the partition is mounted as /home.

Since the system expects to find /var not /home/var, can I just replace /var with a symlink to /home/var.

I have read that some applications will not follow symlinks.

Will there be problems with using a symlink here?

If so, what is the alternative?
Old 11-23-2005, 11:47 AM   #2
Senior Member
Registered: Mar 2004
Location: Munich
Distribution: SuSE, Ubuntu
Posts: 3,513

Rep: Reputation: 58
You need to create a separate partition for every out-sourced part of the root-tree. Although I have never tried your symlink solution, I can't imagine that this will work without trouble.
Old 11-23-2005, 04:40 PM   #3
Registered: Apr 2004
Location: Europe
Distribution: Debian, Slackware
Posts: 505

Rep: Reputation: 46
How big is your var? Is there really a point in moving it at all? I think mount also has an option to move part of the filesystem to another place (--bind option?), see man mount for this.

Last edited by alienDog; 11-23-2005 at 04:44 PM.
Old 11-23-2005, 04:46 PM   #4
Registered: Jan 2004
Posts: 307

Original Poster
Rep: Reputation: 33
It's not really that big (about 400M at the moment) but sometimes it needs a lot of space, for instance apt-get upgrade (Debian system) can download as much as 500 or 600M of .deb files. These can be cleaned up once the upgrade is done but it needs the space with it is doing the upgrade.
Old 11-23-2005, 05:38 PM   #5
Registered: Apr 2004
Location: Europe
Distribution: Debian, Slackware
Posts: 505

Rep: Reputation: 46
400 MB seems a lot to me, mine is 17 MB I think you could make it happen with mount --bind so that you don't have to start partitioning hda5. Partitioning would seem a bin inconvenient.
Old 11-23-2005, 09:50 PM   #6
Registered: Jan 2004
Posts: 307

Original Poster
Rep: Reputation: 33
crashedagain@desktop:~$ sudo du -s /var
391996 /var

most of it is in /var/lib & /var/log:
crashedagain@desktop:~$ sudo du -s /var/*
12 /var/autofs
3848 /var/backups
43412 /var/cache
162572 /var/lib
4 /var/local
12 /var/lock
172136 /var/log
48 /var/mail
4 /var/opt
252 /var/run
4328 /var/spool
5348 /var/tmp
16 /var/www

most of /var/lib is apt & dpkg but there are a couple of really big files in /var/log:
crashedagain@desktop:~$ ls -ls /var/log | sort -n
3436 -rw-r----- 1 root adm 3514197 Oct 20 06:33 syslog.2.gz
6556 -rw-r----- 1 root adm 6698794 Oct 20 06:33 messages.0
60720 -rw-r----- 1 root adm 62108905 Oct 20 04:54 debug.0
68892 -rw-r----- 1 root adm 70467752 Oct 20 06:25 kern.log.0

If I can get rid of these (and set the system up to keep them from growing...130Meg in log files is ridiculous!) then var will be small enough it won't be worth moving. I think logrotate is what cleans them up but I haven't figured out how it works yet.
Old 11-24-2005, 09:49 AM   #7
Registered: Apr 2004
Location: Europe
Distribution: Debian, Slackware
Posts: 505

Rep: Reputation: 46
It has it's own configfile in /etc/ called logrotate.conf that defines how often the logs should be rotated and for how long the old logfiles should be kept. I have:

rotate 1
/var/log/wtmp {
    create 0664 root utmp
    rotate 1
It will rotate the logs weekly, keep 1 week worth of old logfiles, create new (empty) logfiles upon rotation and compress the old logs. In addition there might be some additional settings for certain logfiles in /etc/logrotate.d. They mainly deal with what happens when a certain logfile gets rotated (a bit like the part for wtmp above). Probably all you need to touch is /etc/logrotate.conf. Also make sure that logrotate gets run by cron (i.e. your machine is up at the time of the cronjob).


Oh, and check the logging settings of your firewall, it can quite quickly bloat the logs, could be the reason for the size of your kern logfile. What goes into debug in your system?

Last edited by alienDog; 11-24-2005 at 09:54 AM.
Old 11-24-2005, 10:15 AM   #8
Registered: Jan 2004
Posts: 307

Original Poster
Rep: Reputation: 33
That's pretty much what mine looks like too except I had rotate 5 so I had 5 .gz compressed old files for most logs instead of 1.
But the 60+ Meg files debug.0 and kern.log.0 were dated Oct 20 so why weren't they rotated? Does rotate work on ALL log files in /var/log or is it necessary to specify which ones get rotated? The manpage doesn't say.
I manually removed them & recreated empty files so as to avoid something looking for them & giving an error.
Drive space is probably OK now:
Filesystem Size Used Avail Use% Mounted on
/dev/hda8 4.2G 2.6G 1.4G 67% /
/dev/hda1 4.6G 3.0G 1.6G 66% /mnt/hda1
/dev/hda5 3.0G 791M 2.1G 28% /home
/dev/hda7 26G 8.9G 17G 36% /mnt/hda7
/dev/hdb1 25G 301M 23G 2% /mnt/hdb1
/dev/hdb2 50G 20G 28G 42% /mnt/hdb2

hda1 is windows, hda7 is vfat & hdb is a data drive. but with 1.6G free on hda8 I should be OK, Previously I had about 90% full on this drive.
Old 11-24-2005, 11:44 AM   #9
Senior Member
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,290

Rep: Reputation: 378Reputation: 378Reputation: 378Reputation: 378
You probably shouldn't move /root to a new partition. The reason /root is put on the root filesystem is so that if there's a boot problem and Linux is unable to mount any other partitions besides the root partition, then root can still get to all his files. If /root is on a separate partition, he'll still be able to log in in that case, but won't have any access to files in his home dir.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Moving VAR TMP HOME OPT to new partitions JWatson Linux - Newbie 2 01-03-2005 05:54 AM
Moving contents of /var to separate partition TexasDex Linux - Software 2 03-01-2004 09:30 PM
Moving /var to new partition burnpile Slackware 2 12-10-2003 01:33 PM
moving /home partition bhodi Linux - Newbie 2 11-22-2003 08:57 AM
Moving/using new /home partition concoran Linux - General 1 05-20-2002 10:32 PM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 07:42 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration