Best Practices for Linux Partitioning Mousavi, July 9, 2023July 21, 2023 Ubuntu Server, a widely adopted Linux distribution, is preferred by numerous organizations to meet their server requirements. It stands out as a robust and dependable operating system, serving various purposes. However, comprehending the recommended approaches for partitioning Ubuntu Server becomes crucial to guarantee peak performance and security. Within this article, we will explore ten best practices for partitioning Ubuntu Server that deserve your attention during the server setup phase. Our discussion will encompass crucial aspects like partition dimensions, file system types, and partition arrangement. By adhering to these best practices, you can establish a well-configured and secure Ubuntu Server environment. 1. Leverage LVM LVM, an acronym for Logical Volume Manager, enables the creation of logical partitions on your hard drive. Rather than relying on a single partition to house all your data, LVM empowers you to establish multiple partitions, each dedicated to specific tasks or applications. Employing LVM simplifies disk space management. Resizing existing partitions becomes effortless without the need to delete and recreate them. Furthermore, if you require additional storage, you can incorporate extra physical disks and utilize LVM to merge them into a unified virtual disk. This process is significantly more convenient than manually creating new partitions whenever the need for more space arises. 2. Segregate /var/log from /var The /var directory serves as a repository for files that undergo frequent modifications, such as log files. Storing these files within the same partition as other system files can lead to performance issues, including disk fragmentation and I/O contention. By separating /var/log from /var, you allocate dedicated space on the disk solely for log files, consequently enhancing the overall system performance. 3. Separate /tmp from /var The /tmp directory is used for temporary files, and it can quickly become filled with large amounts of data. This can cause performance issues on the server if not managed properly. On the other hand, the /var directory contains system logs and other important information that should be kept separate from the temporary files in /tmp.By separating these two directories, you can ensure that your server runs more efficiently and that any potential problems are easier to diagnose. Additionally, this will help keep your system secure by preventing malicious code from being stored in the /tmp directory. 4. Separate /usr from / The /usr directory contains all of the user-installed applications, libraries, and other files. This means that if something goes wrong with the root partition (/) then it won’t affect the /usr partition. By separating these two partitions, you can ensure that any problems with the root partition will not cause your installed applications to become inaccessible or corrupted.Additionally, by having a separate /usr partition, you can easily upgrade your system without worrying about losing any of your installed applications. This is because when you upgrade Ubuntu, only the root partition is affected, leaving the /usr partition untouched. 5. Separate /home from / The / directory is where the operating system and its applications are installed. This means that any changes to the OS or application files can cause instability in the server, which could lead to data loss or other issues. By separating /home from /, you ensure that user data remains safe even if there are problems with the OS or applications. Additionally, it’s a good idea to create separate partitions for log files, temporary files, and backups. This helps keep your server organized and makes it easier to manage. It also ensures that important data isn’t lost due to disk space constraints. 6. Separate /boot from / The /boot partition contains the Linux kernel and other essential files needed to boot the system. If this partition is corrupted, it can cause serious problems with the server’s ability to boot up properly. By separating /boot from /, you are protecting these important files from any potential corruption that could occur in the root directory.Additionally, if you ever need to upgrade your kernel or make changes to the boot configuration, having a separate /boot partition makes it much easier to do so without affecting the rest of the system. 7. Separate swap space from root partition Swap space is used to store data that would otherwise be stored in RAM, but can’t fit due to memory constraints. This means that if the root partition runs out of space, it will start using swap space as well, which can lead to performance issues and even system crashes. By separating swap space from the root partition, you ensure that your system has enough room for both RAM and swap space, so that it can run smoothly without any problems. 8. Create a separate partition for backups Having a separate partition for backups ensures that your data is stored in an isolated environment, which helps protect it from any malicious activity or system failure. Additionally, having a dedicated backup partition allows you to easily restore files and settings if something goes wrong with the main operating system partition. Finally, creating a separate partition for backups also makes it easier to manage disk space. By keeping all of your backups on one partition, you can quickly identify how much storage space is being used by backups and adjust accordingly. 9. Do not use bind mounts Bind mounts are a type of mount that allows you to mount the same directory or file system in multiple locations. This can be useful for certain applications, but it also has some drawbacks.The main issue with bind mounts is that they can cause confusion when trying to manage files and directories. For example, if you have two different versions of a file mounted in two different places, it can be difficult to keep track of which version is the most up-to-date. Additionally, changes made to one version may not be reflected in the other, leading to inconsistencies.For these reasons, it’s best to avoid using bind mounts whenever possible. If you do need to use them, make sure you understand how they work and take extra care to ensure your data remains consistent across all versions. 10. Do not create too many partitions Having too many partitions can lead to a decrease in performance, as the system has to search through multiple partitions for data. It also increases the complexity of managing your server, as you have to keep track of which partition contains what data. Finally, it can cause confusion when trying to troubleshoot issues, as it’s not always clear which partition is causing the problem. Therefore, it’s best to create only the necessary partitions and avoid creating unnecessary ones. This will help ensure that your Ubuntu Server runs smoothly and efficiently. follwing numbers are extraceted from Dell site. you can use this as a guidance. NameRecommended Partition Space/homeRemaining Free Space after other partitions created or second drive./usr20 GB at least/var2 GB/lib5 GB/boot250 MB/opt500 MB to 5 GB/etc250 MB/sbin250 MB/bin250 MB/dev250 MB/srv100 MB/tmpMatch this to the size of the Swap partition./mnt8 KB This is an empty partition that is used as a mount point for temporary files./media8 KB This contains subdirectories for mount points of removable media, such as CDs and USB flash drives./swapTwice as large as the amount of RAM in the personal computer. Server Configuration /var/var/logbest practicesdisk space managementlinuxLinux distributionlogical partitionsLogical Volume ManagerLVMoperating systemoptimal performancepartiotionpartitioningperformance issuessecurityserverserver needsubuntuUbuntu Server