41

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.

10
  • @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.
    – VidathD
    May 3, 2020 at 16:42
  • @user535733 I would like to set up a dual boot. If I stick to defaults as you suggest, is 30GB enough for the root partition. Also, Ubuntu doesn't give me the option to install alongside windows. So will create just "/" partition with 30GB in something else option and continuing do it?
    – VidathD
    May 3, 2020 at 16:53
  • @user535733 Ok, thanks. But I seem to have tried everything suggested in those questions. Can you help me? Chat?
    – VidathD
    May 3, 2020 at 16:58
  • 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, 2020 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. May 4, 2020 at 12:07

5 Answers 5

55

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

15
  • So if I am not creating a separate /home partition what should be the size of the root partition?
    – VidathD
    May 3, 2020 at 16:34
  • 5
    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. May 4, 2020 at 11:16
  • 1
    @SyferPolski edited to address your comment.
    – user535733
    May 4, 2020 at 11:46
  • 3
    @SasukeUchiha, If you are not having a separate /home , /usr or /var, just make the /root the entire disk.
    – Lenne
    May 5, 2020 at 8:38
  • 7
    @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. May 5, 2020 at 18:02
12

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

8
  • 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? May 4, 2020 at 21:28
  • @CaptainMan Exactly. That's what's making me so confused? Where does Windows save the files when hibernating anyway?
    – VidathD
    May 5, 2020 at 2:59
  • Windows has a hibernate hidden system file on the system partition (c:\hiberfil.sys).
    – eckes
    May 5, 2020 at 5:10
  • 1
    @eckes And why can't Ubuntu have something similar?
    – VidathD
    May 5, 2020 at 12:55
  • @SasukeUchiha As written above, swap may be a file instead of a partition May 5, 2020 at 13:08
10

NOTE: I will be referring 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

Workaround for hibernation using the swapfile: How to hibernate with swapfile.

3
  • 4
    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, 2020 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
    – VidathD
    Jun 22, 2020 at 19:01
  • The advice for experienced users should be to use LVM and initially allocate only what is needed, leaving most of the Physical Volume unallocated. Even the root partition works as a Logical Volume without any problems in current grub. When a filesystem tends to get full or the need for a new separate filesystem arises, one can add or online-extend LVs without the hassle of moving partitions or even reinstalling. The drawback is that installer LVM support is bad so it's only available for experienced users.
    – Juergen
    Jul 14, 2020 at 10:09
4

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.

5
  • 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, 2020 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.
    – VidathD
    May 5, 2020 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, 2020 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, 2020 at 14:53
  • 1
    @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, 2020 at 16:52
4

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

6
  • 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.
    – VidathD
    May 3, 2020 at 16:56
  • @SasukeUchiha then you won't need a /home partition. Using defaults should be fine as @user535733 mentioned.
    – Mido
    May 3, 2020 at 17:02
  • @SasukeUchiha Suspend has never used swap, you're thinking of hibernate
    – Izkata
    May 4, 2020 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, 2020 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, 2020 at 12:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .