It’s a silly issue that I can live with, but it’d be nice if it could be solved. My system always briefly hangs on the swap file when booting.
Is it simply a hardware limitation? It’s a 20GB file on a SATA SSD.
Is there any configuration that’d allow the system to proceed booting while the swap is being mounted? I only ever need it long after it’s fully booted, when actively using RAM-hungry software. The swap is never touched otherwise.
It’s the top @ systemd-analyze blame
43.053s run-media-camila-Apps-swapfile.swap
systemd-analyze critical-chain
The time when unit became active or started is printed after the "@" character.
The time the unit took to start is printed after the "+" character.
graphical.target @48.335s
└─multi-user.target @48.335s
└─cron.service @48.335s
└─postfix.service @47.509s +824ms
└─time-sync.target @47.503s
└─chronyd.service @47.303s +199ms
└─network.target @47.292s
└─NetworkManager.service @46.696s +595ms
└─network-pre.target @46.692s
└─wpa_supplicant.service @47.339s +99ms
└─basic.target @45.904s
└─dbus-broker.service @45.815s +84ms
└─dbus.socket @45.813s
└─sysinit.target @45.809s
└─auditd.service @45.680s +128ms
└─systemd-tmpfiles-setup.service @45.566s +54ms
└─local-fs.target @45.560s
└─tmp.mount @45.541s +18ms
└─swap.target @45.539s
└─run-media-camila-Apps-swapfile.swap @2.486s +43.053s
└─run-media-camila-Apps.mount @2.360s +123ms
└─dev-sdb1.device
Swap file on an additional device? Such as USB flash drive?
Question is about how system mounts this device.
It is possible to boot without swap and then add it with script.
I’d suggest to add SSD drive and use swap partition on it.
If you can dedicate space for a swap file, then the same can be done with the creation of a swap partition - a much preferred solution | option.
FYI - swap files are notoriously resource intensive with respect to the CPU and “file read | write” (and why the thread )
And wow … it’s a 20 gb swap file? The laptop I’m on now only has a 1 gb swap partition (16 gb RAM) … a desktop we have has a 500 MB swap (it has 64 gb RAM).
No, it’s on a 2.5" SATA SSD connected directly to the mobo. Both the partition containing it and swap file are mounted automatically using fstab.
Like I said, I can’t use a partition.
So it being a file is the reason behind the sluggish boot?
Sometimes I work with very large files. I’d get more than a full freeze requiring a reset per day before setting up a generous swap file, with oomkiller as a last resort to not freeze. Now it runs fine, but the swap takes 40s out of a ~43s boot time to mount.
I’m low on storage space. I’m using a file because sometimes I have to disable it or setup the swap somewhere else to temporarily use the space for something else. My M.2 died and I’m waiting a replacement come back into stock for reasonable prices. Most reliable SSDs models are out of stock since Black Friday or priced over $200 when they normally go for $90 and trust me, I’m not happy about it.
To OP: you can combine - 2 GB for swap partition + 18-20 GB as a file. Set priorities according to your needs.
And DDR4 8 + 16 GiB? It is better to use equal modules.
Wouldn’t I still have the exact slowness at boot? I don’t want to mount the file manually.
I’m aware. That’s if you’re overclocking or doing XMP. I’m doing neither and I have RAM quantity issue, not a speed issue, so throwing money at 10yo RAM modules that cost as much as they originally did just so they match sounds foolish.
It is cheap indeed, but I’ll have to hunt for a reliable seller because most offers I’m seeing are from China.
I have also to read more about it, I never used NVME memory, no idea if it’s compatible with my system or even how this one works. Does it get added to the RAM pool or is it like storage?
My system is due an upgrade and one of the things I’ve been thinking about is buying an inexpensive 128-256GB QLC SSD to use as swap and scratch. I’m counting on it being large enough it won’t fill to the point it being a QLC would slow it down.
Please don’t mix Optane NVMe with Optane DIMM (Intel Optane DC Persistent Memory).
You can use Optane NVMe with 16/32/64 GB capacity. For OS it looks as a storage (NVMe SSD drive).
It’s an ExFAT partition, the one I use to throw files to Windows. I only log into Windows once in a blue moon now to use programs that won’t run on Wine, so I ran a manual trim on it just in case. No changes in boot speed.
I also temporarily shrunk that partition, created a swap one and a swap file of the same size to compare performance. The partition seems to mount 4x times faster. Dammit.
The swap size unsurprisingly also has a huge impact on mount time. If I want to solve the issue asap I think I’ll have to proceed with the SDD for scratch and swap plan; in the long run I’ll get more RAM when updating the PC build so a swap this large shouldn’t be necessary in first place.
@ciello … good to read you did some quick testing - always good to have some concrete comparisons.
By pure accident, I came across an article from Mar 2021 at “lwn.net”. It was written by Linus (do I have to mention his last name? ) … it’s about “swap files stopped working”.
Here’s a couple of paragraphs written by Linus, quoted:
"Now, the good news is even if you do use swap (and hey, that’s nowhere
near as common as it used to be), most people don’t use a swap file,
but a separate swap partition. And the bug in question really only
happens for when you have a regular filesystem, and put a file on it
as a swap.
And, as far as I know, all the normal distributions set things up with
swap partitions, not files, because honestly, swapfiles tend to be slower and have various other complexity issues."
Hah, now I’m glad the swap file is quarantined in a different drive!
Sometimes people overplay the performance impact of something. This is not one of these cases. For anyone in the future with a weird setup like mine that stumbles upon this thread in search of an answer: Your boot is slow because the swap is large and/or because it’s a file.
Yea, I’ve been looking for a definitive answer on that, but nothing proof positive. I did find the question at an Ubuntu forum, and a couple folks said “don’t”.
My Brave browser offers AI answers when doing a search, which results in this output:
----Quoting the AI answer
No, you cannot create a swap file on an exFAT filesystem in Linux; exFAT is not designed for swap functionality and the Linux kernel does not support using it as swap space, meaning you cannot utilize a file on an exFAT partition as a swap file. (&)
Key points to remember:
Swap file requirements:
A swap file needs a file system that allows for efficient read/write operations, which exFAT is not optimized for. (&)
Linux swap support:
Linux primarily supports creating swap files on native file systems like ext4, XFS, etc. (&)
----end quote
There is a link associated with each paragraph detail (I used (&) to designate the links … however, when I click the first link, it’s not clear where the answer came from.
It should also be known, I’m not convinced yet about “AI answers”