Use Swap Files Instead of Swap Partitions

Registered by Robbie Williamson

Switch to using a swap file, instead of a partition, to allow for on-the-fly resizing .

Blueprint information

Status:
Started
Approver:
Colin Watson
Priority:
Undefined
Drafter:
Scott James Remnant (Canonical)
Direction:
Needs approval
Assignee:
Scott James Remnant (Canonical)
Definition:
Approved
Series goal:
None
Implementation:
Blocked
Milestone target:
None
Started by
Robbie Williamson

Related branches

Whiteboard

Can some consideration be given to, say, netbooks with solid state devices. Is it sensible that they have a swap file at all - given how slow SSDs are?

Are you suggesting no swap space at all on netbooks? AFAIK, most SSDs are actually faster than standard rotary disk storage (mine are), so not sure what you mean by "slow SSDs". -Robbie

In terms of performance, it doesn't matter wether a swap file resides in a file system or in a dedicated partition. Read/write troughput is as fast as it is. Additionally, some systems (more than, say, 2 GiB RAM) have swap enabled for the sole purpose of mapping files. -Traumflug

As I understand it, random access is faster on SSD (no seek), while sequential access may still be faster on spinning hard drives. It's very manufacturer specific though, with Intel producing the fastest [1]. That said, I think it's still important to offer swap on netbooks, since many of them ship with very low amounts of system memory. One of the huge advantages, though, of swapfiles would be the ability to provide a System->Administration->Memory application with a slider, allowing the user to select how much swap they want to enable (0 - $DISK_SIZE), with, perhaps a recommendation on an optimal amount. -- Dustin Kirkland
 [1] http://en.wikipedia.org/wiki/Solid-state_drive#Quality_and_performance

SSDs have fast random access and fast reads, but very slow random writes. Using them for swap space can be excruciating if your main memory is so full that you actually need swap space. On my laptops with SSDs, I've set aside dedicated swap partitions but I leave them disabled. I only enable them to allow hibernating, and disable them again after resume. (For sequential reads and writes they are blazing fast.) -- Howard

In cases where physical memory is more than adequate (generally >1GB), swap ends up being used only for once-touched (= cold) pages. Having a 256MB swap file for such adequately-spec'd systems allows optimal use of physical memory, and performance isn't important, but resizing it in case later is, thus a swap-file is key. -- Daniel J Blueman

Using swap file instead of swap partition will require fixing hibernation to swap file. -- Przemyslaw Kulczycki

Wasnt that fixed long time ago to allow Wubi to hibernate and resume, Przemyslaw? -- BUGabundo

2009-06-16 cjwatson: approved, though as discussed on IRC I think the installer partitioning task is a little more complicated than stated here :-)

2009-06-23 robbie.w: Milestone target?

2009-08-27 robbie.w: Deferred because of kernel Bug 386554 . Once this bug is resolved we can quickly enabled.

2009-11-18 robbie.w: Blocked on kernel Bug 386554

A couple "minor" points: non-contiguous swap files are among the things that slow down Windows (and yes, Linux does get some fragmentation, as the ext4 programmers realized); standard advice for installation on SSD-based netbooks is "don't use swap, it will wear out the disk too fast"; SSDs vary in quality, meaning that some (such as certain built-in ones on netbooks) are slow, while others are fast. -Ibidem

(?)

Work Items