Filesystem con BTRFS, problemi con ibernazione con SWAP su ZRAM

Ciao,
vi chiedo un consiglio.

Sono recentemente passato a F33 ed ho eseguito l’installazione di default con BTRFS. Quando provo ad ibernare con il comando systemctl hibernate … ottengo
Failed to hibernate system via logind: Not enough swap space for hibernation
Queste l’output di swapon -v e free

$ swapon -v
NAME       TYPE      SIZE USED PRIO
/dev/zram0 partition   4G   0B  100

$ free
              total        used        free      shared  buff/cache   available
Mem:       16226908     3261236     8341512      584048     4624160    12058424
Swap:       4194300           0     4194300

Si evince che effettivamente la dimensone della SWAP non è suffiiente, visto che ho 16GB di RAM. Ma la SWAP nell’installazione di default di F33 non è un FileSystem di SWAP, ma una SWAP su zram e non utilizza più le partizioni di SWAP per impostazione predefinita.

Di seguito il conteuto di /etc/fstab

$ cat /etc/fstab 
UUID=ff78ce94-1bb0-403a-8973-21ae1efb8b8f /                       btrfs   subvol=@,x-systemd.device-timeout=0,ssd,noatime,space_cache,commit=120,discard=async        0 0
UUID=099F-3A38                            /boot/efi               vfat    umask=0077,shortname=winnt 0 2
UUID=ff78ce94-1bb0-403a-8973-21ae1efb8b8f /home                   btrfs   subvol=@home,x-systemd.device-timeout=0,ssd,noatime,space_cache,commit=120,discard=async    0 0
UUID=ff78ce94-1bb0-403a-8973-21ae1efb8b8f /var                    btrfs   subvol=var,x-systemd.device-timeout=0,ssd,noatime,space_cache,commit=120,discard=async      0 2

Leggendo qui https://fedoraproject.org/wiki/Changes/SwapOnZRAM si evince che…

The zram-generator + configuration file will trigger the setup and activation of swap-on-zram. This means hibernation isn’t possible, even on systems that could support it.

A questo punto mi chiedo se (e come) è possibile tornare ad utilizzare l’IBERNAZIONE con questo tipo di configurazione.

Grazie,
S.

Che io sappia, semplicemente non puoi.
Devi avere una classica partizione di swap.

Ho fatto un po’ di esperimenti…
…ho peso spunto da qui https://superuser.com/questions/1581885/btrfs-luks-swapfile-how-to-hibernate-on-swapfile ed ho eseguito i seguenti passaggi

-- Create and configure a swap-file the same size as the system memory
sudo touch /var/swapfile
sudo chattr +C /var/swapfile
sudo fallocate --length "$(grep MemTotal /proc/meminfo | awk '{print $2 * 1024}')" /var/swapfile
sudo chmod 600 /var/swapfile
sudo mkswap /var/swapfile
sudo swapon /var/swapfile
echo '/var/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
cat /etc/fstab 

-- Set the resume kernel parameters
wget "https://raw.githubusercontent.com/osandov/osandov-linux/61679ecd914d653bab14d0e752595e86b9f50513/scripts/btrfs_map_physical.c"
gcc -O2 -o btrfs_map_physical btrfs_map_physical.c
./btrfs_map_physical /var/swapfile | sed -n "2p" | awk "{print \$NF}" >/tmp/swap_physical_offset
sudo ./btrfs_map_physical /var/swapfile | sed -n "2p" | awk "{print \$NF}" >/tmp/swap_physical_offset
SWAP_PHYSICAL_OFFSET=$(cat /tmp/swap_physical_offset)
SWAP_OFFSET=$(echo "${SWAP_PHYSICAL_OFFSET} / $(getconf PAGESIZE)" | bc)
SWAP_UUID=$(findmnt -no UUID -T /var/swapfile)
RESUME_ARGS="resume=UUID=${SWAP_UUID} resume_offset=${SWAP_OFFSET}"
echo "${RESUME_ARGS}"
sudo grubby --update-kernel=ALL --args="${RESUME_ARGS}"

-- Disable systemd swap space check - To avoid false positive systemd errors about the swap size, if there's already an existing swap target (e.g. the default zram device).
sudo mkdir -p /etc/systemd/system/systemd-logind.service.d/
cat <<-EOF | sudo tee /etc/systemd/system/systemd-logind.service.d/override.conf
[Service]
Environment=SYSTEMD_BYPASS_HIBERNATION_MEMORY_CHECK=1
EOF

sudo mkdir -p /etc/systemd/system/systemd-hibernate.service.d/
cat <<-EOF | sudo tee /etc/systemd/system/systemd-hibernate.service.d/override.conf
[Service]
Environment=SYSTEMD_BYPASS_HIBERNATION_MEMORY_CHECK=1
EOF

Ho quindi fatto il reboot ed ho testato con systemctl hibernate…ma nulla da fare, NON funziona!

Le configurazioni ora sono le seguenti:

$ sudo blkid | grep swap
/dev/zram0: UUID="8164f084-3ac5-41f5-9b90-c2aa29c7dbcd" TYPE="swap"

$ swapon -s
Filename				Type		Size	Used	Priority
/dev/zram0                             	partition	4194300	0	100
/var/swapfile                          	file    	16226904	0	-2

$ cat /etc/fstab 
UUID=ff78ce94-1bb0-403a-8973-21ae1efb8b8f /         btrfs   subvol=@,x-systemd.device-timeout=0,ssd,noatime,space_cache,commit=120,discard=async        0 0
UUID=099F-3A38                            /boot/efi vfat    umask=0077,shortname=winnt 0 2
UUID=ff78ce94-1bb0-403a-8973-21ae1efb8b8f /home     btrfs   subvol=@home,x-systemd.device-timeout=0,ssd,noatime,space_cache,commit=120,discard=async    0 0
UUID=ff78ce94-1bb0-403a-8973-21ae1efb8b8f /var      btrfs   subvol=var,x-systemd.device-timeout=0,ssd,noatime,space_cache,commit=120,discard=async      0 2
/var/swapfile none swap sw 0 0

Il procedimento di ibernazione sembra funzionare in fasedi spegnimento. Alla riaccensione però effettua un ormale boot e non effettua l’operaizone di RESUME :frowning_face:

Ciao @oscisos per curiosità posta :

cat  /etc/default/grub

:slightly_smiling_face:

Questo il contenuto di /etc/default/grub

$ sudo cat /etc/default/grub
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed ‘s, release .*$,g’ /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT=“console”
GRUB_CMDLINE_LINUX=“rhgb quiet resume=UUID=ff78ce94-1bb0-403a-8973-21ae1efb8b8f resume_offset=100144384”
GRUB_DISABLE_RECOVERY=“true”
GRUB_ENABLE_BLSCFG=true

Puoi vedere che l’UUID è corretto

$ findmnt -no UUID -T /var/swapfile
ff78ce94-1bb0-403a-8973-21ae1efb8b8f

E questo l’offset

$ sudo filefrag -v /var/swapfile | awk ‘{ if($1==“0:”){print $4} }’
100144384…

Prova a mettere :

resume=UUID=8164f084-3ac5-41f5-9b90-c2aa29c7dbcd

prima di rhgb quiet

2 Mi Piace

PERFETTO, FUNZIONA!
:ok_hand: :v:
Grazie 1000!

1 Mi Piace

Ottimo @oscisos spunta la soluzione sul mio post che se capita a un’atro utente almeno sà come risolvere l’errore :slightly_smiling_face: