Hideki A. Ikeda (HidekiAI) [池田英紀] ["Tony" Ikeda] –  BLog

Linux Partition Size

Most of my journal pages are my observations and personal reminder (log, hence Web Log-> bLog). It’s convenient for me to write it here so that if I need to reference it from anywhere (i.e. from work) I can, and it (hopefully) benefits the readers from my experiences. One thing which I’ve constantly question myself when I allocate partitions for Linux system is “how much”?

Here are my charts based on my experiences and observations (again on Gentoo). Before I list my charts, I’d like to display my current/sample size based on “df -h”:

Filesystem            Size Used  Avail Use% Mounted
/dev/sda3             19G  737M  18G   5%   /
/dev/mapper/vg-usr    9.9G 8.3G  1.1G 89%   /usr
/dev/mapper/vg-home   9.9G 164M  9.2G  2%   /home
/dev/mapper/vg-opt    5.0G 750M  4.0G 16%   /opt
/dev/mapper/vg-var    9.9G 832M  8.6G  9%   /var
/dev/mapper/vg-tmp    2.0G 90M   1.8G  5%   /tmp
/dev/sda1             2.0G 59M   1.9G  4%   /boot

Note also that I’ve removed my shared and other irrelevent mounts such as udev off this table.

Notice that I use LVM, the justification for this is (as you will and can see), my /usr is almost out of space so all I need/have to do is lvextend that mount. So from the chart above, here’s what I have the tendency to derive towards:

mount size                sample
/boot small               256M - 512M
/opt  small to medium     756M - 1G
/var  medium              1G - 2G
/tmp  very small to small 128M - 512M
/usr  medium to large     2G - 10G
/home medium to large     1G x nUsers
/     medium to large     1G+

Notes:

  • /boot – I have about 6 different kernels (with initrd, etc) and still have plenty
  • /opt – I only have settings such as jdk, vpn, and ltsp, not much goes here
  • /var – mostly eaten by /var/log, but you might want it larger if you have mail spooler
  • /tmp – mostly session based stuffs including X, no need to be big at all
  • /usr – most of the bloat is due to portage, it would be smaller if I didn’t do –buildpkg option but I do cross-compile to build my i586 binary packages on my x86_64 dev-box.
  • /home – I would say allocate a Gig per user.  Note that if you use WINE, you would probably want this to be bigger since each application install would go here (i.e. “Frozen Throne : Warcraft III” took up about 1.5G on my /home folder).
  • / – I usually use the rest (leftover) for / (including /root, /etc, /lib, /bin)

As you can see, I’ve offshot (and wasted) some of the partition space such as for /tmp. If you are using LVM, many people commonly advises that “it’s easier to grow than shrink the partition“.

Other issues based on my experiences are that you would really want to make sure /boot, /lib, /sbin, /etc to be a partition of its own that is not LVM (i.e. leave it as ext2 or ext3); I took a chance on my /var and /opt folder to be LVM but I’ve rebuilt enough times that I’m willing to take the chances.

As you can see from my “df -h” output, my /boot and / is both on a partition of its own. In the past, I’ve made (or learned lessons from) mistakes of having my /etc in LVM partition or other fs such as reiserfs. When they get corrupted or if the kernel was not properly compiled with right modules and fs, it’s got me in a frustrating situations.

As for SWAP, I’ve usually allocated 2x or 3x my RAM size.

Finally, on a small harddrive system such as my laptop (2Gig), I have partitioned it as 512M for DOS, 256M for /boot, 512M swap, and the rest is / (which /home, /usr, etc all resides).

NFS mounts To Save Space and Avoid Redundancy

I like nfs, to me, it’s the easiest to understand and use.  Some paths can actually be virtual.  But the “rule of thumb” which you should follow is to ask yourself: Can my *nix box boot and will I be able to diagnose without network if something goes wrong? And if you are not sure, then that path should not be virtual.

For example, on my i586 system, I do not allow emerge to compile (there are exceptions such as python based), I only do –usepkgponly because it’s quicker to have my x86_64 compile the package.  Therefore, I may have my /usr/portage mounted to my nfs.  To be honest, emerge is useless without network anyways (although you can set PKGDIR to your CDROM), so it makes perfect sense to override with virtual path.

I may also be able to do nfs for /home folder as well, with or without my /home folder, my box would boot.  I think you get the picture…

Comments

It’s interesting to see things clearer when you run into problems and you find solutions which when you were still new to the subject, you wondered why people did things the way they do.

For example, if you are used to the MSDOS and NT4 methods of filing system, you’d probably have some difficulties of wondering why *nix system allows overlaps based on mounting and unmounting. For example, you you mount a device as “/” and in that mount, there is a subfolder /boot. In this /boot directory, you see nothing in it. Then you mount another device as “/boot”, and suddenly, the contents of /boot is populated.

In my case, on my dev-box, if I wanted to boot both Gentoo and netBSD, but share the same folders such as “~/projects”, it would make sense to allocate a partition (I always dedicate separate drive and/or partition just for my source codes so I have methods to recover the most important data to me – yes, I run CVS on another server box) and mount this partition as /home/username/projects so that it can be accessed from multiple O/S.

Final Suggestions

Sometimes, you run into a driver issue such as lvm2 becomming broken, such is the case as I write this addendum.  It isn’t really broken, it is actually a dependency issue in which device-mapper and lvm2 is having a conflict which blocks it from not being able to update one or the other.

In my case, I had unmerged lvm2 so that I could update device-mapper.  And then I was going to emerge lvm2 back (using the “<” to get the older version).  But before I could merge back the lvm2, I had a blackout (due to a storm and my APC was weak on battery) in which it had caused my box to reboot before I could get the lvm2 back in place.

Long story short is that my devices that are lvm2 based is not accessible at this time.  Which is perfectly fine since my major/main devices are not lvm2 based except “/usr“.  Now, if you now realized that emerge is located in /usr/bin, you can see the issue…

So here is my suggestion.  In most cases, other than /usr/portage folder (and possibly, /usr/src if you keep your old linux kernels), /usr should not grow too much.  So what you want to do is selectively mount subfolders in /usr as you see fit and let /usr be part of “/” mount.

Here is my list of path which I believe should  be part of “/” and the rest can be mounted as separate devices (either as lvm2, ext2, ext3, etc) so that if other devices corrupts or has failure due to drivers/modules, you can still do some surgeries and recover from it.

  • /etc – all your rc’s and configurations are here, so any subfolder included
  • /bin
  • /sbin
  • /lib
  • /usr – subfolders such as /usr/portage and /usr/src can be a separate mounted device.  What you really need from here is debatable, but my suggestions are not to mount /usr/bin, /usr/sbin, and /usr/lib (be careful with /usr/lib since contents may be symbolically linked with other folders)

Another suggestion is that if you are using ext2 for /boot mount rather than ext3, make sure that whenever you build new kernel, you don’t forget the support for it (at least as module).

Related posts

Leave a Reply

You must be logged in to post a comment.

Google AdSense

Google Analytics

Google AdSense Search

Categories