wait until swapoff is *actually* finished (it returns too early)?
(Please d̲o̲ Cc me on replies, I don’t subscribe to this list. Thanks!)
Hi,
this is a bit curious problem:
I have a setup with swap devices on dmcrypt:
$ cat /etc/crypttab
# <target name> <source device> <key file> <options>
crtpv LABEL=fooclvm none discard,luks,initramfs
cswp1 /dev/vg-foo/lv-swp1 /dev/random discard,cipher=aes-xts-plain64,size=256,plain,swap
cswp2 /dev/vg-foo/lv-swp2 /dev/random discard,cipher=aes-xts-plain64,size=256,plain,swap
In a cronjob, I basically do swapoff && cryptdisks_stop && \
cryptdisks_start && swapon for both swaps individually to
throw away the old encryption key regularily (but not too
frequently).
I immediately ran into the problem, when trying this for the
first time, that a “swapoff /dev/mapper/cswp1” returns before
the device is released, so the subsequent cryptdisks_stop fails.
I found that inserting a “cat /proc/swaps”, funnily enough,
makes those failures less frequent but still present; adding
a “sleep 3” as well made it work for months.
Until tonight when it didn’t.
Just adding a “sleep” is no proper fix anyway, so the question
is, how to wait in a shell script until the swap device is
*really* swapoff’d when the syscall returns too early, and
(someone from the Linux kernel maintainers reading this?) should
I report the latter as a bug against the kernel?
This is on bullseye/amd64, on VMs and bare metal both. Using
direct partitions like /dev/sda3 (or via LABEL= to avoid trouble)
makes no difference from using LVs.
Thanks in advance,
//mirabilos
--
16:47⎜«mika:#grml» .oO(mira ist einfach gut....) 23:22⎜«mikap:#grml»
mirabilos: und dein bootloader ist geil :) 23:29⎜«mikap:#grml» und ich
finds saugeil dass ich ein bsd zum booten mit grml hab, das muss ich dann
gleich mal auf usb-stick installieren -- Michael Prokop über MirOS bsd4grml
Reply to: