![BTRFS 및 커널 5.0.16-gentoo에서 최대 절전 모드용 스왑 파일 사용](https://rvso.com/image/154439/BTRFS%20%EB%B0%8F%20%EC%BB%A4%EB%84%90%205.0.16-gentoo%EC%97%90%EC%84%9C%20%EC%B5%9C%EB%8C%80%20%EC%A0%88%EC%A0%84%20%EB%AA%A8%EB%93%9C%EC%9A%A9%20%EC%8A%A4%EC%99%91%20%ED%8C%8C%EC%9D%BC%20%EC%82%AC%EC%9A%A9.png)
여기에 설명된 대로 스왑 파일을 만들었습니다.https://wiki.archlinux.org/index.php/Swap#Swap_file_creation
최대 절전 모드로 전환하려고 하면 다음 오류가 발생합니다.
$ echo disk > /sys/power/state
echo: write error: no such device
또한 dmesg에서는 다음을 얻습니다.
[30721.352822] [drm] Reducing the compressed framebuffer size. This may lead to less power savings than a non-reduced-size. Try to increase stolen memory size if available in BIOS.
[30721.454735] acpi LNXPOWER:07: Turning OFF
[30721.454987] acpi LNXPOWER:02: Turning OFF
[30721.455365] acpi LNXPOWER:01: Turning OFF
[30721.455563] PM: Cannot find swap device, try swapon -a
[30721.455563] PM: Cannot get swap writer
[30721.553943] OOM killer enabled.
[30721.553944] Restarting tasks ... done.
에 설명된 대로https://wiki.archlinux.org/index.php/Power_management/Suspend_and_hibernate#Hibernation_into_swap_file, 다음 커널 매개변수를 설정했습니다.
resume=UUID=2bfb4ccd-6b80-4806-8a08-4f1e67ef035f
resume_offset=148378880
이력서_오프셋 및 이력서 매개변수 값을 얻는 방법은 다음과 같습니다.
$ filefrag -v /swapfile
Filesystem type is: 9123683e
File size of /swapfile is 536870912 (131072 blocks of 4096 bytes)
ext: logical_offset: physical_offset: length: expected: flags:
0: 0.. 0: 148378880.. 148378880: 1:
1: 1.. 131071: 148378881.. 148509951: 131071: last,unwritten,eof
$ findmnt -no SOURCE,UUID -T /swapfile
/dev/mapper/nvme0n1p2[/root] 2bfb4ccd-6b80-4806-8a08-4f1e67ef035f
을(를 ) 사용하려고 하면 swap_offset
다음 문제가 발생합니다.
$ swap-offset /swapfile
ioctl(FIBMAP) failed: Invalid argument
그렇다면 BTRFS를 사용할 때 최대 절전 모드로 스왑 파일을 사용할 수도 있습니까? 커널이 스왑 파일의 수정 위치를 인식하지 못하는 것 같습니다.
답변1
u/hjoke(https://www.reddit.com/user/kjoke/) 내 하루를 보냈습니다 :
filefrag는 BTRFS에 대해 오프셋을 잘못 계산하지만 올바른 오프셋을 계산하는 스크립트가 있습니다.https://github.com/osandov/osandov-linux/blob/master/scripts/btrfs_map_physical.c
gcc btrfs_map_physical.c -o btrfs_map_physical
스왑 파일을 다운로드한 후 첫 번째 물리적 오프셋을 가져옵니다.
$ sudo ./btrfs-map-physical /swap | head -n2
FILE OFFSET EXTENT TYPE LOGICAL SIZE LOGICAL OFFSET PHYSICAL SIZE DEVID PHYSICAL OFFSET
0 regular 4096 607759892480 268435456 1 608833634304
여기: 608833634304
. 이 오프셋을 페이지 크기로 나눕니다.
$ getconf PAGESIZE
4096
그래서 resume_offset
입니다 608833634304 / 4096 = 148641024
. 매개변수 와 함께 이 값을 resume
커널 매개변수로 추가하고 재부팅합니다. systemd hibernate
systemd는 커널 매개변수를 무시하고 오프셋을 잘못 계산하지만 작동하기 때문에 이후에도 여전히 실패합니다 echo disk > /sys/power/state
.