0

Trying to hibernate failed because the swap is too small. Debian wiki pages do in my view not clearly explain how to fix this. 2 3

$ sudo fdisk -l /dev/nvme0n1
Disk /dev/nvme0n1: 476.94 GiB, 512110190592 bytes, 1000215216 sectors
Disk model: SAMSUNG MZVLB512HAJQ-000L7              
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: AC1BEA07-5209-41FE-AF1A-79C3D68B3FE4

Device             Start        End   Sectors   Size Type
/dev/nvme0n1p1      2048    1050623   1048576   512M EFI System
/dev/nvme0n1p2   1050624  998215679 997165056 475.5G Linux filesystem
/dev/nvme0n1p3 998215680 1000214527   1998848   976M Linux swap

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            7.7G     0  7.7G   0% /dev
tmpfs           1.6G  2.0M  1.6G   1% /run
/dev/nvme0n1p2  467G   95G  349G  22% /
tmpfs           7.7G   13M  7.7G   1% /dev/shm
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
/dev/nvme0n1p1  511M   23M  489M   5% /boot/efi
tmpfs           1.6G  216K  1.6G   1% /run/user/1000

$ mount    # edited
/dev/nvme0n1p2 on / type ext4 (rw,relatime,errors=remount-ro)
/dev/nvme0n1p1 on /boot/efi type vfat (rw,relatime,fmask=0077,dmask=0077,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro)

Johan
  • 321
  • 1
  • 15
  • 1. Consider the reason for hibernation, something not enable by default; if your only reason is "cuz I wanna" you better keep the working system as it is. 2. If you have a valid reason then consider using a swapfile instead of a swap partition with the required maximum size that must be at least = amount of RAM (a little more is preferable). – ChanganAuto May 07 '23 at 20:09
  • In general (actually, all the time), one cannot change a disk's partition size while ANY of the disk's partition in mounted. That's why you're instructed to "boot from another medium than HD". – waltinator May 08 '23 at 00:00
  • @waltinator In general, you can change the size of all unmounted partitions. I needed to do this quite often. As long as partitions are not required to run the systems, unmount them and chance their sizes. You just can't shrink a partition before the mounted partition to increase the size of a partition after the mounted one (and vice versa). Here, the problem is that the partition to be shrinked can't be unmounted. – Philippos May 08 '23 at 06:06
  • @Philippos would it be possible to unmount Device=/dev/nvme0n1p2 Type=Linux filesystem either by booting from a USB or in rescue mode? – Johan May 26 '23 at 13:38
  • 1
    I don't know what kind of rescue mode is implemented, but it will be possible when booting from USB. – Philippos May 26 '23 at 14:10

2 Answers2

1

This worked out

  1. Backup with CloneZilla
  2. Prepare offline configuration of partitions
  3. Configure partitions
  4. Final swap setup
  5. Check partitions
  6. Test hibernation

1. Backup with CloneZilla

  • Requires at least one usb drive, one of which must have enough space for the backup.
  • optionally a second to install CloneZilla Live on
  • I decided to follow the strategy of making CloneZilla available as an iso image on the disk with an entry to the grub boot menu, making it easy to backup stuff in future without relying on two usb's
  1. Gnome-disk-utility failed so I was led to use CloneZilla Live, the ISO, not zip
  2. CloneZilla Live example at the bottom, and see original guide
  3. I'm running Debian Bullseye and it was necessary to solve the bug of a slightly prior version by inserting rmmod tpm before the menuentry
  4. when I got to running the actual program it was a bit buggy but worked out somewhat like described in the original guide

2. Prepare offline configuration of partitions (no mounted filesystem)

  1. reboot
  2. edit BIOs to prioritize (and what not) boot from usb
  3. boot from usb with Debian bullseye install to enter rescue mode where filesystem is not in use.

3. Configure partitions

  1. I deactivated swap of current swap partion, went to gparted and removed it, so I did not backup the existing small swap partion uuid, so I had to setup swap at the end
  2. follow rootuser.com advice to first check filesystem e2fsck -fy /dev/partition-here, shrink it to slightly less than intended resize2fs /dev/partition-here desired-minus-~10-G, then shrink partition, however, using parted, and then resize2fs to actually desired size, then parted to create the linux-swap from end of filesystem to 100%.
  • for parted commands:
    1. select device (it defaulted to the usb device that booted rescue mode)
    2. unit GiB (as explained at archlinux this unit corresponds to the unit of resize2fs xxxG)
  1. quit parted and use mkswap /dev/swap-partion-name

4. Final swap setup

  1. reboot was buggy (I hit the keyboard a few times in the hope of causing some progress) and it eventually entered Gnome :-)
  2. swapon /dev/swap-partition-name
  3. update:
  4. fstab (remember # Please run 'systemctl daemon-reload' after making changes here.),
  5. RESUME,
  6. and initrd/initramfs
  7. free -m
  8. cat /proc/sys/vm/swappiness

5. check filesystem, disk partition table, partitions, and block devices

  1. e2fsck -fy /dev/filesystem-partition-name-here
  2. mount
  3. fdisk -l /dev/encompassing-partition-name-here
  4. df -h
  5. lsblk

6. Test hibernation

  1. systemctl hibernate
  2. sudo journalctl -r -u hibernate.target
  3. sudo systemctl list-dependencies -a hibernate.target
  4. sudo systemctl status systemd-hibernate
Johan
  • 321
  • 1
  • 15
0

Simply booting gparted live from an USB stick would have given you the opportunity to act on all the partitions.

user4089
  • 878
  • 6
  • 14