Arch Linux 休眠到文件

创建文件:

# fallocate -l 4G /swapfile

# chmod 600 /swapfile

# mkswap /swapfile
# swapon /swapfile

编辑/etc/fstab文件。添加:/swapfile none swap defaults 0 0

编辑/etc/mkinitcpio.conf文件:
HOOKS="... block lvm2 resume filesystems ..."
# mkinitcpio -p linux

# filefrag -v /swapfile

查找偏移指针:

Filesystem type is: ef53
File size of /swapfile is 4294967296 (1048576 blocks of 4096 bytes)
ext: logical_offset: physical_offset: length: expected: flags:
0: 0.. 0: .. 38912: 1:
1: 1.. 22527: 38913.. 61439: 22527: unwritten
2: 22528.. 53247: 899072.. 929791: 30720: 61440: unwritten

# ls -l /dev/disk/by-uuid/ 查看swapfile文件所在盘的UUID。
lrwxrwxrwx 1 root root 10 Aug  8 19:22 415bb7cf-5a71-4481-a832-c789643ce12c -> ../../sda4

GRUB配置:

# vim /etc/default/grub

GRUB_CMDLINE_LINUX_DEFAULT="resume=/dev/disk/by-uuid/415bb7cf-5a71-4481-a832-c789643ce12c resume_offset= quiet"

参考:https://wiki.archlinux.org/index.php/Hibernate#Hibernation_into_swap_file

https://wiki.archlinux.org/index.php/Swap#Swap_file

上一篇:LibreOJ #2036. 「SHOI2015」自动刷题机


下一篇:Default Web Site