Jump to content

Why Separate Boot, Home, and Var Partition in Linux?

Go to solution Solved by CWP,

/boot: For legacy reasons. In the olden days, BIOS cannot reference any sector that is located higher than 1024 cylinders. Forcing the /boot partition to be on its own and be the first partition created ensures that the necessary files are located below the 1024-cylinder limit. The Linux kernel and the initrd/initramfs image are located here to ensure everything is loaded into memory to start the actual storage drivers for direct access in order to get rid of the slow and limited BIOS for reading data. I am not sure if UEFI solved this issue though...

 

/home, /var, /usr, ...: Compartmentalize the storage space. For example, if you have an errant user or process that fills up the /home partition, it does not affect /var, where the log files are stored. You can then review the logs in order to investigate what happened. Also, take a look at the /etc/fstab file. Each line has two numbers at the end. One is for dump (an old, old backup program), and the other is to tell the system to fsck on boot (file system check).

 

It also enables security and/or different file system strategies. For the security example, /boot, /usr, are mostly static (except if you are updating). /home and /var, not so much. In other words, you can configure the system to mount these partitions as read-only on startup, and only remount them read-write before you update.

A useful mount flag is noexec, where you are indicating to the system that it should not honour any binary programs that are marked executable. For example, if a web-uploaded file is stored in /tmp, and there just so happens to be an exploit that remotely triggers the ability to start a program, mounting /tmp with the noexec flag would help keep that from happening. Another example would be if you do not allow your users to run any programs that they download or compile themselves: mount /home with noexec. If there is no reason why a certain mount point should contain runnable programs, it should be mounted with noexec.

 

For different file system strategies, Gentoo uses portage for their package management system that contains an enormous amount of small files stored in /usr/portage. You can format that mount point's partition with a file system that is more efficient at storing small files. Of course, this recommendation was made before SSDs were available or affordable.

On the other hand, f2fs file system is supposed to be more efficient for flash-based storage (minimizes writes), but not every boot code supports f2fs, so you may have to use ext4 for /boot and f2fs for the rest.

/tmp is supposed to be volatile. You cannot expect any file stored there to survive a reboot. Some distributions will deliberately wipe it out on startup. Some security auditing scripts (CSF, some profiles in RHEL/CentOS7's OpenSCAP, etc.) would recommend mounting a ramdisk there, again for compartmentalizing, but there is also next to no slowdown for "wiping" that directory.

 

Of course, most of the above would not apply to you. These are some of the examples that I have encountered that either requires using or improves if using different mount points. Personally, I have not been following the different mount points strategy, instead opting for whatever the distribution decides (which is usually a separate /boot and a separate /home, if space allows), although I may take extra security precautions if I am setting up an Internet-facing server.

 

TL;DR: Personal preference. Some are for legacy reasons. Some for technical reasons. Some were suggested long ago, but do not apply now. Take extra precaution if you are setting up a Linux-based server that has direct access to the Internet.

I've been thinking of this for a long time, why does Linux do this? Why separate everything? What's the benefit? Why not just combine them together? I've tried this and it works as well, everything is kept in one place.

Where I hang out: The Garage - Car Enthusiast Club

My cars: 2006 Mazda RX-8 (MT) | 2014 Mazda 6 (AT) | 2009 Honda Jazz (AT)


PC Specs

Indonesia

CPU: i5-4690 | Motherboard: MSI B85-G43 | Memory: Corsair Vengeance 2x4GB | Power Supply: Corsair CX500 | Video Card: MSI GTX 970

Storage: Kingston V300 120GB & WD Blue 1TB | Network Card: ASUS PCE-AC56 | Peripherals: Microsoft Wired 600 & Logitech G29 + Shifter

 

Australia 

CPU: Ryzen 3 2200G | Motherboard: MSI - B450 Tomahawk | Memory: Mushkin - 8GB (1 x 8GB) | Storage: Mushkin 250GB & Western Digital - Caviar Blue 1TB
Video Card: GIGABYTE - RX 580 8GB | Case: Corsair - 100R ATX Mid Tower | Power Supply: Avolv 550W 80+ Gold

 

Link to comment
Share on other sites

Link to post
Share on other sites

Personal preference?

DISPLAYS: LG 27UL500 IPS 4k60hz + HDR and LG 27GL650F IPS 1080p 144hz + HDR

 

LAPTOP: Lenovo Legion 5 CPU: AMD Ryzen 7 5800H GPU: RTX 3070 8GB RAM: 16GB 3200MHz (2x8GB DDR4) STORAGE: 1TB Crucial P5 NVMe SSD + 2TB Samsung 970 evo plus NVMe SSD DISPLAY: 1080p 165hz IPS OS: Windows 10 Pro x64

Link to comment
Share on other sites

Link to post
Share on other sites

Just now, Kirky2k15 said:

Personal preference?

Maybe, because some people said to me to separate those stuff in separate partition, but some people said otherwise (just combine them together).

Where I hang out: The Garage - Car Enthusiast Club

My cars: 2006 Mazda RX-8 (MT) | 2014 Mazda 6 (AT) | 2009 Honda Jazz (AT)


PC Specs

Indonesia

CPU: i5-4690 | Motherboard: MSI B85-G43 | Memory: Corsair Vengeance 2x4GB | Power Supply: Corsair CX500 | Video Card: MSI GTX 970

Storage: Kingston V300 120GB & WD Blue 1TB | Network Card: ASUS PCE-AC56 | Peripherals: Microsoft Wired 600 & Logitech G29 + Shifter

 

Australia 

CPU: Ryzen 3 2200G | Motherboard: MSI - B450 Tomahawk | Memory: Mushkin - 8GB (1 x 8GB) | Storage: Mushkin 250GB & Western Digital - Caviar Blue 1TB
Video Card: GIGABYTE - RX 580 8GB | Case: Corsair - 100R ATX Mid Tower | Power Supply: Avolv 550W 80+ Gold

 

Link to comment
Share on other sites

Link to post
Share on other sites

/boot: For legacy reasons. In the olden days, BIOS cannot reference any sector that is located higher than 1024 cylinders. Forcing the /boot partition to be on its own and be the first partition created ensures that the necessary files are located below the 1024-cylinder limit. The Linux kernel and the initrd/initramfs image are located here to ensure everything is loaded into memory to start the actual storage drivers for direct access in order to get rid of the slow and limited BIOS for reading data. I am not sure if UEFI solved this issue though...

 

/home, /var, /usr, ...: Compartmentalize the storage space. For example, if you have an errant user or process that fills up the /home partition, it does not affect /var, where the log files are stored. You can then review the logs in order to investigate what happened. Also, take a look at the /etc/fstab file. Each line has two numbers at the end. One is for dump (an old, old backup program), and the other is to tell the system to fsck on boot (file system check).

 

It also enables security and/or different file system strategies. For the security example, /boot, /usr, are mostly static (except if you are updating). /home and /var, not so much. In other words, you can configure the system to mount these partitions as read-only on startup, and only remount them read-write before you update.

A useful mount flag is noexec, where you are indicating to the system that it should not honour any binary programs that are marked executable. For example, if a web-uploaded file is stored in /tmp, and there just so happens to be an exploit that remotely triggers the ability to start a program, mounting /tmp with the noexec flag would help keep that from happening. Another example would be if you do not allow your users to run any programs that they download or compile themselves: mount /home with noexec. If there is no reason why a certain mount point should contain runnable programs, it should be mounted with noexec.

 

For different file system strategies, Gentoo uses portage for their package management system that contains an enormous amount of small files stored in /usr/portage. You can format that mount point's partition with a file system that is more efficient at storing small files. Of course, this recommendation was made before SSDs were available or affordable.

On the other hand, f2fs file system is supposed to be more efficient for flash-based storage (minimizes writes), but not every boot code supports f2fs, so you may have to use ext4 for /boot and f2fs for the rest.

/tmp is supposed to be volatile. You cannot expect any file stored there to survive a reboot. Some distributions will deliberately wipe it out on startup. Some security auditing scripts (CSF, some profiles in RHEL/CentOS7's OpenSCAP, etc.) would recommend mounting a ramdisk there, again for compartmentalizing, but there is also next to no slowdown for "wiping" that directory.

 

Of course, most of the above would not apply to you. These are some of the examples that I have encountered that either requires using or improves if using different mount points. Personally, I have not been following the different mount points strategy, instead opting for whatever the distribution decides (which is usually a separate /boot and a separate /home, if space allows), although I may take extra security precautions if I am setting up an Internet-facing server.

 

TL;DR: Personal preference. Some are for legacy reasons. Some for technical reasons. Some were suggested long ago, but do not apply now. Take extra precaution if you are setting up a Linux-based server that has direct access to the Internet.

CPU Intel i7-7700 | Cooling Noctua NH-D14 SE2011 | Motherboard ASUS ROG Strix Z270F Gaming | RAM Corsair Vengeance LPX 3.6GHz 32GB | GPU EVGA GeForce RTX 3070 FTW3 Ultra Gaming |

Case Fractal Design Define R5 | Storage Samsung 980 PRO 500GB, Samsung 970 EVO+ "v2" 2TB | PSU Corsair RM850x 2021 | Display ASUS VP247QG + Samsung SyncMaster T220 | OS Garuda Linux

Link to comment
Share on other sites

Link to post
Share on other sites

55 minutes ago, CWP said:

snip

I'll take note of this, thank you :)

Where I hang out: The Garage - Car Enthusiast Club

My cars: 2006 Mazda RX-8 (MT) | 2014 Mazda 6 (AT) | 2009 Honda Jazz (AT)


PC Specs

Indonesia

CPU: i5-4690 | Motherboard: MSI B85-G43 | Memory: Corsair Vengeance 2x4GB | Power Supply: Corsair CX500 | Video Card: MSI GTX 970

Storage: Kingston V300 120GB & WD Blue 1TB | Network Card: ASUS PCE-AC56 | Peripherals: Microsoft Wired 600 & Logitech G29 + Shifter

 

Australia 

CPU: Ryzen 3 2200G | Motherboard: MSI - B450 Tomahawk | Memory: Mushkin - 8GB (1 x 8GB) | Storage: Mushkin 250GB & Western Digital - Caviar Blue 1TB
Video Card: GIGABYTE - RX 580 8GB | Case: Corsair - 100R ATX Mid Tower | Power Supply: Avolv 550W 80+ Gold

 

Link to comment
Share on other sites

Link to post
Share on other sites

A few quick things to add to @CWP's very thorough post: some of the partitioning becomes very useful when you have an SSD boot drive and HDD mass storage drive.  Some partitions--namely, /tmp, /var, the swapfile, and sometimes /home depending on your use case--are highly volatile, and are often constantly have data written to them, then deleted, then re-written.  So you can put these partitions on your HDD if you're concerned about read/write cycles on your SSD.

 

Using separate partitions can also make re-installing or switching distros less of a hassle, since you can only re-install the OS files while leaving, say, /home untouched.  You can then point your new install at the location of your old partitions and have your files back.  A lot of people actually recommend using a separate /home partition for just this reason, especially if you're planning to hop distros at some point or if you're installing Linux Mint right around now (Mint is one of the few distros that really, really pushes you to do a clean install when there's a new major version out).

Link to comment
Share on other sites

Link to post
Share on other sites

18 hours ago, Azgoth 2 said:

A few quick things to add to @CWP's very thorough post: some of the partitioning becomes very useful when you have an SSD boot drive and HDD mass storage drive.  Some partitions--namely, /tmp, /var, the swapfile, and sometimes /home depending on your use case--are highly volatile, and are often constantly have data written to them, then deleted, then re-written.  So you can put these partitions on your HDD if you're concerned about read/write cycles on your SSD.

 

Using separate partitions can also make re-installing or switching distros less of a hassle, since you can only re-install the OS files while leaving, say, /home untouched.  You can then point your new install at the location of your old partitions and have your files back.  A lot of people actually recommend using a separate /home partition for just this reason, especially if you're planning to hop distros at some point or if you're installing Linux Mint right around now (Mint is one of the few distros that really, really pushes you to do a clean install when there's a new major version out).

Awesome! Thank you for adding this :D

Where I hang out: The Garage - Car Enthusiast Club

My cars: 2006 Mazda RX-8 (MT) | 2014 Mazda 6 (AT) | 2009 Honda Jazz (AT)


PC Specs

Indonesia

CPU: i5-4690 | Motherboard: MSI B85-G43 | Memory: Corsair Vengeance 2x4GB | Power Supply: Corsair CX500 | Video Card: MSI GTX 970

Storage: Kingston V300 120GB & WD Blue 1TB | Network Card: ASUS PCE-AC56 | Peripherals: Microsoft Wired 600 & Logitech G29 + Shifter

 

Australia 

CPU: Ryzen 3 2200G | Motherboard: MSI - B450 Tomahawk | Memory: Mushkin - 8GB (1 x 8GB) | Storage: Mushkin 250GB & Western Digital - Caviar Blue 1TB
Video Card: GIGABYTE - RX 580 8GB | Case: Corsair - 100R ATX Mid Tower | Power Supply: Avolv 550W 80+ Gold

 

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×