前言
我犯了一个错误,在我的高效工作桌面上以双启动配置安装了带有加密 ZFS / OpenZFSroot
分区的 Ubuntu 20.04 LTS (请参阅下面的分区表)。但是我没有对我正在关注的教程给予适当的关注,现在似乎我有一个 4G 的交换分区,虽然我有 32G 的 RAM(编辑: 我发现了我如何能够增加交换但我仍然不能进入休眠状态——见下文)。因此我不能让这台机器进入休眠状态。
解决此问题的最佳方法是什么,以便我可以让这台机器进入休眠状态?
当前状态
$ sudo fdisk -l /dev/nvme0n1
Disk /dev/nvme0n1: 1.88 TiB, 2048408248320 bytes, 4000797360 sectors
Disk model: KXG60PNV2T04 NVMe KIOXIA 2048GB
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: 1FCA11ED-9263-4C06-A8DF-594C0DE84AFA
Device Start End Sectors Size Type
/dev/nvme0n1p1 2048 1085439 1083392 529M Windows recovery environment
/dev/nvme0n1p2 1085440 1290239 204800 100M EFI System
/dev/nvme0n1p3 1290240 1323007 32768 16M Microsoft reserved
/dev/nvme0n1p4 1323008 409420488 408097481 194.6G Microsoft basic data
/dev/nvme0n1p5 409421824 410920959 1499136 732M Windows recovery environment
/dev/nvme0n1p6 410923008 415117311 4194304 2G Linux filesystem
/dev/nvme0n1p7 415117312 4000797326 3585680015 1.7T Linux filesystem
$ sudo swapon --show --output all
NAME TYPE SIZE USED PRIO UUID LABEL
/dev/zd0 partition 4G 0B -2 1e1fb013-69d9-4878-b358-6b8ee53d5b09
$ sudo zpool list -v
NAME SIZE ALLOC FREE CKPOINT EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT
Root 1.66T 535G 1.13T - - 2% 31% 1.00x ONLINE -
nvme0n1p7 1.66T 535G 1.13T - - 2% 31.5% - ONLINE
$ sudo zpool status -v
pool: Root
state: ONLINE
scan: none requested
config:
NAME STATE READ WRITE CKSUM
Root ONLINE 0 0 0
nvme0n1p7 ONLINE 0 0 0
errors: No known data errors
$ sudo zfs list
NAME USED AVAIL REFER MOUNTPOINT
Root 539G 1.08T 192K none
Root/root 534G 1.08T 530G /
Root/root/00a891589b00cebc55cb6767e266ca38ac201daf3a6048c1f33d7d55c0710533 544K 1.08T 143M legacy
[…] # many other legacy mount points
Root/root/ffe52d35c873e6a417ee12c7025d848dac1f269b8078266f00a8d8088fd34384 396K 1.08T 607M legacy
Root/swap 4.25G 1.08T 172M -
$ sudo zfs get all Root/swap
NAME PROPERTY VALUE SOURCE
Root/swap type volume -
Root/swap creation So Aug 2 15:36 2020 -
Root/swap used 4.25G -
Root/swap available 1.08T -
Root/swap referenced 172M -
Root/swap compressratio 1.00x -
Root/swap reservation none default
Root/swap volsize 4G local
Root/swap volblocksize 4K -
Root/swap checksum on default
Root/swap compression off local
Root/swap readonly off default
Root/swap createtxg 3746 -
Root/swap copies 1 default
Root/swap refreservation 4.25G local
Root/swap guid 12379969387189982956 -
Root/swap primarycache metadata local
Root/swap secondarycache none local
Root/swap usedbysnapshots 0B -
Root/swap usedbydataset 172M -
Root/swap usedbychildren 0B -
Root/swap usedbyrefreservation 4.08G -
Root/swap logbias throughput local
Root/swap objsetid 278 -
Root/swap dedup off default
Root/swap mlslabel none default
Root/swap sync always local
Root/swap refcompressratio 1.00x -
Root/swap written 172M -
Root/swap logicalused 169M -
Root/swap logicalreferenced 169M -
Root/swap volmode default default
Root/swap snapshot_limit none default
Root/swap snapshot_count none default
Root/swap snapdev hidden default
Root/swap context none default
Root/swap fscontext none default
Root/swap defcontext none default
Root/swap rootcontext none default
Root/swap redundant_metadata all default
Root/swap encryption aes-256-gcm -
Root/swap keylocation none default
Root/swap keyformat passphrase -
Root/swap pbkdf2iters 342K -
Root/swap encryptionroot Root -
Root/swap keystatus available -
我试过的
创建交换文件
我认为交换文件可能很容易解决,但我显然错了:
$ sudo dd if=/dev/zero of=/swapfile bs=1MiB count=$((32*1024))
32768+0 records in
32768+0 records out
34359738368 bytes (34 GB, 32 GiB) copied, 14.5783 s, 2.4 GB/s
$ sudo chmod 600 /swapfile
$ sudo swapon /swapfile
swapon: /swapfile: skipping - it appears to have holes.
所以我想我应该增加交换分区。我也不清楚为什么swapon
声称交换分区有,4G
尽管zfs get all Root/swap
说它1.08T
是可用的。
任何与 GParted 相关的东西
GParted 不会识别太多。这可能与os-prober
(GParted 问题 14、Debian 错误 888114、os-prober 问题 1848496、openzfs 问题9801和9069)中的错误有关
替换小的 Swap 分区(=增加 ZFS 上的 Swap 分区)
创建命令的灵感来自GitHub 上的评论,但请记住不要使用-o sync=always
.
$ sudo zfs create -V 32G -b $(getconf PAGESIZE) -o logbias=throughput -o primarycache=metadata -o secondarycache=none -o com.sun:auto-snapshot=false -o compression=zle Root/swap_two
$ sudo zfs rename Root/swap Root/swap_bak
$ sudo zfs rename Root/swap_two Root/swap
$ sudo mkswap -f /dev/zvol/Root/swap
$ sudo swapon /dev/zvol/Root/swap
确保此条目位于/etc/fstab
:
/dev/zvol/Root/swap none swap discard 0 0
然后重新启动并删除微小的旧交换:
$ sudo zfs destroy Root/swap_bak
虽然这似乎有效,但我仍然无法休眠:
$ sudo systemctl hibernate
Failed to hibernate system via logind: Sleep verb "hibernate" not supported
因此,我仍然愿意接受任何建议。也许它需要一个专用resume
参数GRUB_CMDLINE_LINUX_DEFAULT
?