Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

swap files make setting up hibernation a bit more complicated - in most cases the file has to be contiguous, e.g. you have to defragment it once after allocating. Then, you need to tell the bootloader the byte offset of the file on the partition.


Does contiguousness matter these days? Especially since all disk locations are lies anyway as SSD firmware has its own layer of indirection too?


In this case, IIUC the swap-restore mechanism just can’t use fragmented files because it runs before filesystem drivers can do their work. So it just gets an offset and probably derives the length from a header stored there, using raw disk accesses to thaw the RAM contents.

In general terms though, I hear disk fragmentation still makes a difference, f.ex. because disk page sizes don‘t match filesystem extent sizes, and disk optimizations like prefetching or even garbage collection work better with contiguous data.


If you want to share step-by-step, I’ll update the gist.


That’s my point, it’s different for each distro & partitioning setup, so I wouldn’t know what to share here. Having a swap partition makes it as easy as adding `resume=/dev/sdXYZ` or `resume=UUID=…` to your kernel parameters.


And using LVM for "partitioning" bypasses a lot of this silliness. Do 'lvcreate --contiguous' and you should be good to go if you're using most any non-toy initrd.

Given that every r/w filesystem you're going to use as your '/' on a Linux desktop or server supports online growing (and most support offline shrinking), it's nuts to me to hear people worrying about getting partition sizes correct. With LVM, if you get it wrong you just resize the LV and the filesystem it contains.

Hell, LVM makes swapping out disks a really easy online operation. [0] If you don't have nice hot-swap drive caddies, you might have to power off the box once to add in the new disks and again to remove the old ones, but all the data transfer can happen while the system is in use.

[0] Assuming the new and old disks have the same logical sector size, which they usually do.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: