Partitioning for average end user.

21 replies [Last post]
alank
Offline
Joined: 12/02/2018

Hello,

I'd like to hear your thought whether or not partitioning is necessary for your average internet dwelling hooman. I have a 500GB HD, 4GB of RAM. How many partitions would I need. Should I just have 1 for root, 1 for /home. Using MBR that would ofc be 2 primary partitions, right?

loldier
Offline
Joined: 02/17/2016

The average user only needs one partition to avoid the root partition overfilling. But if you are in the habit of reinstalling and want to keep old data, a separate home partition would be nice to have. MBR choice depends on your hardware and firmware. BIOS boot expects MBR, UEFI can use GUID GPT. Use MBR if you have a disk 2 TB or less. MBR supports four primary partitions.

I use two partitions, root and home, no swap.

nadebula.1984
Offline
Joined: 05/01/2018

Here's my partitioning schemes:

MBR partition table, BIOS/Legacy boot firmware:
/, /boot, /home, swap

GPT partition table, BIOS/Legacy boot firmeare:
bios boot, /, /boot, /home, swap

GPT partition table, UEFI boot firmware:
/boot/efi, /, /boot, /home, swap

So 4 or 5 partitions are more than enough for "average users".

Cyberhawk

I am a translator!

Offline
Joined: 07/27/2010

With 4GB of RAM I'd suggest having a swap partition. Just in case, who knows how many applications will be running at some point all at once.

So, if the computer supports using MBR, this is my suggested partition scheme:

/ ext4 60GB
/swap 2xRAM size = 8GB
/home ext4 all the rest = about 425GB

This way you have a huge root partition, you will probably never run out of space, even after installing every application that is remotely interesting to you. You also have twice as much swap as RAM, so you are never likely to run out of that too. And you still have way over 400GB for home, which is huge imho. If you want to store lots of videos in HD, you will need an extra drive anyway.

Magic Banana

I am a member!

I am a translator!

Offline
Joined: 07/24/2010

Twice the RAM for the swap is a lot. If your system swaps because it ran out of RAM, it is unbearably slow (because the disk is about 100 times slower than the RAM) and you will not wait for that much swap to be filled before saving your work and closing applications. Nowadays, having as much swap as RAM is already a lot, unless you want to hibernate (in which case, it is kind of necessary because hibernating basically is zipping the content of the main memory and storing it on the swap partition).

60 GB for / is a lot too. Nevertheless, that depends on what you plan to install. In particular, some video games require a lot of disk space. For those who do install heavy games, I would advise 32 GB to be at ease, what is already much more than what the default install does (14 GB if I remember well: too little in my humble opinion).

The rest of the disk for /home: for a desktop usage, I only see drawbacks (having a partition full, while another one was oversized) in further partitioning the disk.

nadebula.1984
Offline
Joined: 05/01/2018

Regarding "the rest of the disk for /home", I don't see so many drawbacks. Most "average users" are highly unlikely to re-partition their HDD/SSD. They tend to accept and keep whatever they are provided.

Magic Banana

I am a member!

I am a translator!

Offline
Joined: 07/24/2010

I apparently have not expressed myself clearly: I meant "I only see drawbacks in having the file hierarchy on more than two partitions (/ and /home)".

I actually have /tmp on a tmpfs filesystem (i.e., in RAM) and that is useful for my work (I often deal with large temporary files I make with 'mktmp'). Nevertheless, for a regular desktop user, the performance gain will never be noticeable and she may run out of RAM if she does not have as much RAM as I (16 GB) and uses, for instance, Popcorn Time, which downloads movies into /tmp.

alank
Offline
Joined: 12/02/2018

Well thank you all for your responses. I think I'm gonna go with /root, /home and /swap. Just because why not, right? There aren't any negatives to having partitions (assuming that they are done correctly). I think hehe.

Magic Banana

I am a member!

I am a translator!

Offline
Joined: 07/24/2010

Why do you want to put root's file on a separate partition? You will probably never have a lot in /root anyway. In fact, users of distribution that rely on 'sudo' (including Trisquel) usually do not write anything in /root.

The swap partition is not mounted, i.e., it is not attached to the file hierarchy. There is no such thing as /swap unless you create it... and, indeed, it is possible to have a swap file instead of (or in addition to) a swap partition. However only swap *partition* allow you to hibernate the system.

The drawback of having more partitions is that you more easily end up with a full partition, when another partition still has a lot of space available. You then need to repartition. And, depending on the filesystems you chose, it may not be that easy: XFS cannot be shrunk; JFS cannot be resized at all, etc.

loldier
Offline
Joined: 02/17/2016

I think he means '/', not the superuser directory 'root'. / that we call root has no name.

strypey
Offline
Joined: 05/14/2015

I've spent a lot of time in the past cleaning up the messes of people's borked Windows systems. By default, Windows PCs always have the OS and user files in the same partition, so when the OS dies, as it inevitably does, you have to painstakingly back up all the users files onto a sufficiently large external drive before you can do a reinstall, or install a new OS.

Learning from this experience, I always advise people to have separate partitions for / and /home. This means you can easily reinstall your OS, or switch to a different distro, without having to copy the entire contents of your primary drive to another drive first and re-partition from scratch (note: it's wise to do a fresh backup of anything mission critical before making any such changes to do your drive). I find a 16GB partition for / is usually enough (anything larger than 30GB is really a waste of space).

On my systems, I always have a second primary partition the same size, which I use for testing new versions or distros that I'm thinking about using, or just curious about. At present I have two swap partitions the same size as RAM, one to go with each primary partition, but from now I will just use one, for reasons Magic Banana has explained in previous thread on this topic.

strypey
Offline
Joined: 05/14/2015

Since I posted my last comment in this thread, I replaced the HDD in my laptop with an SSD and maxed out the RAM at 2GB. Just recently I bought a more powerful laptop which I also had an SSD installed into, and maxed out the RAM at 4GB. I've been doing some reading to see whether or not it's a good idea to use a swap partition on SSDs and opinions are mixed. Here's a good example of this debate:
https://askubuntu.com/questions/404096/with-an-ssd-do-i-need-to-change-my-swappiness-to-increase-ssd-life

Some comments suggest that less damage is done to the SSD if swapping is discouraged by reducing swapiness (see: https://www.howtoforge.com/tutorial/linux-swappiness/ ) and that a swap partitions does more damage to the SSD than a partition with a file system because they can use TRIM. Others say that recent SSDs are much more durable than the early ones and none of this matters.

Either way, with the newer laptop, 4-8GB seems like a lot of space to reserve entirely for a swap partition. So I've been reading about setting a swap file on the root partition instead. Here's some instructions I found:
https://www.maketecheasier.com/create-swap-file-linux/

When following these, the command:
# swapon -a

... threw an error about "insecure permissions 0644, 0600 suggested."

A solution to this is described here:
https://www.rootusers.com/managing-swap-space-in-linux/

If anyone knows of more reliable references for these topics, or even better, pages on the Trisquel wiki, please share links here.

strypey
Offline
Joined: 05/14/2015

Some quick updates on my swap experiences. I reinstalled Flidas with no swap partition on Vision (the 4GB RAM laptop). I tried creating a swap file, but kept running into "invalid argument" errors when I tried to "swapon -a", following the instructions in the pages I linked in my previous comment. I had the same issue on Bishop, my older 32-bit laptop with 2GB RAM.

I did an experiment on Vision, doing everything I could think of to use up RAM; two music websites playing songs, two PeerTube videos playing, another video playing on VLC, and other programs open including GIMP, LibreOffice, and Transmission. With all that running I was topping out the CPU and the second PeerTube video was getting choppy but I'd only used 75% of my RAM according to the Mate System Monitor. So it's pretty clear I don't need swap space reserved on Vision unless, as MagicBanana always says, I want to hibernate the system.

It might be good to have a 2-4GB swap file on the root partition of Bishop. But when I checked the Mate System Monitor is seems the swap partition hadn't been activated during install, even though I had manually set it as swap space during the install. Maybe the installer detected my SSD and is configured not to use swap partitions on them? I deleted the swap partition using GParted and rebooted, and I haven't noticed any performance issues without it, so maybe I don't need swap on Bishop either?

Magic Banana

I am a member!

I am a translator!

Offline
Joined: 07/24/2010

If a buggy application leaks memory (probably in uncommon conditions), it may end up requiring more RAM than available. Without any swap, the OOM killer (a component of Linux) will choose a process and kill it to free some memory. If it chooses a program you are working with (not necessarily the buggy one, by the way) and you have not saved your work for some time, you may not like it. With some swap (you do not need a lot), the system will become slow, because the disk, where the swap is, is much slower than the RAM (maybe ~50 times slower if the disk is SSD). If you are sitting in front of the computer, you will notice it, have the time to save your work and choose by yourself what process to terminate (maybe after taking a look at the system monitor to identify which one uses more memory than it should). That is why I would recommend some swap.

strypey
Offline
Joined: 05/14/2015

Further update, I've noticed that Bishop (my 32-bit system with the 2GB RAM)is freezing up after it's been left unattended for some time. I'm guessing that the Power Management system is hibernating it and now that I've deleted my swap partition, that's not working. So I definitely need a swap file on Bishop.

Last time I tried to create one though, I couldn't figure out how to make it work. Today, I think I got it right. Here's what I did in my terminal.

# sudo fallocate -l 2G /mnt/2GB.swap

# sudo mkswap /mnt/2GB.swap

Output:
Setting up swapspace version 1, size = 2 GiB (2147479552 bytes)
no label, UUID=d6104677-6cd1-4801-8cd6-efb6074963e7

# sudo swapon /mnt/2GB.swap

Output:
swapon: /mnt/2GB.swap: insecure permissions 0644, 0600 suggested.

# sudo chmod 600 /mnt/2GB.swap

# sudo swapon /mnt/2GB.swap

Output:
swapon: /mnt/2GB.swap: swapon failed: Device or resource busy

# sudo swapoff -a

Output:
swapoff: cannot find the device for UUID=b0f783b0-d459-4ef4-b863-ea1141302763

# sudo swapon /mnt/2GB.swap

# swapon -s

Output:
Filename Type Size Used Priority
/mnt/2GB.swap file 2097148 0 -2

Then I edited /etc/fstab, commented out the line under the comment about the swap partition added during installation (now deleted), and added this line to the end:
/mnt/1GB.swap none swap sw 0 0

Now to reboot, and see if it works. Wish me luck!

strypey
Offline
Joined: 05/14/2015

That seems to have worked for Bishop. I haven't left it alone long enough to suspend or hibernate yet. But where it used to say "Swap not available" in Mate System Monitor, it now shows 2GB of available swap space, with a few hundred KB used, and the system feels a bit less sluggish.

So I'm trying the same thing on Vision (my 64-bit system with 4GB RAM) but it's not working. The only thing I did different was to do the "chmod" command before doing the "swapon" command. But now swapon throws an error saying:
"swapon failed: Invalid argument"

When I used rm to delete the swap file, rebooted, and tried again following exactly the steps that worked on Bishop, I get both the "insecure permissions" error *and* the "invalid arguments" error.

Can anyone tell me what I'm doing wrong here?

Magic Banana

I am a member!

I am a translator!

Offline
Joined: 07/24/2010

I believe your system tries to suspend, using the RAM, not the swap. A swap *file* does not support hibernation: a swap *partition* is needed. It can be graphically created with GParted, e.g., using Trisquel's live system.

strypey
Offline
Joined: 05/14/2015

Magic banana"
> A swap *file* does not support hibernation: a swap *partition* is needed.

I believe this is incorrect, for two reasons. One, when I allowed both Trisquel 8 and PureOS 8.0 to partition automatically during install, neither of them set up a swap partition. It seems unlikely to me that the default configuration would be one that results in the system crashing every time it tries to hibernate. Also, see:
https://wiki.debian.org/Hibernation/Hibernate_Without_Swap_Partition

Magic Banana

I am a member!

I am a translator!

Offline
Joined: 07/24/2010

That wiki page says:
Now use uswsusp which is an alternate suspend method for the linux kernel that can use a swap file instead of a swap partition

I was talking about Linux's native hibernation. But, sure, uswsusp is a solution. Notice however that its development stopped more than eight years ago:
The development of s2ram is not going to be continued after this release and whitelist entries are no longer accepted.
http://suspend.sourceforge.net

strypey
Offline
Joined: 05/14/2015

Good to know. But what about the fact that the default partitioning scheme did not include a swap partition when I installed both Trisquel 8 and PureOS 8 on the internal SSD of Vision (my 64-bit system)?

Magic Banana

I am a member!

I am a translator!

Offline
Joined: 07/24/2010

That is news to me (I always manually partition the disk, through the "Something else" type of installation). Just a guess: swap on an older SSD may be a bad idea (reduced life time), but not a real problem on a newer one. If you find out the rationale for the default, please tell it here.

strypey
Offline
Joined: 05/14/2015

A quick update, I haven't had the system freeze with a blank screen again since I set up the swap file, even though I've been leaving it unattended for a few hours at a time. The plural of anecdote is not data, but this does seem to support my contention that Trisquel is able to hibernate to and resume from a swap file (maybe only on SSDs?).

Magic banana:
> If you find out the rationale for the default [partition scheme in Trisquel installer], please tell it here.

Willdo, although anyone from the Trisquel dev team could share this with us if they have time.