Have multiple partitions for /var along with a partition for /var itself useful?
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Have multiple partitions for /var along with a partition for /var itself useful?
I'm setting up a new Linux server and trying to get the best performance from it, along with if any directory fills up, then I won't have to worry about the whole OS.
I want to split up /var into various partitions, such as the following:
/var/cache
/var/log
/var/software_install
Will there be a problem with having these separate partitions and still having a separate partition for /var too?
Or should I plan on just a separate partition only for /var only?
Yes, it is a good idea to have separate partitions when you know that the data in those partitions will be quite dynamic. It is done mostly on web servers for logs and database servers. If you have similar requirement then you can go with what you have mentioned that is creating separate partitions for /var and then for the directories under /var . The only thing that you have to make sure that you do it at the beginning when the directory is empty. It will be good to go with LVM so that you can expand them whenever required.
I'm thinking about doing something similar. You say that it should be done only when /var is empty. Would it be enough to boot from a live medium, copy everything from the old /var to the new partition, remove the old /var, and edit fstab accordingly?
For partitions like /var or /home it is usually done at the time of deployment itself. However, incase it wasn't done at the time of deployment then you can do the following:
1. Make a new partition, format it with whatever filesystem you want to.
2. Make a new directory something like varnew.
3. Mount the newly created partition on /varnew
4. Boot using livecd.
5. Copy stuff from /var to /varnew make sure that you use switches to preserve permissions.
6. Once copied rename /var to /varold
7. Umount /varold
8. Create a directory /var (make sure that it has same permissions as that of /varold)
9. Umount /varnew
10. Mount the partition mounted on /varnew to /var
Keep the old partition which was mounted on /varold for a while to make sure that everything is working fine. Delete it after 2 weeks or so.
Edit: Make sure that you have latest backup of /var before going ahead with above steps. Whenever you are playing around with partitions you should always have the latest backup.
Last edited by T3RM1NVT0R; 03-26-2015 at 04:05 PM.
You say that it should be done only when /var is empty.
Yes, when you use a directory as a mount point you cannot access any of the old files and subdirectories in the mount point directory. You end up wasting hard drive space with inaccessible files.
Quote:
Originally Posted by maples
Would it be enough to boot from a live medium, copy everything from the old /var to the new partition, remove the old /var, and edit fstab accordingly?
You need an empty /var directory to use as a mount point. So remove everything in /var but leave the directory.
Quote:
Originally Posted by maples
I want to split up /var into various partitions, such as the following:
/var/cache
/var/log
/var/software_install
If /var is mounted on partition A and /var/cache is mounted on partition B then you have chained mount points.
If you have chained mount points then /var/cache has to be located on the /var partition and /var/cache should be empty when you make it into a mount point. Also if you have chained mount points then be sure to set up the pass number field correctly for each mount point in /etc/fstab. If you don't have the pass number field set correctly then Linux will try to mount the mount point directories in parallel which leads to intermittent failures depending on the timing of what order the mounts actually finish.
If you have chained mount points then /var/cache has to be located on the /var partition and /var/cache should be empty when you make it into a mount point. Also if you have chained mount points then be sure to set up the pass number field correctly for each mount point in /etc/fstab. If you don't have the pass number field set correctly then Linux will try to mount the mount point directories in parallel which leads to intermittent failures depending on the timing of what order the mounts actually finish.
------------------------
Steve Stites
If I'm doing this at install time, do I have to worry about chained mount points along with setting pass number fields?
Also I've never heard of chained mount points, so this is something else I need to research.
Would it be best to put each of those separate partitions under one Volume Group or multiple Volume Groups?
It will be a good idea to keep them under separate volume group. Keeping them in single volume group means those partitions will share PVs and if disk or partition which is part of that PV under the volume group fails will affect the other partitions if they share the extents from same PV.
So to make it simple have separate VGs which will inturn have separate PVs added to it and will not conflict with each other.
With LVM, provided you setup a fixed non-LVM /boot partition,
you can use a single volume group for both a / Logical volume and a /home volume.
Splitting / into / and several /var volumes is possible - but is going to be more complicated.
Bear in mind that LVM is not an auto-extending file system, although it is easy to extend volumes with just a couple of commands.
LVM works with fixed size volumes, which can be easily extended and less easily contracted.
It will be a good idea to keep them under separate volume group. Keeping them in single volume group means those partitions will share PVs and if disk or partition which is part of that PV under the volume group fails will affect the other partitions if they share the extents from same PV.
So to make it simple have separate VGs which will inturn have separate PVs added to it and will not conflict with each other.
I don't believe I have the option to create and assign the VG to those partitions during the install phase, at least I didn't see it during a dry run.
Yes you have that option during install. At the time of install using disk druid (utility which runs for creating partitions / LVMs during install) you can create PVs, VGs and LVs. It is there in RHEL 5 and RHEL 6 and now in RHEL 7.
If you have chained mount points then /var/cache has to be located on the /var partition and /var/cache should be empty when you make it into a mount point. Also if you have chained mount points then be sure to set up the pass number field correctly for each mount point in /etc/fstab. If you don't have the pass number field set correctly then Linux will try to mount the mount point directories in parallel which leads to intermittent failures depending on the timing of what order the mounts actually finish.
I've never messed with the "pass" part of fstab, so I just want to double-check that I've got it straight. It mounts them in the order specified in the "pass" field. So if I have, for example, 4 partitions, and I want them to be mounted on /, /var, /var/tmp, and /var/temp/example, along with tmpfs for /tmp, then my fstab would look like:
I've never messed with the "pass" part of fstab, so I just want to double-check that I've got it straight. It mounts them in the order specified in the "pass" field. So if I have, for example, 4 partitions, and I want them to be mounted on /, /var, /var/tmp, and /var/temp/example, along with tmpfs for /tmp, then my fstab would look like:
# <file system> <dir> <type> <options> <dump> <pass>
/dev/sda1 / ext4 (options) 0 1
/dev/sda2 /var ext4 (options) 0 2
/dev/sda3 /var/tmp ext4 (options) 0 3
/dev/sda4 /var/tmp/example ext4 (options) 0 4
tmpfs /tmp tmpfs (options) 0 2
Did you put the number which I have marked in bold and red? You can only have either 0 or 1 or 2, where 0 means fsck will not check filesystem for inconsistency, 1 is usually given to / and 2 for other filesystems.
Quote:
If you have chained mount points then /var/cache has to be located on the /var partition and /var/cache should be empty when you make it into a mount point. Also if you have chained mount points then be sure to set up the pass number field correctly for each mount point in /etc/fstab. If you don't have the pass number field set correctly then Linux will try to mount the mount point directories in parallel which leads to intermittent failures depending on the timing of what order the mounts actually finish.
As far as I am aware pass number has nothing to do with mounting mechanism, it is about filesystem check. If you are mounting the partition in sequential way you are good to go.
Last edited by T3RM1NVT0R; 03-26-2015 at 10:06 PM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.