18

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.

  • @user535733 I have 16GB RAM. I only use this to explore. My main OS is Windows 10. In Windows I never get above 50% RAM however many apps I open. – Sasuke Uchiha May 3 at 16:42
  • To explore, simply use the LiveUSB's "Try Ubuntu" environment. No need to change any partitions. Doesn't touch your disk at all. If your system can handle it, try installing Ubuntu in a VM - it's easier than repartitioining. – user535733 May 3 at 16:49
  • 8
    BIG RED FLAG: "Ubuntu doesn't give me the option to install alongside Windows". Do NOT attempt to install Ubuntu until you have solved that! Several existing questions explain how. Could be FastBoot, could be Legacy, could be a couple other common stumbles. – user535733 May 3 at 16:55
  • 1
    What brand/model system? What video card/chip? Some need settings. Only use Windows to shrink NTFS partitions & reboot so it runs chkdsk. Then use gparted or during install create / (root) and optionally /home. Make sure Windows fast start up is off. askubuntu.com/questions/843153/… & askubuntu.com/questions/145902/… UEFI install: help.ubuntu.com/community/UEFI & askubuntu.com/questions/221835/… – oldfred May 3 at 17:04
  • 2
    A /home partition protects your personal data in case something goes wrong with your main installation. I've been using Linux as my primary desktop for 20 years and always keep /home separate. – chrylis -cautiouslyoptimistic- May 4 at 12:07
38

A separate /home partition has never been necessary.

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.

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.

| improve this answer | |
  • So if I am not creating a separate /home partition what should be the size of the root partition? – Sasuke Uchiha May 3 at 16:34
  • 4
    Not all filesystems support swapfiles. BtrFS only recently started(kernel 5.0) and ZFS does not. If you're creating a / partitioon on ZFS, you should create a swap partition instead of a swap file. – Syfer Polski May 4 at 11:16
  • 1
    @SyferPolski edited to address your comment. – user535733 May 4 at 11:46
  • 1
    @SasukeUchiha, If you are not having a separate /home , /usr or /var, just make the /root the entire disk. – Lenne May 5 at 8:38
  • 3
    @Lenne you mean /, not /root right? In fact, /root should never be it's own partition, the entire reason it exists is so ~root is on the root partition. – vikarjramun May 5 at 18:02
6

Is it necessary to have a /home and swap partitions in 20.04

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 his/her 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).

| improve this answer | |
  • For the Windows people, making a separate home partition is somewhat analogous to putting your big files (like media) onto a hard disk while having your other files be on an SSD, right? – Captain Man May 4 at 21:28
  • @CaptainMan Exactly. That's what's making me so confused? Where does Windows save the files when hibernating anyway? – Sasuke Uchiha May 5 at 2:59
  • Windows has a hibernate hidden system file on the system partition (c:\hiberfil.sys). – eckes May 5 at 5:10
  • 1
    @eckes And why can't Ubuntu have something similar? – Sasuke Uchiha May 5 at 12:55
  • @SasukeUchiha As written above, swap may be a file instead of a partition – Hagen von Eitzen May 5 at 13:08
2

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.

| improve this answer | |
  • Would the system-sharing case not be better served by some kind of quota enforcement? Otherwise, a user can still fill up the /home partition and make the system unusable for everyone else, even if it's slightly more convenient for the sysadmin. – IMSoP May 5 at 11:22
  • I have a SSD. So it is pretty fast as it is. Also, my SSD is 256GB and I have about 150 used up for windows and 40GB for the shared partition. My current swap file is only 1.7GB and it NEVER seems to get used. I also never seem to get more than 15% RAM usage. – Sasuke Uchiha May 5 at 13:00
  • wellll i recently broke half my ram by spilling coffee on it so I'm down to single channel 4gb so for me it's definitely necessary to have a swap partition.. i'm actually starting to wonder if it was broken before the coffee because the computer had started freezing a lot and at the time i had no swap partition, never thought of checking free -m – Rabbit May 25 at 12:34
  • @IMSoP I would never set up quota management on the root drive. Putting the files on a separate drive comes before any quota management. But, again, it depends on the usage scenario. – rln May 26 at 14:53
  • @rln I don't follow; what's the relationship between what drive/partition a directory is on and how you manage its quota? – IMSoP May 26 at 16:52
2

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

| improve this answer | |
  • I will be saving almost no files in the "home". I will be saving all my personal files in a separate NTFS shared partition with windows. – Sasuke Uchiha May 3 at 16:56
  • @SasukeUchiha then you won't need a /home partition. Using defaults should be fine as @user535733 mentioned. – Mido May 3 at 17:02
  • @SasukeUchiha Suspend has never used swap, you're thinking of hibernate – Izkata May 4 at 14:04
  • That FAQ seems not particular helpful.why would you want to have a 1TB Swap partition. (Besides it does not mention kernel crash dumps which could be the only reason to have a swap size similar to RAM size). Normally I would say have at least 1GB of Swap, use the same size as ram up to 32GB and above 32GB Ram you don't need more swap. – eckes May 6 at 7:25
  • you do not have 500gb of ram or 1tb of ram (unless you are a visitor from the year 2035), why would you have a 1tb swap partition? – Rabbit May 25 at 12:36
0

NOTE: I will be refering to / partition as /root to make it more clear.

For New Users (Simple Successful Install)

  1. 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.

  2. 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.

  3. 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)
  • Size: min. 10 GB (25+GB recommended. I have 40GB)
  • Type for the new partition: Primary
  • Location for the new partition: Beginning of this space
  • Use as: ext4
  • Mount point: Choose "/"
  • /home (Only needed if you want to keep your personal files separate from / Root partition)
  • Size: Remainder of space on the drive or any size you want.
  • Type for the new partition: Primary
  • Location for the new partition: Beginning of this space
  • Use as: ext4
  • Mount point: Choose "/home"
  • /swap (Only needed if you want to Hibernate)
  • Size: Depends on your RAM. [See Swap FAQ][2].
  • Type for the new partition: Primary
  • Location for the new partition: Beginning of this space
  • Use as: swap
| improve this answer | |
  • Incorrect. swap is nowadays a file. Not a partition. And please don't use / Root , / Swap or / Home. Use / and /swap/ and /home/ to refer to directories. – Rinzwind Jun 22 at 18:56
  • @Rinzwind But you can have a separate swap partition if you prefer? Can't you? Please Edit and make the changes you suggested. My wifi is super slow at the moment and it takes ages to load – Sasuke Uchiha Jun 22 at 19:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.