[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#844713: ITP: partman-swapfile -- add support for creating swapfiles

Package: wnpp
Owner: Dimitri John Ledkov <xnox@ubuntu.com>
Severity: wishlist

* Package name    : partman-swapfile
  Version         : 1
  Upstream Author : d-i team
* URL or Web page : d-i
* License         : GPL
  Description     : add support for creating swapfiles

I am working on minimising number of partitions used in the default
instalations in Ubuntu. One of the things I have done already in Ubuntu is to
tweak and not use dedicated /boot partition for non-encrypted LVM based
installations. Simply by tweaking the partman-auto recipes, on
architectures/bootloaders that support booting off LVM.

Another thing I am investigating is moving away from swap partitions to
swap files, on non-lvm installations. This will involve tweaking the
default partman-auto recipes & the no-swap warning.

However, to provide swapfiles out of the box I wrote this
partman-swapfile module which hooks into /lib/partman/finish.d to create
/target/swapfile with an appropriate stanza in /target/etc/fstab. Care
is taken not to create swapfiles uncessory, reuse existing one, or do
nothing if a swap partition is already present, or swapfiles not
supported on a given filesystem (e.g. btrfs).

There are two control options to configure the size of the
swapfile. Absolute size, and percentage of free space on the
rootfs. The defaults are 2GB and 5%, meaning the swapfile will be 2GB in
size or 5% of the free space on rootfs, whichever is lower. Setting the
size or percentage to zero will skip creating the swapfile. This is a
strategy to make sure there is some swap available, without wasting too
much of disk space on high-memory-to-disk ratio systems (e.g. 1TB of RAM
with a 200GB hard drive).

I am not at all sure if this functionality is at all welcomed, needed,
or will generate any interest. I do not know if it's wanted to be
available by default in Debian's d-i. At the moment I created a git
repository in the d-i team, and plan to upload this to experimental for
people to try this out.

On the implementation side, swapfile is allocated using fallocate (if
avaialble and target filesystem creates files without holes using
fallocate) otherwise "slow" dd is used. This makes swapfile creation
really quick on ext4 rootfs.

All the glory details are here:



Reply to: