- Linux Partitioning Recommendations
- Content
- Partitioning for Linux-only Installation
- Disk Selection
- Creating Partitions
- efi (UEFI bootloader)
- / (Linux system)
- /home (personal user data)
- swap (temporary storage)
- Partitioning table summary
- Partitioning to dual-boot Linux and Windows
- Freeing up Space for Linux
- Creating Linux Partitions
- Partition a New Drive for data storage
- Conclusion
- Best Disk Partitioning Scheme for a Linux-based Developer Machine
- 5 Answers 5
Linux Partitioning Recommendations
Manual disk partitioning can be confusing for new Linux users. In this post, we will provide you our Linux partitioning recommendations. We’ll address both EFI partitioning for dual-boot with Windows and Linux-only installation schemes.
Content
Partitioning for Linux-only Installation
Disk Selection
I’ll use Ubuntu 20.04 LTS installer to demonstrate partitioning, but the same process applies to every Linux distro. We need to get to the manual partition settings of the installer, it is located under the “Something else” label in the Ubuntu installer:
This is how Ubuntu’s installer partition manager looks like:
As we can see, I have two hard drives, which are named alphabetically:
If you also have several hadrd drives on your system, you can select the one you need based on its size.
These are brand-new hard drives that are not partitioned yet. I’ll install my system with /dev/sda disk for my Ubuntu installation. For that we first need to create a partition table on it. A partition table will store information about our partitions.
Select your disk → New Partition Table → Continue
Creating Partitions
Now that we have created a partition table, it’s time to create partitions. You can think of partitions as slicing our disk into parts, each for different purpose.
The first partition will be for the bootloader. Bootloader is responsible for loading the operating system and is critical part of every computer. UEFI and BIOS (legacy) are the two common bootloaders for computers. You can find out what bootloader is supported by your hardware in the motherboard firmware specs. Recent hardware uses the UEFI and we recommend to install Linux in the EFI mode, while older hardware can only be used in the legacy mode.
For the EFI mode, we recommend to create four different partitions:
- efi (UEFI bootloader)
- / (Linux system)
- /home (personal user data)
- swap (temporary storage)
Click the “+” button, and create them in order.
efi (UEFI bootloader)
Starting with the efi partition, 100MB is usually more than enough. The type of partition should be primary. Select “EFI System Partition” in the “Use as” dropdown menu.
/ (Linux system)
Now select the rest of the free space to create the root partition. Ubuntu recommends at least 15GB for the system partition. However, if you want to play games and install many programs, I recommend 50GB or even 100GB. It depends on the size of your hard drive and your needs.
Select Ext4 journaling file system if it’s not already selected by default and mount point to be root (i.e., forward slash /).
/home (personal user data)
Next, select the free space again and click the “+” button to create /home partition. Home partition is used to store personal files like images, downloads, music, videos, etc. Again, depending on your needs, choose the size accordingly. I’ll go with 30 GB because it is only for the demonstration purpose.
Select Ext4 journaling file system if it’s not already selected by default and mount point to be /home.
swap (temporary storage)
Last, we have a swap partition. The system automatically uses a swap partition in case RAM gets filled. This way, it doesn’t have to forcibly close processes to free up RAM/prevent a system crash. We have a dedicated post that goes in-depth about Linux swap, so make sure to check it out if you are interested in learning more about it.
There are no strict rules on how large a swap partition should be. With that being said, there are general guidelines that the community follows. If you have less than 8GB of RAM, the swap should be two times that size. Otherwise, the swap can be the same size as RAM.
Once you have selected the right size, make sure to mark the partition as a swap in the “Use as” dropdown menu, and that’s it!
Partitioning table summary
Here’s how my partitioning table looks like after the above changes.
Complete the rest of the steps and fire up the installation once you are ready! Your distro should boot without any issues!
Feel free to run the following command in the newly installed system to check your partition table, and everything should match:
Congratulations! You have installed Ubuntu with manual partitioning, which gives you a lot more flexibility. For example, you can completely wipe the system partition ( / ) and install another distribution on it while all your personal data in /home stays intact. Just remember NOT to format the /home partition during the re-installation.
Partitioning to dual-boot Linux and Windows
Freeing up Space for Linux
While I primarily use Linux as my operating system, it can fall short in specific scenarios. That’s why some users prefer to dual-boot Windows and Linux. This partitioning recommendation will work exacltly for such users.
First, load the Linux installation live system. This time though, select “Try Ubuntu” instead of “Install Ubuntu”. That’s because we need to free up space for Linux before running the installation.
To that end, we’ll use GParted. GParted is the most advanced partition manager for Linux. It’s a lot more capable than the partition manager in the installer.
There is only Windows installed and it occupies the whole disk. That’s the most common scenario for people looking to try Linux but would like to keep Windows.
The only partition that we can modify is the “Basic data partition”. It’s usually the largest partition, and in my case, it’s /dev/sda3. We are going to resize that partition to free up some space for our Linux system.
Right-click on the basic data partition → Resize → Type the new (smaller) size for that partition
I’ve decided to shrink the basic data partition to 30GB and I was left with 90GB of free space for my Linux system. You need to do similar shrink on your system.
Creating Linux Partitions
We already have an efi partition that was created by the Windows installer, so we don’t need to create it.
We only need to create the remaining three partitions:
The detailed steps on doing this can be found by scrolling up to the “Creating Partitions” section above. The only difference is that GParted has an “Add” button instead of “+” like the installer’s partition manager and you do not need to add mount points in GParted.
After you have provided the new partition scheme in Gparted, all changes are “virtual”, meaning that your drive is still intact. It’s a fantastic feature of GParted that allows us to see how the drive would look with our changes. Once you’re happy with your changes, click the checkmark button on the top menu to apply the changes.
Depending on the size of your drive, it may take some time for changes to complete. Nevertheless, once it’s done, we can proceed with the installation. Launch the installer from the desktop menu and go to the partitioning step. (it’s called “Installation type” in Ubuntu’s installer)
Select manual partition or “Something else”, as Ubuntu calls it and you will see the newly create partition scheme. Now we only need to edit our system ( / ) and /home partitions to specify the mount points for root / and /home respectively.
Proceed with the installation steps, and that’s it! Once you reboot the system, the GRUB menu should show up, asking you to select which operating system to boot.
Note: If it doesn’t show up, don’t panic! Go to the boot manager in BIOS (usually F8 at the boot) and shift Ubuntu to be first in the list.
Partition a New Drive for data storage
Another scenario would be that you have purchased a hard drive and would like to add it to your Linux system as a data storage. Similar to the above, we’ll use GParted, the bets Linux partitioning tool.
Open GParted → Select your new disk → Device → Create New Partition Table → Select type msdos → Apply
Now we can partition the hard drive. If you would like to have use this hard drive with Linux exclusively, you can create one ext4 file system partition that occupies the whole disk.
Alternatively, you can split the drive into two partitions: one for Linux with the ext4 filesystem and another one for Windows with the ntfs filesystem. When you are done with partitioning, don’t forget to click “Apply” for GParted to apply changes.
Opening files manager confirms that the partitions have been created.
Conclusion
We have finally addressed one of the most common sources of confusion regarding manual Linux partitioning. This was a more advanced topic, so kudos to you for reaching it to the end!
Let me know in the comments below if you would like to see more advanced Linux tips. Also, don’t forget to subscribe to our newsletter, so you don’t miss out on the latest posts!
Best Disk Partitioning Scheme for a Linux-based Developer Machine
Is there some kind of «best disk partitioning scheme» for a Linux-based web and application developer machine, in terms of performance, organization or others?
5 Answers 5
Partitioning doesn’t affect performance so much, but yes, file systems and their configuration affect performance. Look at this benchmark. For a little information about mounting options, see fstab at the ArchWili; especially look at atime options.
Partitioning has nothing with organization files in Linux, because in Linux everything is mounted into one tree.
I recommend one partition for the root filesystem, / , and separate partitions for folders where you place your work and personal data: /home and /var/www if you put your websites here, because if you change distro you will no need to do backup.
You may make partitions/disks based on files organization and their importance.
For example, you have got projects and documents which are very precious, then you can have them on RAID-ed disks. Also you may have remote disk mounted with ssh/ftp.
/ -> SSD disk, partition 1 /home -> SSD disk, partition 2 /tmp -> tmpfs /media/data -> RAID-ed disk, partition 2 (ie. shared photos with family) user mounts: /home/miroslav/secure -> RAID-ed disk, partition 1 (encrypted) /home/miroslav/remote -> sshfs/curlftpfs
To mount remote and secure directories you will probably need some script that asks you for password(s).
Directory sym-links pwd=/home/miroslav :
projects -> secure/projects documents -> secure/documents mails-dir -> secure/mails
On our internal developement virtual machines we use three partitions:
- /root partition — housing mostly static operating system stuff
- /var partition — for all dynamic data
- /home partition — this is where development takes place with the user accounts of the developers
The reason to separate the partitions is to avoid a system halt due to full filesystem. If /home is full — does not matter. No running processes are affected. Delete something, enlarge online and continue.
/ should not change much (the only exception is /tmp — but files there are usually never big).
/var is the place where /var/tmp and all other «live» data resides (including /var/log ). A full /var/log is still the number one reason for system/application failures, so /var has to be big enough and there has to be a warning in time when space is becoming sparse there.
On physical machines, where disk space does not matter that much, we divide up additional «partitions» (mostly LVs), including: /var , /var/tmp , /var/log , /tmp , /boot , . but these are production machines, where uptime matters.
I used to make separate partitions for / , /home , /usr/local and /var , but I always seemed to end up with some sort of interactions across partitions. If I did install a different distro, I would want to have the unused dotfiles removed for simplicity, so I still made a backup and wiped /home .
As for making a /var partition, I made so many sites at school (~100 or so), with such a large variance in sizes between media heavy sites and text only exercises, that it was impossible for me to accurately estimate the amount of space to allocate.
Now, I just have one partition for everything, and I don’t come anywhere near filling it up. Personal media (movies, games, shows) go on an external HD, so that I can take it to a friend’s house. For virtual machines, which have to be virtual appliances in virtualbox if you want to move them, I like to have a dedicated flash drive for each one.
I’ve never seen a HD crash, but if it did, I don’t think it would matter how the physical drive was partitioned; it would just be dead. The riskiest thing I’ve ever done with my HD is resizing partitions, which is no longer necessary.