You are not logged in.

#1 2022-08-18 20:39:38

jason88452
Member
Registered: 2022-08-18
Posts: 3

Separate /var partition

In the Arch Wiki, it is said that you can create a separate partition for /var directory to prevent root system from becoming full. I decided to make this partition, but I don't know if I should have this partition before or after my home directory. So I have two choices for the partition layout here:

/boot (300MiB)
/ (20GiB)
/home (900GiB)
/var (12GiB)

and

/boot (300MiB)
/ (20GiB)
/var (12GiB)
/home (900GiB)

Which option should I go with? The Arch Wiki doesn't mention anything related to how /var should fit into a partition layout. The only 'hint' to the order of the partitions is that the subsection /home is spoken about before /var. But I can't tell if that's an indication to a better partition order or just because /home is more common and relevant to partition separately than /var.

Also, another important detail in the Wiki is:

It is used, for example, for caching and logging, and hence frequently read or written.

I still don't understand what to make of "and hence frequently read or written."

I would appreciate any help, thank you!

Offline

#2 2022-08-18 21:07:12

mpan
Member
Registered: 2012-08-01
Posts: 1,207
Website

Re: Separate /var partition

It’s not important how you order you partitions. Do it as it’s convenient to you.

A long time ago⁽¹⁾ with slower HDDs it was beneficial to put data requiring high bandwidth towards the outer cylinders and data requiring low latency at random access towards the middle cylinders. The first one was due to higher data rates at the edge, the second due to lower average head travel distance. Nowadays this advice is outdated for practical purposes.⁽²⁾ No only HDDs are much faster, you are getting layers of abstraction and caching over any disk access. Not to mention SSDs are widespread now, having no such considerations.
____
⁽¹⁾ But not very long time ago. In the early days, before everything used ZBR, there was no difference.
⁽²⁾ Synthetic benchmarks may still show a slight improvement for heavy swap usage, but that’s of close to not relevance for real world scenarios. There may also be particular workloads that will benefit from it, but this is the “if you ask, you do not need it” territory.


Sometimes I seem a bit harsh — don’t get offended too easily!

Offline

#3 2022-08-18 21:19:50

WorMzy
Forum Moderator
From: Scotland
Registered: 2010-06-16
Posts: 11,855
Website

Re: Separate /var partition

As mpon says, it doesn't make any difference where you put it. But if you need to shrink the /home partition to make space, it's safer to just shrink it. If you shrink it and move it, you're much more likely to have something go wrong and end up losing data (but you have backups right?).

/var is mostly used for caches and logs, the system journal will dump it's logs to disk here unless you explicitly tell it not to, and pacman will store cached packages here (again, unless you tell it not to). Those are the biggest users of /var off the top of my head. Personally I don't see a need for a separate var partition, so long as you maintain good cache hygiene (i.e. use paccache to keep pacman's pkg cache under control).


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

#4 2022-08-18 22:11:30

2ManyDogs
Forum Fellow
Registered: 2012-01-15
Posts: 4,645

Re: Separate /var partition

If you need to shrink /home to make room for the new /var, why not just use the extra space from /home to make your root partition bigger instead?

Offline

#5 2022-08-19 04:05:41

mpan
Member
Registered: 2012-08-01
Posts: 1,207
Website

Re: Separate /var partition

As for the “/var” usage and its separation, I wonder what could be reasons to even care about it.

The ones I can invent now are:

  • Running out of space, if some database grows uncontrollably. That may happen with a world-facing database and could result in a DoS of the entire system. But nowadays we have disk quotas to address this.

  • Fragmentation due to high number of writes. But with modern file systems like ext4 and btrfs that is no longer such a huge issue.

  • Database I/O interleaved with other disk activity slowing down both. That may be an actual concern for heavy I/O. But addressing that requires putting “/var” on a separate device, not just another partition.

  • Separating operating system, in the meaning of software installed and configuration, from the data. A very good reason, but first you need to have such a setup and the need for one.


Sometimes I seem a bit harsh — don’t get offended too easily!

Offline

#6 2022-08-19 13:54:32

jason88452
Member
Registered: 2022-08-18
Posts: 3

Re: Separate /var partition

Thank you all for your input, I appreciate it so much.

I can't resize my partitions because I use XFS. I had this layout in mind since the installation.

The reason why I'm using a separate /var is because it takes up so much space. A while ago, I had /var in the root directory and that made the / directory around 98% full, so I had to clear the pacman cache frequently. Plus, the Arch Wiki recommends to separate /var to prevent the / directory from running out of space.

After thinking about it for a while, I noticed that one layout could be better than the other in my case. One important detail I forgot to mention is that I usually have my /home directory (which is over 900GiB in size) less than 10-15% full because most of my data sits in my Google Drive cloud. So, putting a partition with only the first 90 GiB in use while the remaining 810GiB is empty before a 'frequently accessed' partition on an HDD sounds like a pretty bad idea. Because, this frequently accessed partition will sit in the last 12GB of my drive which is a pretty slow area compared to the outside of the disk, far away from where the rest of the data is actually located. Thus basically, there's going to be an 810GiB empty space between where data is populated (/boot, / and the first 90GiB of /home) and the /var partition. Plus, since /var is frequently accessed, it would make sense to put it near the beginning of the disk with the rest of the data. This way, the disk arm wouldn't have to jump back and fourth to skip hundreds of GiBs in empty space just to get to a frequently accessed partition. Instead, it'd be much better if I put /var before home so that way the arm of the disk wouldn't even have to go to the end of the drive. This way, all data is going to be on the outer edge of the drive without /var having to sit at the end of the HDD with over 810GiB of empty space before it.

Last edited by jason88452 (2022-08-19 13:56:53)

Offline

#7 2022-08-19 13:59:05

jason88452
Member
Registered: 2022-08-18
Posts: 3

Re: Separate /var partition

WorMzy wrote:

As mpon says, it doesn't make any difference where you put it. But if you need to shrink the /home partition to make space, it's safer to just shrink it. If you shrink it and move it, you're much more likely to have something go wrong and end up losing data (but you have backups right?).

/var is mostly used for caches and logs, the system journal will dump it's logs to disk here unless you explicitly tell it not to, and pacman will store cached packages here (again, unless you tell it not to). Those are the biggest users of /var off the top of my head. Personally I don't see a need for a separate var partition, so long as you maintain good cache hygiene (i.e. use paccache to keep pacman's pkg cache under control).

Sadly, I can't shrink my /home partition before it's using the XFS file system. And I am keeping a good cache hygiene, however the /var kept filling up again pretty fast regardless which was a bit annoying.

Offline

#8 2022-08-19 14:19:43

seth
Member
Registered: 2012-09-03
Posts: 51,135

Re: Separate /var partition

And with what did /var keep filling up pretty fast?
You should maybe rather address that than trying to gloss over it w/ partition shenanigans.

Online

#9 2022-08-19 15:45:11

mpan
Member
Registered: 2012-08-01
Posts: 1,207
Website

Re: Separate /var partition

As seth said.

That is absolutely not normal. For comparison: the installation of Arch from which I write now is almost 12 years old and the entire “/var” currently holds 12GB. Some people have a bit less, some even an order of magnitude more, but certainly nothing that would fill up a terabyte-sized file system.

Since a very common culprit is not cleaning pacman’s cache: install community/pacman-contrib. Among other useful utilities, it offers paccache, which will allow you to clean pacman cache, leaving only most recent and needed packages. The code below removes all but the three last versions of package files of installed packages, and all package files of not installed packages. Replace `-r` with `-d` to only print what will be removed:

sudo pacman -rk3
sudo pacman -ruk0

If it wasn’t pacman’s cache, install community/ncdu: a terminal tool to explore what takes space. Run it like this, wait for it to complete collecting data and determine, what uses up space:

sudo ncdu -r /var

The `-r` option enables read-only mode, so you would not accidently remove something — you may skip it, if you want to use ncdu to also remove stuff. But most likely you do not want to. Removing files belonging to some software you no longer use is generall safe. But otherwise you want to determine what and why produces the files, and address that for each piece of software separately.

As for the considerations regarding partition placement, everything I had to say was written above.

— edit: for the record, the change introducing the suggestion we’re talking about.

Last edited by mpan (2022-08-19 16:39:00)


Sometimes I seem a bit harsh — don’t get offended too easily!

Offline

Board footer

Powered by FluxBB