How to config the hibernation function by creating swapfile in '/' correctly?

Hello everybody, I’am a Chinese student using Manjaro, the question I asked above makes me confusing, so I really need your help so that I can solve my problem. Besides, my english is not very well, therefore, please feel free to ask me about any thing if I didn’t describe clearly in the below, thank you very much!

  1. I’am currently using the latest version of Manjaro, and it’s kernal is “x86_64 Linux 5.13.19-2-MANJARO”

  2. Because of don’t want to open too much softwares and drop them to the position I want, so I really need the hibernation function.

  3. I prefer using swap file instead of swap partition owing to the size of the swap file can be change easily in the future.

  4. Although as a manjaro user, I have readed the description in ArchWiki.

  5. What I have done all are listed in the below.

  6. Firstly, I checked the version of btrfs by running btrfs --version, and I got btrfs-progs v5.14.2.

  7. After that, by running commands sudo swapoff /swapfile,sudo dd if=/dev/zero of=/swapfile bs=1M count=8192 status=progress,sudo chmod 600 /swapfile,sudo mkswap /swapfile and sudo swapon /swapfile, a 8GB swapfile was created.

  8. Then, I appended command /swapfile none swap defaults 0 0 to the ‘/etc/fstab’ file, save and exit by running ‘:wq’.

  9. Besides, I have edited the file ‘/etc/default/grub’, only changed the line of ‘GRUB_CMDLINE_LINUX_DEFAULT’ existing to GRUB_CMDLINE_LINUX_DEFAULT="quiet udev.log_priority=3 nowatchdog resume=UUID=f8913796-f929-449f-ad39-5f6884e648f7 resume_offset=1179648"

  10. :wq

  11. Finally, sudo update-grub

  12. After test, it’s failed…

  13. If I have missed something or did wrong? Looking forward to anyone’s reply. thanks!


Manjaro linux 如何配置系统休眠功能(交换到文件)?

  1. 我使用的最新 Manjaro 操作系统
  2. Kernel: x86_64 Linux 5.13.19-2-MANJARO
  3. 不想每次开机都需要重新打开很多软件,并将它们排列到合适的位置
  4. 所以想使用休眠(hibernation)功能
  5. 考虑到交换到文件而不是交换到分区,因为这样我可以方便地调整交换文件的大小
  6. 作为 manjaro 用户,我去蹭了 archwiki 上的相关说明,做了以下操作
  7. 首先,我检查了btrfs的版本,确认它的版本超过5.0(文档中说低于5.0 不支持)
  8. 然后,由于我在装系统的时候点选了「交换到文件」这一选项,所以我已经有一个较小的 /swapfile,开机状态下它处于忙碌状态,所以我执行了 sudo swapoff /swapfile
  9. 接下来,由于我内存只有8G,所以我创建了8G容量的交换文件,并给它设置了权限,即执行sudo dd if=/dev/zero of=/swapfile bs=1M count=8192 status=progress``和``sudo chmod 600 /swapfile
  10. 然后格式化它并让它生效,即执行sudo mkswap /swapfile``和``sudo swapon /swapfile
  11. 然后我在 /etc/fstab 文件末尾追加了 /swapfile none swap defaults 0 0 并保存退出(给交换文件新增 fstab 的配置嘛)
  12. 我查询了我系统磁盘分区的情况,如下图,然后对 /etc/default/grub 进行了设置,即将 GRUB_CMDLINE_LINUX_DEFAULT 所在行改为了GRUB_CMDLINE_LINUX_DEFAULT=“quiet udev.log_priority=3 nowatchdog resume=UUID=f8913796-f929-449f-ad39-5f6884e648f7 resume_offset=1179648” 保存退出
  13. 最后重新执行 sudo update-grub 重新生成 grub 的配置文件
  14. 重启电脑,打开两个软件,然后点击「休眠」按钮进行系统休眠
  15. 系统确实断电关闭,但是再次点按开机键,电源指示灯闪烁了一下,然后电脑没有任何反应,依然处于断电状态,再次点按开机键,系统开机,进入系统后是电脑刚重启的样子,并没有恢复到之前的工作环境,打开浏览器,提示我浏览器未正常关闭,是否恢复之前的浏览,实锤了,休眠没有配置成功
  16. 向互联网中隐藏的大佬请教!感激不尽!

Moderator edit: Email address removed

Sorry but I can’t uploda images, The resume and resume_offset are getted by running lsblk -f and sudo filefrag -v /swapfile.