LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Debian (https://www.linuxquestions.org/questions/debian-26/)
-   -   How much space does /var need? Definite answer needed. (https://www.linuxquestions.org/questions/debian-26/how-much-space-does-var-need-definite-answer-needed-4175613523/)

Weapon S 09-10-2017 12:44 AM

How much space does /var need? Definite answer needed.
 
I have /var on a separate partition. While following the recommendations for ArchLinux, I made the partition 10GB. Less than 2GB is in use. I could really use every GB of the SSD the partition is on.
People around the internet seem to say 2GB is enough for Debian/Ubuntu. I know Debian has to download a tonne of stuff to /var for a system upgrade though... What is a safe minimum size for /var? Or am I stuck with 10GB still then? Thank you for your input.

dejank 09-10-2017 01:49 AM

Short answer would be that there is no definite answer. Var is indeed variable directory. For example, in my case, it uses some 5,6GB of space. I could make it smaller, for example be cleaning /var/cache/apt/archives that take 4,4GB of that. But I have plenty of room, so no need for that. In your case, if you do not need archives and if you setup your apt tools to automatically clean archives and if you have nice set up for logs that do not fill like mad, you do not need more than 2GB. But, unless you really, really need /var as separate directory, just put it under / and do not think much about it. All you need of partitions is / and /home, plus some swap, depending on your RAM and need for hibernate, in case of laptops. You do not need even /home, it all can go under /, but having /home separate can make your life easier, when it comes to backups and such.

IsaacKuo 09-10-2017 06:18 AM

If you could really use every GB of the SSD, I would recommend you modify things so that everything is in a single partition that takes up the entire SSD. Only have a true swap partition if you use the hibernation feature (suspend to disk). If you don't use hibernation, but you still want swap, create a swapfile. With a swapfile, it's easy to delete it at any time if you need more disk space.

I've used Debian for many years, but honestly I have never used /var on a separate partition. But I can say 2GB would definitely be enough unless you have, say, a humongous web site stored on /var/www (the default location for a web site). Some stuff you can do to clean up disc space:

Code:

apt-get clean
apt-get install localepurge
apt-get remove --purge packageYouDontWant
apt-get autoremove --purge

I always run apt-get clean to flush out cached archives after installing regular updates. Localepurge is a package to get rid of stuff for languages other than the one(s) you need. It doesn't actually free up much space, so don't be surprised when it doesn't really help much.

Another thing that can help conserve disc space, but at the expense of RAM, is to mount /home/user/.cache on a tmpfs RAM disk. Depending on your web browser(s) and web browsing habits, this might amount to a large fraction of a GB. Of course, moving it from the SSD to RAM isn't a free ride. It consumes space in RAM, and also it gets wiped clean when you reboot. Still, there are various things I like to mount on RAM disks:

Code:

Filesystem              1M-blocks    Used Available Use% Mounted on
none                        3950      33      3917  1% /var/log
none                        3950      0      3950  0% /var/tmp
none                        3950      1      3950  1% /tmp
none                        3950      0      3950  0% /media
none                        3950    246      3705  7% /home/kuo/.cache

The /etc/fstab entries for these look like:
Code:

none /tmp        tmpfs defaults 0 0
none /var/tmp      tmpfs defaults 0 0
none /media        tmpfs defaults 0 0
none /var/log        tmpfs defaults 0 0
none /home/kuo/.cache tmpfs defaults 0 0

Anyway, the basic steps for converting to a single large partition would be:

1) copy /etc/fstab and prepare a modified fstab:

Code:

cp -vax /etc/fstab /etc/fstab.backup
vi /etc/fstab

Modify it by deleting or commenting out the entries for /var and /home and other such things, as well as comment out the swap partition entry.

2) Boot up to a liveCD.

3) Use gparted to resize/move partitions, if necessary, to provide adequate room in the / partition to store everything. Delete the swap partition at this time (depending on the liveCD, you might need to run "swapoff -a" first to unlock the swap partition.)

4) Mount the various partitions.

5) Copy the contents of various partitions to the appropriate locations in the / partition. Something like this:
Code:

cp -vax /media/user/VARPART/* /media/user/ROOTPART/var/
6) After all contents have been copied, reboot the system to make sure everything works. Use "fdisk -l" to confirm that none of the other partitions are mounted.

7) Boot back into the liveCD; use gparted to delete the now unused partitons. Resize the main partition to use the entire space of the SSD.

jlinkels 09-10-2017 06:41 AM

On my laptop /var is 1.6G. IIRC I installed the previous Debian version and did one dist-upgrade. But /var can grow fast if you have some logfiles which suddenly grow large.

Current desktop installations I make with 1 or 2 partitions. At most a separate /home but often not even that. Because with limited disk space you need space overhead on each partition just to be sure. And with a single partition you share that overhead.

jlinkels

Weapon S 09-13-2017 09:48 AM

I guess the definitive answer is: you can't know. Also the tip to just put it under the root directory makes sense.
(In my previous setup it sort of made sense, because I tried to spare another SSD from spurious writes.)


All times are GMT -5. The time now is 04:56 AM.