8 ms·
this is unlikely to hurt you unless you use a swap file, rather than a dedicated swap partition. for performance reasons most any modern linux installation wou
by walrus01 6y ago
this is unlikely to hurt you unless you use a swap file, rather than a dedicated swap partition.
for performance reasons most any modern linux installation would be using a dedicated swap partition, that is defined as swap-only during the install process with mkswap
In my experience some of the reasons for using a swap file were more common maybe 10 or 15 years ago. Nowadays with disk space being less costly and rare, and systems having a lot more RAM (so the likelihood of going deep into swap is less), it's unsurprising that none of the testers encountered it.
https://man7.org/linux/man-pages/man8/mkswap.8.html https://man7.org/linux/man-pages/man8/mkswap.8.html
- ylyn 6y agoSwapfiles are quite common when you use FDE (say, LUKS) and you don't want your swap to be in plaintext on disk. (Although, you could just have an entire LUKS-encrypted swap volume instead of a swapfile...)
- walrus01 6y agomost people I know who are paranoid to really go into the details of a FDE linux desktop/workstation environment choose to have no swap file, and at minimum 64GB of RAM. even safer if the swap doesn't exist.
- dathinab 6y agoWhile maybe not the most performant my favorite is LVM2 on top of a single large LUKS-encrypted partition (+no boot partition and a single (custom platform key) signed EFI bootable kernel blob containing the initram fs in the EFI partition). This: - Allows a encrypted swap partition (on in lvm2 on top of luks, sure not perfect but I don't really use swap) - Allows hibernation (which I don't really use tbh.) - Fully encrypted disc - Fast boot (compared to e.g. encrypted grub, at least last time I checked) - Easy resizing of partitions on demand - Which in turn makes it easier to use more partitions (for /, /home, etc.), which is necessary for taking advantage of certain mount flags like noexec for security. Anyway I think the reason Ubuntu uses a swap file is because it means you don't need to resize a partition when "upgrading" your RAM or similar (for hibernation to work). Through tbh. they should make the choice in the installer dependent of the hardware.
- pdonis 6y agoWould the bug Linus is describing still bite you if your swap is in a separate LVM partition? (That's how Ubuntu 20.04 sets things up by default.)
- _-___________-_ 6y agoOnly if it's a swap file on a filesystem on that LVM partition, and even then if the filesystem is otherwise empty then there's no other data to accidentally overwrite, you might just trash the filesystem structure.
- pdonis 6y agoThen, if I'm understanding this correctly, the default setup in Ubuntu (at least in Ubuntu 20.04, which I happen to have installed on a couple of laptops recently), which has been mentioned both in this discussion and in the lwn.net article discussion, should be safe from the bug, since that setup, if you enable full-disk encryption, sets up two LVM partitions, one for root (called "vgubuntu-root") and one for swap (called "vgubuntu-swap"). They show up as separate LVM partitions in fdisk. The swap appears to me to just directly use the "vgubuntu-swap" partition.
- _-___________-_ 6y agoSounds fine. It would be strange if vgubuntu-swap contained an actual filesystem with a single file on it (the swap file).
- encryptluks2 6y agoYou still need an unencrypted EFI partition given what you describe, and the signed unified kernel image lives there, which means that you do in fact have a boot partition. My /boot mount is my EFI partition. However, an alternative is having your EFI partition reside on a USB drive that in turn boots into your encrypted partition.
- 6y ago
- gwd 6y agoIn the most recent Debian installer, if you want to do FDE, it does: partition > LUKS > LVM > swap volume That way you get encrypted swap without having swap be a file in your filesystem.
- tremon 6y agoEven with full-disk encryption you have two options that I'd recommend over a swap file: - lvm on luks: inside the luks dm-crypt container, create multiple logical volumes: one for swap, one for the root filesystem - swap on dm-crypt: create a separate encrypted partition for swap Since the swap data needs no permanence, it's possible to generate a new encryption key every boot. Debian's crypttab supports this out of the box [0]: cswap /dev/sda6 /dev/urandom cipher=aes-xts-plain64,size=256,hash=sha1,swap (although I'd recommend using a /dev/disk/by-id/ path there, for obvious reasons. The scripts do check there's no valid signature on the partition before formatting, but still...) [0] https://manpages.debian.org/buster/cryptsetup-run/crypttab.5.en.html#EXAMPLES https://manpages.debian.org/buster/cryptsetup-run/crypttab.5...
- yrro 6y ago> Since the swap data needs no permanence Unless you want to hibernate!
- pseudalopex 6y agoI thought partitions used to be faster but files are just as fast now.[1] [1] http://lkml.iu.edu/hypermail/linux/kernel/0507.0/1690.html http://lkml.iu.edu/hypermail/linux/kernel/0507.0/1690.html
- lathiat 6y agoUbuntu uses a swap file by default since 17.04 Zesty: https://blog.surgut.co.uk/2016/12/swapfiles-by-default-in-ubuntu.html https://blog.surgut.co.uk/2016/12/swapfiles-by-default-in-ub... But as otherwise discussed this only made it into a release candidate and not an actual release. So the impact is minimal.
- mmis1000 6y agoIf you are using budget vps, it is likely you will want to enable it. Because vps tend to not setup a swap partition at all. And you are unlikly to reformat a vps to add a swap partition.
- megous 6y agoOr use zswap on budget VPS.
- bombcar 6y agoI use swap files on all my VPS, even the ones that give me a swap partition - space is cheap as free and it's easy to set a monitor that says "oh wow we're starting to use swap significantly, something's wrong" instead of a "the box OOMKILLed everything, something's wrong". In fact that just happened - no service died but something used a lot of RAM at midnight - investigating now.