1
Filesystem      Size  Used Avail Use% Mounted on
udev             63G     0   63G   0% /dev
tmpfs            13G  139M   13G   2% /run
/dev/nvme0n1p2  103G   22G   77G  22% /
tmpfs            63G   76M   63G   1% /dev/shm
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs            63G     0   63G   0% /sys/fs/cgroup
/dev/nvme0n1p1  511M  132K  511M   1% /boot/efi
tmpfs            13G   16K   13G   1% /run/user/117
tmpfs            13G   68K   13G   1% /run/user/1000
/dev/sda1       3.6T   19G  3.4T   1% /media/geert/HDD

The only "usable" space on my SSD is the 103G filesystem mounted on /. (i.e. everything I save or install goes in that filesystem.) What are the udev and tmpfs filesystems doing? Are there steps I can undertake to make my "usable" space larger?

EDIT: here's the output of fdisk -l:

Disk /dev/nvme0n1: 232.9 GiB, 250059350016 bytes, 488397168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 9D9D4041-0C82-47D0-AFD2-C0D29383FE18

Device             Start       End   Sectors   Size Type
/dev/nvme0n1p1      2048   1050623   1048576   512M EFI System
/dev/nvme0n1p2   1050624 220219391 219168768 104.5G Linux filesystem
/dev/nvme0n1p3 220219392 488396799 268177408 127.9G Linux swap

The problem seems to be that the swap space is huge. My RAM is 128G, is it (a) possible (desirable?) to reduce the swap space or (b) desirable to put the swap space on the HDD or (c) desirable to move certain system or user files (home folder? or opt which contains some large applications?) to the HDD?

All general advice is welcome.

  • 1
    There are only 2 partitions of you SSD (/dev/nvme0n1) in that listing. Please post the output of sudo fdisk -l – Eugen Rieck Jan 22 '18 at 8:48
2

OK, you set up an enormous swap space using up half you SSD - I suggest you remove or reduce it.

To do so, use swapoff -a to stop using it, then use fdisk or friends to change your partition table to something resembling sane. In a last step adapt /etc/fstab to reflect the new swap settings.

After reboot you can use resize2fs on /dev/nvme0n1p2 to increase the usable size on the file system.

EDIT

For the partitioning, use fdisk /dev/nvme0n1 (or another tool of your choice) after making sure you have switched off swap. Now first remove partition 3, then extend partition 2 to the end of the disk. If your tool has an extend function use this, else just remove the partition and recreate it with exactly the same partition number (2), starting sector (1050624) and the end sector of the original partition 3 (268177408). Save the partition table and reboot.

  • So the swap space being about the same size as the RAM is not important? – Geert Jan 22 '18 at 9:22
  • With 128G RAM I suspect you don't want any swap space, but of course that depends on what you are running – Eugen Rieck Jan 22 '18 at 9:23
  • As of now I am not RAM-bound (maybe I won't ever.) Shall I just set it to 4G or something? I would very much appreciate if you could walk me through the process of repartitoning my drive in some more detail. – Geert Jan 22 '18 at 9:28
  • OK, just drop the swap completely for now. Whenever you get RAM-bound there will be better options. I'll edit the question for the fdisk part – Eugen Rieck Jan 22 '18 at 9:31
  • What are the better options when I become RAM bound? It's not likely, but it could be next week (I just started out as a researcher so not yet sure what will be the bottlenecks.) – Geert Jan 22 '18 at 9:42
0

I would start with Eugen's advice to remove the swap from the SSD entirely, because you likely have enough RAM to not need swap. If in fact you do need a bunch of swap for your calculations, you can add it later from your large media drive. You don't even need to re-partition, since Linux can swap to files as well as partitions. (partitions are more efficient though)

# create a giant file
dd if=/dev/zero of=/media/geert/HDD/swap bs=1G count=128

# make sure only root can read it or move it
chmod 700 /media/geert/HDD/swap
chmod go-w /media/geert/HDD # just guessing here

# with new enough tools, swapon can act on the file directly
# else you need to create a loopback device on it first
mkswap /media/geert/HDD/swap
swapon /media/geert/HDD/swap

# Add it to /etc/fstab so that it activates on startup
echo "/media/geert/HDD/swap none swap sw,auto 0 0" >> /etc/fstab

Swap is just "slow but cheap RAM" for people who need it. If you have more RAM than you need, there is no need for any swap. I have run numerous servers with no swap at all and it is not a problem. I have even run desktop systems with modest RAM with no swap in order to avoid the lag caused by a large webpage suddenly evicting all my apps and bogging down my system. I'd rather see the browser tab crash (killed by Linux OOM) immediately than wait around for 5 minutes while my system grinds to a halt and eventually decides to kill that browser tab anyway.

The "rule of thumb" about having swap size match your ram size is for things like suspend-to-disk. So, laptops (or even desktops) need to maintain that practice if they want that feature. It was also a recommendation for servers on the assumption that you have a server with an economical quantity of RAM as needed for the work load, and tons of inexpensive disk. If a bunch of users decide to run their tasks all at once the swap will keep them from getting killed off... but leave the server pretty laggy until they're done.

Also, I think you realized already, but anything in the "df" listing that doesn't mention a disk partition in the left column is just a virtual filesystem that is either stored in RAM or being generated on demand. They don't occupy any of your disk.

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.