7

I'm installing Debian Wheezy on a 50 GB partition of a 500 GB Seagate SATA hard disk with 2 GB RAM. I want to use following partition scheme, but stuck at:

  1. How much (in percent) of disk space should be given to following partitions?
  2. The order in which partitions should be created?

So that system runs very fast and smooth.

/
/boot
/home
/tmp
/usr
/var
/srv
/opt
/var/www
/usr/local
SWAP

MACHINE INFORMATION

  1. Debian Wheezy 64 Bit Update up to Date
  2. Role of Machine Server
  3. Main Software
  4. Bind9, Apache2, Mysql-Server, PHP5
  5. 500 GB Seagate SATA Hard Disk
  6. 2 Partitions 50 GB & 450 GB I do not want touch 450 GB Partition (sda2) however I can take 50 GB more from sda2 if required
slm
  • 369,824
Nishan
  • 508

5 Answers5

5

The partition layout has zero influence on the speed of the system (unless you have partitions across multiple drives). So choose what makes maintenance easier (which is part of running smooth). Unless you have special needs, create the following filesystems (in addition to swap):

  • / for the operating system
  • /home for user data, unless it's a server that only has a few dot files in /home`
  • Possibly a separate for data that doesn't belong to a human user, usually mounted on /srv.

In your case, a separate /home is probably not warranted, but you might want a separate /srv. If you do separate /srv then /var/www and /var/mysql should be symbolic links to directories under /srv.

The partition sizes depend on how much data you have and how many programs you want to install beyond the basic LAMP installation. 10GB for the OS is plenty.

Mount /tmp as tmpfs.

Separate partitions for /var, /usr, /opt and so on will only complicate your life and will bring you no benefit whatsoever.

Use LVM for partitioning, don't create more PC-style partitions. LVM makes administration a lot easier.

  • Just one thing How Mount /tmp as tmpfs will affect system RAM. I have just 2GB RAM at all. – Nishan Aug 23 '13 at 09:22
  • @Nishan Mounting /tmp as tmpfs doesn't affect RAM usage. With tmpfs data is either in RAM or swap, with other filesystems data is either in RAM (buffers/cache) or on-disk, same difference. Mounting /tmp as tmpfs gives a slight performance improvement and avoids needing to clean up or having obsolete files on boot. – Gilles 'SO- stop being evil' Aug 23 '13 at 09:50
  • Thank you, however tmpfs data is either in RAM or swap is confusing me, if temp data is in RAM, it is bound to consume the RAM to some extent. But i am sure there must be some theory behind this and logic behind your advice, which i need to understand. Thank you once again. – Nishan Aug 23 '13 at 11:09
  • @Nishan If you put a short-lived file in an on-disk filesystem, it might stay in the cache and never hit disk. If you put a long-lived file in tmpfs, it might get swapped out. Temp data doesn't consume more or less RAM depending on whether it's on tmpfs or not. Tmpfs can be swapped in and out more efficiently because the kernel doesn't need to enforce any kind of consistent state in case of a power failure. But the amount of RAM and storage that some data consumes is the same whether it's on tmpfs or on-disk storage. – Gilles 'SO- stop being evil' Aug 23 '13 at 11:13
2

Because you are creating all the Debian partitions on the same disk, there is no performance gains to be made by different partition layouts. The only gains are for risk reduction (because putting everything in / can put you in a "bad place" [tm] if that partitions disk space is all used up). I would suggest:

 / 1G
 /boot 100M
 /usr 10G
 /var 15G
 /home 20G
 swap 4G

Place all of /home's space into /usr if you do not plan to have many users/require large space for home directories.

/ a 1G / is generous as most of your operating install will land in /usr. Some libraries will end up in /lib but will only be a few hundred Megabytes in size for most servers. If you are paranoid increase the size of /. /var tends to be your non-volatile data area, log files, pid files, crontabs, transient mail queues, non-volatile tmp directory and so forth. /home is more for the benefit of users, but if in a server role there is nothing to stop you from configuring apache to look in /home/www instead of /var/www, or to symlink over to the /home partition from /var/www.

I've ran my servers in this setup for a number of years and have only had to vary the formula for specific server roles (database servers, large volume mail servers).

Drav Sloan
  • 14,345
  • 4
  • 45
  • 43
  • thank you for your advise and answer but what about /tmp, /srv, /opt, /var/www, /usr/local – Nishan Aug 21 '13 at 11:04
  • /tmp is often tmpfs (which is actually held in memory), most linux distributions do not have /srv or /opt. /var/www can always be a symlink to /home, and even with /usr/local installs you will be hard pushed to fill 10G. – Drav Sloan Aug 21 '13 at 15:45
  • I've updated my question to reflect the new information in your question and to give some insight to my choice of sizes. – Drav Sloan Aug 21 '13 at 15:54
  • 100 MB for /boot can be rather tight. Unless you are strapped for space, I suggest allocating a few hundred megabytes, maybe half a gigabyte, there. Since the question specifies that 50 GB, or 100 GB if necessary, is available for partitioning for the system, limiting /boot to 100 MB seems shortsighted. – user May 24 '17 at 13:03
2

I like to use LVM for partitioning. It's a bit more complex, but I think that its versatility makes it worth it. So I'd partition like this:

  • sda1: /boot (256M)
  • sda2: LVM physical volume (everything else)

You could use LVM also for boot, but it's more complex.

Then I'd create a volume group using sda2 ("vg01", or whatever strikes your fancy) and define these logical volumes:

  • root (mounted on /): 2G
  • usr (/usr): 10G
  • var (/var): 3G
  • home (/home): 10G
  • swap (for swap): 2G (depending on your memory; I'd use 4GB tops)

I like to use names for LVs that tell me what is in them. Plus, it makes it easier to tab-complete :-)

This layout would leave about 23GB (50 - (2+10+3+10+2)) free to assign to whatever you want. With LVM you can create volumes for temporary things and then delete them, or resize current volumes if you find you need more space.

rsuarez
  • 902
2

Since you've made a small partition, I would just put everything on / and make about 2GB of swap. That's it :)

Alko
  • 922
0

From experience probably the most manageable best partition scheme looks like this:

/ (/Dev /etc /home /media /mnt /opt /root /run /sys /tmp /var /proc) Rest of GB
/usr (/bin /sbin /lib /lib64) 6GB
/usr/share 3GB
/usr/local 5GB+
/boot 1GB
/var/www (if serving website) 
/swap (2gb recommend in abscence of none)

Why like this?

For / we want to mount this with nodev nosuid noexec. This hardens the system substantially but it means you'll have to run your scripts, portable software and games from /usr/local.

For /usr ideally you will mount as read only to stay fresh, but the odd time you update just remount as rw, no biggie; safely use nodev.

For /usr/share, safe to use nodev, nosuid mount as ro

For /usr/local, this is your program files particularly for scripts, games and portable applications. Mount as rw.

/boot for obvious reasons, read-only (ro) nodev nosuid noexec.

Why not use /home as traditional? because of web browsers and malware. Mounting those directories as nodev nosuid noexec between /var /tmp and /home will cripple almost all malware.

BTW, /proc and /sys are virtual file systems created by the kernel. Therefore can be mounted as desired in fstab.

E L
  • 1
  • 1