1

My root partition is reaching its limits which is annoying since most package managers install packages somewhere on my root partition.

I have to fix this in some way but I'm not really sure what the best approach is. I could reformat some partitions into a bigger root partition. I think I have two option to do this, I could:

  • delete nvme0n1p2 ([SWAP]) and merge it with nvme0n1p3(/)
  • split nvme0n1p4

However merging nvme0n1p2 and nvme0n1p3 would cause losing my SWAP partition (which I do occasionally use if my RAM runs out). However I don't use it often, so I could spit sdb (an old SSD) and use part of it for SWAP.

Splitting nvme0n1p4 would require copying a lot of data to and from sda (an old and slow HDD).

While I was writing this I was wondering if it was an option as well to move my default install location of pacman (I'm running Manjaro) to nvme0n1p4 which would probably solve a lot of space problems as well.

However I'm not experienced enough to see what potential problems this would cause to my system.

I know I didn't ask a specific question yet. So I guess my questions are:

  • What is the most durable solution to my space problem that is least likely to break my system.
  • Did I miss a good alternate solution to my problem?
$ lsblk
NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda           8:0    0 931,5G  0 disk 
└─sda1        8:1    0 931,5G  0 part /mnt/data
sdb           8:16   0 111,8G  0 disk 
└─sdb1        8:17   0 111,8G  0 part /opt
nvme0n1     259:0    0 931,5G  0 disk 
├─nvme0n1p1 259:1    0   300M  0 part /boot/efi
├─nvme0n1p2 259:2    0    16G  0 part [SWAP]
├─nvme0n1p3 259:3    0    32G  0 part /
└─nvme0n1p4 259:4    0 883,2G  0 part /mnt/nvme0n1p4

$ df
Filesystem      Size  Used Avail Use% Mounted on
dev              16G     0   16G   0% /dev
run              16G  1,7M   16G   1% /run
/dev/nvme0n1p3   32G   30G  503M  99% /
tmpfs            16G  498M   16G   4% /dev/shm
tmpfs           4,0M     0  4,0M   0% /sys/fs/cgroup
tmpfs            16G   53M   16G   1% /tmp
/dev/sdb1       110G   26G   79G  25% /opt
/dev/nvme0n1p4  869G  419G  406G  51% /mnt/nvme0n1p4
/dev/nvme0n1p1  300M  312K  300M   1% /boot/efi
/dev/sda1       916G  113G  757G  13% /mnt/data
tmpfs           3,2G   60K  3,2G   1% /run/user/1000

7
  • 1
    Resizing nvme0n1p4 and adding the freed space to nvme0n1p3 is the easiest option. You need to boot from USB if you want to use gparted.
    – Freddy
    Feb 15, 2021 at 0:10
  • I'm I correct in thinking that I would have to backup both nvme0n1p3 and nvme0n1p4 since both will be erased in the process?
    – Jonas
    Feb 15, 2021 at 0:13
  • 1
    No, they won't be erased (unless you delete the partitions). Resizing does not touch your data. But you should backup your (important) data as always.
    – Freddy
    Feb 15, 2021 at 0:21
  • Thnx, I will take a look at gparted then
    – Jonas
    Feb 15, 2021 at 0:23
  • 1
    What is taking all the space in /? My root is about 9GB with all data normally in /home in a data partition and I houseclean regularly. I also do not use snaps which are somewhat larger. But 30Gb should normally be plenty unless running a lot of server apps with data in /. What does this show, then drill down in largest. sudo du -hx --max-depth=1 / 2> /dev/null
    – oldfred
    Feb 15, 2021 at 3:38

1 Answer 1

1

One simple solution would be to remove your swap, by "merging" your / and /swap partition (more like removing your nvme0n1p2 and extend your nvme0n1p3), then finally create a swap file there.

Now, if you want to create a swap file only using a GUI, you can use gnome-disks, step by step:

  1. Click on gnome-disks' top-left drive icon.
  2. Create a New Disk Image...
  3. Set the size you want for your swap file, its name and where you want to put it, then click on Attach new Image....
  4. gnome-disks should now get you right away on the newly created swap file section, which should be identified as xx GB Loop Device. Then, just click on the "Wheels" button.
  5. Go on Format Partition...
  6. Give your swap partiton a label (e.g. "swap0").
  7. Check the Erase witch (makes the swap contiguous on the drive, for better performance) on.
  8. Choose other as the partition Type.
  9. Click on Next.
  10. Choose Linux Swap Partiton.
  11. Then, Next again.
  12. And, Format, which will take some time.
  13. Now, click on the "Wheels" button again.
  14. Go this time on Edit mount options...
  15. Disable the User Session Defaults switch.
  16. Just make sure that Mount at system startup is checked, Show in user interface in unchecked and that Identify As is set on /dev/disk/by-uuid/xxx, just to be sure.
  17. Then press OK.
  18. And finally, click on the "Play" button to mount it, and you're done !

Using a fully dedicated swap partition is less and less needed since a long time.

Also, I don't know how many GBs of RAM AND VRAM you have, but 16GB of swap is really huge. If you're really not using that much swap, you should decrease that amount.

Now here's a trick: If you still want to use that much of swap space but only do from time to time, you could make a small swap file first of let's say 2GB to 4GB, then create the second one when you really need it on / or simply put it somewhere else (e.g. your sda1/mnt/data) with much more free space to make it available at all times.


Few things to consider:

A. Please note that you really should not put swaps on an SSD or any flash-based drive since it will really decrease it's lifespan, since swaps are "fake RAM" after all (RAM are made to whitstand a lot more I/O than any storage drives), and that a smaller SSD (typically under 400GB or even under 1025GB ones) has a lower life-span than their bigger counterparts due to smaller over-provisionning.

I mean, look at how much GBs you do write per week, simply just web browsing, streaming and watching Youtube videos writes a lot (caching). It's very easy to reach 250GBs of writes a week, even for a granny. Now add the fact that you're likely a power-user (well you do as a data science student, so this means it's one of the worse cases) and that modern smaller SSDs are only granted a mere 100TBs of writes before the warranty is void (yes, void, do check the products' datasheets), and you'll quickly reach those 100TBs even before you reach the "years-based warranty".

So, do consider making your swaps on either spinning disks, or throwaway flash storages (USB keys, memory cards, etc) as long as it's not USB 1.x-based or maybe 2.x if you really need them to still be very fast since that's mostly not the raw GB/s that mostly makes flash-based drives fast, but the drive cells' access times.

B. Depending on what drives you put your swaps and how you fragment them (e.g. one swap file per drive, etc), you can even end up with a faster swap than you ever had.

C. You can even hibernate with a swap file: https://askubuntu.com/a/892410

D. gnome-disks is a very powerful yet straighforward tool, which can check your drive's status (temperature, lifespan, bad sectors, etc), set some drives settings (caching, standby times, etc), etc but also cleanly unmount, eject and then power off your devices (drives, usb keys, etc) better than no other GUI tools.

3
  • Hey X.Link. Thank for your answer. I think I will try the solution with gparted that Freddy suggested in the comments first, since it doesn't merging my swap and /. Thnx for your remarks about using SSD's for swap. I wasn't aware of the effects on it's lifespan. 16 GB might be a lot, however I hardly use it since I've got 32 GB RAM. However, I'm a data science student, and sometimes i do use more then 32 GB RAM for some computations. I will buy more RAM when my bank account allows for it, but for now I'm happy that I can occasionally use my SWAP :)
    – Jonas
    Feb 15, 2021 at 8:38
  • 1
    My bad, by "merging" I wanted to say: "remove your /swap partition and use the remaining space to extend your / one, then create a swap file there", the same procedure of what Freddy suggested with Gparted is used, but using nvme0n1p2 instead of nvme0n1p4. By the way, I've just noticed that you only have 32GB for /, which is just too small for a desktop Linux where 50GB should be the minimum especially if you consider distro upgrade (e.g. Ubuntu 20.04 to 22.04, Debian 10 to 11, etc.) and that you do have RAM and space hoggers like Electron-based softwares (e.g Atom and Discord).
    – X.LINK
    Feb 16, 2021 at 2:48
  • No problem. I already appreciated your answer how it was, and now that you edited I accepted it. You really have a point when you mention that I can just create swap if I need it. I'm not an admin, just a Linux user so I'm not somebody who routinely re-formats disks all the time. But I think it is worth doing more often. Thnx for your input!
    – Jonas
    Feb 16, 2021 at 8:14

You must log in to answer this question.

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