Is it necessary to have a /home
partition in Ubuntu Desktop 20.04? I read somewhere about a home
file in /root
partition...
Does the same go to the /swap
partition?
Can someone set up a guide for New and Experienced users so that this information will be beneficial to many.
/home partition: A separate /home partition has never been necessary. It has always been optional.
The Ubuntu installer has well-considered and quite sane defaults to create a working system for new and/or unskilled users. That default does not create a separate /home partition.
Some folks prefer a separate /home partition, others don't.
/swap partition: Since 18.04, a separate swap partition in most Desktops has been superseded by a swap file within the root partition. A separate swap partition is no longer recommended for most new Desktop users. Swap in a server is a little more complex; swap is recommended for some advanced uses (like non-ext filesystems).
Advice for new users: For your first install, stick to the installer defaults as much as possible. Focus on making your first install successful rather than perfect. You can always repartition/reinstall a more complex system later -- Ubuntu makes it easy.
Certainly not. You may stick to the defaults, that is a single partition holding your files, and perhaps another partition for swapping. On some recent Linux distributions, swapping happen into a swap file (this is slightly less efficient but can be much more convenient, because you won't use a separate disk partition for swap). See swapon(8) and mkswap(8) and the underlying swapon(2) system call. If you are curious, read about virtual memory, file systems, the page cache, and some textbook on operating systems.
An astute reader might want to have a different
/home/
partition to be able to later and easily change his/her Linux distribution (e.g. to Debian or Fedora) without losing their data. This is not necessary, but might be useful.In all cases, don't forget to backup your important data (preferably on a different medium or on some remote server). Hardware disks do fail, and you will make mistakes. You might even automatize your backups (e.g. with crontab and rsync).
NOTE: I will be referring to
/
partition as/root
to make it more clear.For New Users (Simple Successful Install)
Do you need a separate
/home
partition? Definitely not. The home partition is where your personal files (Documents, Downloads, Pictures, etc) are stored. If you don't make a separate/home
partition, those files will be saved in/home/username
folder. So if this is your first time installing Ubuntu, don't try to make it too complicated and don't make a separate partition for/home
. When you are more experienced and confident, you can try this.Do you need a separate
/swap
partition? Well, it depends. If you want to hibernate you will need a separate/swap
partition (see below)./swap
is used as a virtual memory. Ubuntu uses it when you run out of RAM to prevent your system from crashing. However, new versions of Ubuntu (After 18.04) have a swap file in/root
. There is a workaround way to use the swapfile to hibernate but it is not recommended for new users (See below if you want to know). So you don't need to have a separate/swap
partition.So my recommendation to new users is, until you get accustomed to Ubuntu and gain confidence in using it, stick to the defaults in the installer and go with "Erase Disk and Install Ubuntu*" option (If you are dual-booting "Install Alongside YourOS" option).
For Experienced/Confident Users ("Perfect" Install)
If you are experienced and confident it is best to have a separate partition for at least
/home
. You won't need a separate/swap
if you don't hibernate. Even if you want to hibernate, there is a workaround to use the swapfile.Here are the recommended partitioning:
/
root: All the software you install are stored here/home
Only needed if you want to keep your personal files separate from root partition (/
)/swap
Only needed if you want to HibernateWorkaround for hibernation using the swapfile: How to hibernate with swapfile.
It's optional to have a separate
/home
partition. It allows you to reinstall your operating system (Ubuntu) without losing your data and configuration files. There can be other uses not limited to this option.Ubuntu by default creates a "home directory" in
/
partition. It's ok to go without a separate/home
partition. But either way keep a backup of your important files.While swap partition/file is needed for hibernation. The SwapFaq page shows how much space you need for a swap partition
The need for a separate /home partition and swap depends on your usage scenario.
A separate /home partition is a good idea when you have multiple users accessing it via samba or other type of file shares, to prevent them from filling up the root partition (which can cause other issues). On single-user systems with limited space, such as my work laptop, I just go with a big root disk; if it gets filled, it affects noone but me, and I'd rather have the freedom to one day download 100GB of data to my Downloads folder under /home, and the other day to fetch 100GB of docker containers which go under /var. On a server, I might put all of these (/home, /var, /var/lib/docker) on separate partitions for isolation purposes.
The swap partition is often replaced by a swap file nowadays. Apart from swapping/paging, the swap is also used for hibernation on desktop/laptop installations. A swap file has less performance than a partition, but that is hardly noticeable in most installations, and using a swap file gives you more freedom to use more or less swap when required instead of dedicating a part of your hard disk to it.
But do you actually need swap? If you have enough memory, you can do without it. Just be aware that the system to kill processes when/if it does get full. You can use the swapon/swapoff commands to turn on and off swap usage, if you want to try it out.
It should be noted that some software (for example Kubernetes) manages memory on their own and explicitly doesn't want swap space - it won't start if it is available.