LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 03-26-2015, 02:32 PM   #1
JockVSJock
Senior Member
 
Registered: Jan 2004
Location: SATX
Distribution: RHEL/CentOS
Posts: 1,211
Blog Entries: 4

Rep: Reputation: 131Reputation: 131
Question 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?

thanks
 
Old 03-26-2015, 03:13 PM   #2
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
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.
 
Old 03-26-2015, 03:48 PM   #3
maples
Member
 
Registered: Oct 2013
Location: IN, USA
Distribution: Arch, Debian Jessie
Posts: 813

Rep: Reputation: 264Reputation: 264Reputation: 264
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?
 
Old 03-26-2015, 04:03 PM   #4
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
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.
 
1 members found this post helpful.
Old 03-26-2015, 04:11 PM   #5
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Blue Ridge Mountain
Distribution: Linux Mint 17, Debian 8
Posts: 7,860

Rep: Reputation: 311Reputation: 311Reputation: 311Reputation: 311
Quote:
Originally Posted by maples View Post
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 View Post
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 View Post
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.


------------------------
Steve Stites

Last edited by jailbait; 03-26-2015 at 04:14 PM.
 
Old 03-26-2015, 04:37 PM   #6
JockVSJock
Senior Member
 
Registered: Jan 2004
Location: SATX
Distribution: RHEL/CentOS
Posts: 1,211
Blog Entries: 4

Original Poster
Rep: Reputation: 131Reputation: 131
Quote:
Originally Posted by T3RM1NVT0R View Post
It will be good to go with LVM so that you can expand them whenever required.
Still wrapping my brain around LVM.

Would it be best to put each of those separate partitions under one Volume Group or multiple Volume Groups?
 
Old 03-26-2015, 04:41 PM   #7
JockVSJock
Senior Member
 
Registered: Jan 2004
Location: SATX
Distribution: RHEL/CentOS
Posts: 1,211
Blog Entries: 4

Original Poster
Rep: Reputation: 131Reputation: 131
Quote:
Originally Posted by jailbait View Post

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.
 
Old 03-26-2015, 05:08 PM   #8
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
Quote:
Still wrapping my brain around LVM.

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.
 
Old 03-26-2015, 05:23 PM   #9
JeremyBoden
Senior Member
 
Registered: Nov 2011
Distribution: Debian
Posts: 1,144

Rep: Reputation: 235Reputation: 235Reputation: 235
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.
 
Old 03-26-2015, 06:02 PM   #10
JockVSJock
Senior Member
 
Registered: Jan 2004
Location: SATX
Distribution: RHEL/CentOS
Posts: 1,211
Blog Entries: 4

Original Poster
Rep: Reputation: 131Reputation: 131
Quote:
Originally Posted by T3RM1NVT0R View Post
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.

I am using RHEL 5 and RHEL 6.
 
Old 03-26-2015, 06:11 PM   #11
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
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.
 
Old 03-26-2015, 07:52 PM   #12
maples
Member
 
Registered: Oct 2013
Location: IN, USA
Distribution: Arch, Debian Jessie
Posts: 813

Rep: Reputation: 264Reputation: 264Reputation: 264
Quote:
Originally Posted by jailbait View Post
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:
Code:
# <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
Is that right?
 
Old 03-26-2015, 10:03 PM   #13
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
@ maples

Code:
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.
 
Old 03-27-2015, 07:35 AM   #14
maples
Member
 
Registered: Oct 2013
Location: IN, USA
Distribution: Arch, Debian Jessie
Posts: 813

Rep: Reputation: 264Reputation: 264Reputation: 264
OK. So the order of how it's mounted is determined by the order that you put them in fstab? And in that example, the /tmp would get mounted last?
 
  


Reply

Tags
/var, linux, partition


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
fsck.ext3 unable to resolve 'label=var' 1.6TB var techux Linux - General 3 03-31-2013 09:02 PM
/var/log/wtmp vs. /var/run/utmp masenko703 Linux - Newbie 4 10-05-2012 03:41 AM
/var/cache/yum and /var/lib/rpm getting BIG. How to safely pare down? SharpyWarpy Linux - General 3 02-29-2012 01:17 AM
my.cnf on debian squeeze. var names don't match, var values missing. sneakyimp Linux - Server 1 07-03-2011 01:59 AM
pam does not like my owner, group and date for /var/ftp. especially /var manis2008 Linux - Software 1 02-08-2008 07:36 AM


All times are GMT -5. The time now is 01:58 PM.

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