-
Notifications
You must be signed in to change notification settings - Fork 5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
encrypted swap causes system to crash/reboot #3288
Comments
When trying this with an encrypted swap FILE, I got the following kernel dump via a serial console.
|
from my Google encrypted swap FILE does not work in general. encrypted swap PARTITION should work. But never found what is the problem with files hence my focus was on encrypting partition only. Swap FILE without encryption works perfectly. |
So I am wasting my time with testing this on a swap file - i need to use a swap partition? Getting to the point of not worth the time for a minimal use case. |
Sorry, I can confirm that the encrypted SWAP file is not working. If we want to get ahead, we also need to test with a partition. I tested it on a Pi4 with 64-bit kernel, but works fine. |
Taken a brief look at this, just enough to confirm that I won't be able to figure out what is going on in a sane timescale - very much out of my area of expertise - needs a linux memory management/encryption expert. The fact it works on 64bit might indicate a problem with the encryption path in 32bit, but I have no idea how to track that down. Worth noting there is no HW encryption on the Pi SoC, so this is always going to be slow anyway as its done in SW - there could even be timeouts that might cause problems. |
Thank you for looking into it. Hopefully 64bits raspbian will be ready for general release soon and if it fixes this and other issues better to focus on it. cryptsetup dev have similar suspicions https://gitlab.com/cryptsetup/cryptsetup/issues/495 |
I have the same problem with a 64 bit kernel and a non-encrypted swap file: However, I have an encyrpted partition. Could it maybe be that the network driver gets lots of input and cannot get a buffer since the write back buffer fills up too much as encryption and storage to disk are too slow?
|
So after executing the following command, the problem does not happen any more for me (and it happened more than once per day before): sysctl -w vm.min_free_kbytes=65536 This command does not make the setting permanent over reboots - there are various config files to make it permament. |
problem with encrypted swap? on 32 aor 64 bits raspbain? |
I had NO encrypted swap, but an encrypted partition (swap on unencrypted usb stick). I would bet that the problem is not the swap, but the encryption in general when he receives too much data over this kernel driver. Before, I had problems on an Rpi 4, Raspian Buster, both 32 as well as 64 bit kernels. The fix helped for 4.19.75-v8+ #1270 SMP PREEMPT Tue Sep 24 18:59:17 BST 2019 aarch64 GNU/Linux |
Is it not complaining about a spurious '#' after the 65536? |
I execute the following command and receive only 1 line of output:
Still no problem after 46 days of uptime (I had problems after 1-10 days before). |
Describe the bug
swap partition encrypted with cryptsetup causes system to reboot as soon as swap is used
To reproduce
In this example there is external disk attached with 2GB swap partition (/dev/sda2)
disable existing swap:
sudo swapoff -a
install cryptsetup:
sudo apt-get install cryptsetup
edit /etc/crypttab and add:
cryptswap /dev/sda2 /dev/urandom swap,cipher=aes-xts-plain64,size=256,hash=sha1,noauto
start encrypted partition:
sudo cryptdisks_start cryptswap
check that above worked:
enable encrypted swap:
sudo swapon /dev/mapper/cryptswap
check that above worked:
make use of it, I force it with:
stress -m 2 --vm-bytes 500M
but initially I noticed it during normal usage e.g. when running complex software build.
I observe swap usage using
htop
Expected behaviour
system should use encrypted swap.
Actual behaviour
system reboots as soon as swap is being used
System
Which model of Raspberry Pi? tested with:
2B, 3 and 3B+
Which OS and version (
cat /etc/rpi-issue
)?Raspberry Pi reference 2019-09-26
Generated using pi-gen, https://github.com/RPi-Distro/pi-gen, 80d486687ea77d31fc3fc13cf3a2f8b464e129be, stage2
Which firmware version (
vcgencmd version
)?Sep 24 2019 17:37:47
Copyright (c) 2012 Broadcom
version 6820edeee4ef3891b95fc01cf02a7abd7ca52f17 (clean) (release) (start_cd)
Which kernel version (
uname -a
)?Linux raspberrypi 4.19.75-v7+ solved issue of mirroring screen after rotation. #1270 SMP Tue Sep 24 18:45:11 BST 2019 armv7l GNU/Linux
Logs
There is nothing in logs related to reboot, no OOM... nothing
The last entries in kern.log
followed by fresh boot sequence.
Additional context
When swap partition is not using encryption everything works perfectly. I have tried external HDD, memory sticks etc. Using partition or full disk. Results are always the same - as soon as I try encrypt swap system reboots.
To rule out any misconfiguration I have run it with the latest fresh install of raspbian. All updates applied.
I have raised this issue on raspberry pi forum (Encrypted swap crashes all system) but so far no solution/cause have been found.
The text was updated successfully, but these errors were encountered: