Add a service to enable swap early - before fsck of the root filesystem

fsck may require significant amount of RAM, enable swap earlier to avoid
out of memory condition. Implement this as a separate service unit, not
a swap unit, because the latter requires udev running (implicit
dependency on dev-xvdc1.device) which is not the case before remounting
root filesystem read-write.

QubesOS/qubes-issues#6174
This commit is contained in:
Marek Marczykowski-Górecki 2020-11-02 04:46:31 +01:00
parent aa50b2fedc
commit 7f15690e43
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724
6 changed files with 19 additions and 1 deletions

View File

@ -101,7 +101,7 @@ install-init:
install -m 0644 init/functions $(DESTDIR)$(LIBDIR)/qubes/init/ install -m 0644 init/functions $(DESTDIR)$(LIBDIR)/qubes/init/
# Systemd service files # Systemd service files
SYSTEMD_ALL_SERVICES := $(wildcard vm-systemd/qubes-*.service) SYSTEMD_ALL_SERVICES := $(wildcard vm-systemd/qubes-*.service) vm-systemd/dev-xvdc1-swap.service
SYSTEMD_NETWORK_SERVICES := vm-systemd/qubes-firewall.service vm-systemd/qubes-iptables.service vm-systemd/qubes-updates-proxy.service SYSTEMD_NETWORK_SERVICES := vm-systemd/qubes-firewall.service vm-systemd/qubes-iptables.service vm-systemd/qubes-updates-proxy.service
SYSTEMD_CORE_SERVICES := $(filter-out $(SYSTEMD_NETWORK_SERVICES), $(SYSTEMD_ALL_SERVICES)) SYSTEMD_CORE_SERVICES := $(filter-out $(SYSTEMD_NETWORK_SERVICES), $(SYSTEMD_ALL_SERVICES))

View File

@ -83,6 +83,7 @@ lib/systemd/system/netfilter-persistent.service.d/30_qubes.conf
lib/systemd/system/org.cups.cupsd.path.d/30_qubes.conf lib/systemd/system/org.cups.cupsd.path.d/30_qubes.conf
lib/systemd/system/org.cups.cupsd.service.d/30_qubes.conf lib/systemd/system/org.cups.cupsd.service.d/30_qubes.conf
lib/systemd/system/org.cups.cupsd.socket.d/30_qubes.conf lib/systemd/system/org.cups.cupsd.socket.d/30_qubes.conf
lib/systemd/system/dev-xvdc1-swap.service
lib/systemd/system/qubes-early-vm-config.service lib/systemd/system/qubes-early-vm-config.service
lib/systemd/system/qubes-misc-post.service lib/systemd/system/qubes-misc-post.service
lib/systemd/system/qubes-mount-dirs.service lib/systemd/system/qubes-mount-dirs.service

View File

@ -908,6 +908,7 @@ The Qubes core startup configuration for SystemD init.
%files systemd %files systemd
%defattr(-,root,root,-) %defattr(-,root,root,-)
/etc/systemd/system/xendriverdomain.service /etc/systemd/system/xendriverdomain.service
/lib/systemd/system/dev-xvdc1-swap.service
/lib/systemd/system/qubes-misc-post.service /lib/systemd/system/qubes-misc-post.service
/lib/systemd/system/qubes-mount-dirs.service /lib/systemd/system/qubes-mount-dirs.service
/lib/systemd/system/qubes-rootfs-resize.service /lib/systemd/system/qubes-rootfs-resize.service

View File

@ -107,6 +107,7 @@ enable qubes-sync-time.timer
enable module-load-dummy-psu.service enable module-load-dummy-psu.service
enable module-load-dummy-backlight.service enable module-load-dummy-backlight.service
enable qubes-psu-client@.service default sys-usb enable qubes-psu-client@.service default sys-usb
enable dev-xvdc1-swap.service
# Disable useless Xen services in Qubes VM # Disable useless Xen services in Qubes VM
disable xenstored.service disable xenstored.service

View File

@ -0,0 +1,13 @@
[Unit]
# have it as .service, not .swap, because .swap has implicit dependency on
# .device which needs udev running already
Description=Enable swap on /dev/xvdc1 early
DefaultDependencies=no
Before=systemd-fsck-root.service
[Service]
Type=oneshot
ExecStart=-/usr/sbin/swapon /dev/xvdc1
[Install]
WantedBy=sysinit.target

View File

@ -0,0 +1,2 @@
[Unit]
After=swap.target