Bug 186252

Summary: Cannot mount an encrypted swap file in fstab
Product: Base System Reporter: Mark Voortman <mark>
Component: miscAssignee: freebsd-bugs (Nobody) <bugs>
Status: Open ---    
Severity: Affects Some People CC: bdrewery, freebsd-bugs, hrs, koobs, mike
Priority: Normal Keywords: feature, needs-patch, security
Version: Unspecified   
Hardware: Any   
OS: Any   
See Also: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=195326

Description Mark Voortman 2014-01-29 19:00:00 UTC
Adding

  md none swap sw,file=/swap 0 0

to /etc/fstab mounts the swap file on boot, but it will be unencrypted. When I make it md.eli (or md0.eli or /dev/md.eli or /dev/md0.eli) the swap file is not mounted. This approach does work for swap partitions (e.g., /dev/ada1.eli).

How-To-Repeat: Create a swap file:

  dd if=/dev/zero of=/swap bs=1024k count=64
  chmod 0600 /swap

and add it to /etc/fstab

  md.eli none swap sw,file=/swap 0 0

and reboot. The (encrypted) swap file will not be available.
Comment 1 Bryan Drewery freebsd_committer freebsd_triage 2015-05-14 03:54:01 UTC
For me the basic md vnode swap doesn't work. It just creates the md but does not load the swap on boot. If I mdconfig -d -u 99 and then service swap start (swapon -aq), it works.
Comment 2 Bryan Drewery freebsd_committer freebsd_triage 2015-05-14 03:55:56 UTC
At boot there is "swapon: /dev/md0: Read-only file system"
Comment 3 Bryan Drewery freebsd_committer freebsd_triage 2015-05-14 04:00:09 UTC
My problem is Bug #195326
Comment 4 Adam Mackler 2015-10-16 16:51:41 UTC
I would use this feature if available, that is configuring an encrypted swap file in /etc/fstab the same way as for a swap partition.  FreeBSD 10.2.
Comment 5 Eitan Adler freebsd_committer freebsd_triage 2018-05-20 23:50:36 UTC
For bugs matching the following conditions:
- Status == In Progress
- Assignee == "bugs@FreeBSD.org"
- Last Modified Year <= 2017

Do
- Set Status to "Open"