*-a*, *--all*::
All devices marked as "swap" in _/etc/fstab_ are made available, except for those with the "noauto" option. Devices that are already being used as swap are silently skipped.
+*-T*, *--fstab* _path_::
+Specifies an alternative fstab file for compatibility with *mount(8)*. If _path_ is a directory, then the files in the directory are sorted by strverscmp(3); files that start with "." or without an .fstab extension are ignored. The option can be specified more than once. This option is mostly designed for initramfs or chroot scripts where additional configuration is specified beyond standard system configuration.
+
*-d*, *--discard*[**=**__policy__]::
Enable swap discards, if the swap backing device supports the discard or trim operation. This may improve performance on some Solid State Devices, but often it does not. The option allows one to select between two available swap discard policies:
}
-static int swapon_all(struct swapon_ctl *ctl)
+static int swapon_all(struct swapon_ctl *ctl, const char *filename)
{
- struct libmnt_table *tb = get_fstab();
+ struct libmnt_table *tb = get_fstab(filename);
struct libmnt_iter *itr;
struct libmnt_fs *fs;
int status = 0;
fputs(_(" -o, --options <list> comma-separated list of swap options\n"), out);
fputs(_(" -p, --priority <prio> specify the priority of the swap device\n"), out);
fputs(_(" -s, --summary display summary about used swap devices (DEPRECATED)\n"), out);
+ fputs(_(" -T, --fstab <path> alternative file to /etc/fstab\n"), out);
fputs(_(" --show[=<columns>] display summary in definable table\n"), out);
fputs(_(" --noheadings don't print table heading (with --show)\n"), out);
fputs(_(" --raw use the raw output format (with --show)\n"), out);
{
int status = 0, c;
size_t i;
- char *options = NULL;
+ char *options = NULL, *fstab_filename = NULL;
enum {
BYTES_OPTION = CHAR_MAX + 1,
{ "noheadings", no_argument, NULL, NOHEADINGS_OPTION },
{ "raw", no_argument, NULL, RAW_OPTION },
{ "bytes", no_argument, NULL, BYTES_OPTION },
+ { "fstab", required_argument, NULL, 'T' },
{ NULL, 0, NULL, 0 }
};
mnt_init_debug(0);
mntcache = mnt_new_cache();
- while ((c = getopt_long(argc, argv, "ahd::efo:p:svVL:U:",
+ while ((c = getopt_long(argc, argv, "ahd::efo:p:svVL:U:T:",
long_opts, NULL)) != -1) {
err_exclusive_options(c, long_opts, excl, excl_st);
case 'U':
add_uuid(optarg);
break;
+ case 'T':
+ fstab_filename = optarg;
+ break;
case 'd':
ctl.props.discard |= SWAP_FLAG_DISCARD;
if (optarg) {
}
if (ctl.all)
- status |= swapon_all(&ctl);
+ status |= swapon_all(&ctl, fstab_filename);
if (options)
parse_options(&ctl.props, options);