PDA

View Full Version : Linux GURU Question About Moving /var directory



n2ize
09-25-2015, 03:54 PM
II could use a quick spot of advice here. On my current Linux system configuration the /var directory is on the root partition /. Unfortunately the root partition is kind of small and /var is growing in size. This is starting to make things get difficult, including doing system upgrades where lots of stuff is stored under /var.

Fortunately the drive is large and I have reasonably large partitions on it for /home , /usr, and a large partition for a /mnt/volume1 filesystem used for miscellaneous storage. Basically I want to move /var from the root partition to one of these other partitions.

On earlier versions of linux when I ran into a similar issue with /var I did the following...

1) Backed up /var
2) Moved the directory /var to a larger partition, say the home partition /home/var
3) Removed /var from the root partition and set a symlink /var on the root partition to the directory /home/var on the home partition.
4) Rebooted the system and viola' it worked without any problems from then on.

What I am wondering is if this a practical way to do it these days. Doing a search on this topic some say to make a separate partition just for /var (which means I would have do some partition resizing and edit fstab to change the mount point for /var). Others say to go about it more of less the way I described above asI have done it in the past.

I don't see why there should be any issue with moving /var to an existing partition since that partition is going to be mounted at boot time anyway.

Any Linux Guru's want to weigh in on this ??

KC2UGV
09-26-2015, 10:55 AM
For workstations, I rarely split up anything other than /boot. But, moving /var of onto it's own partition is what I do for production servers. But, I also have it in a volume group, and leave free pe's so I can grow it as needed (Or other file systems for that matter).

n6hcm
09-28-2015, 12:29 AM
the problem with moving the entire folder /var off the root file system is that there are some things that will write there before other partitions are mounted (therefore you will lose log entries).

instead of moving all of /var somewhere else, move the largest things and then soft link from /var/... to /newlocation/var/... (but only after you figure out what can be moved).

KC2UGV
09-28-2015, 07:01 PM
the problem with moving the entire folder /var off the root file system is that there are some things that will write there before other partitions are mounted (therefore you will lose log entries).

instead of moving all of /var somewhere else, move the largest things and then soft link from /var/... to /newlocation/var/... (but only after you figure out what can be moved).

Nothing should be writing to the filesystems until they are mounted. Filesystems get mounted almost immediately after the kernel is loaded, if init is properly configured (As it is in most distros).