(メモ)CF-N10でubuntu 休止実装ログ

以下の記事で書いた内容を別のPC(CF-N10)でやったので、ログ残しておきます。

ログ

taka@cfn10:~$ sudo swapoff -a
[sudo] taka のパスワード: 
taka@cfn10:~$ free
               total        used        free      shared  buff/cache   available
Mem:        12129188     1664456     6973788      160232     3974268    10464732
Swap:              0           0           0
taka@cfn10:~$ sudo fallocate -l 12G /swapfile
taka@cfn10:~$ ls -l /swap*
-rw------- 1 root root  4294967296  19 15:31 /swap.img
-rw-r--r-- 1 root root 12884901888  111 15:36 /swapfile
taka@cfn10:~$ sudo chmod 600 /swapfile 
taka@cfn10:~$ sudo mkswap /swapfile 
スワップ空間バージョン 1 を設定します。サイズ = 12 GiB (12884897792 バイト)
ラベルはありません, UUID=77bb8fa5-015c-4692-a8c1-2dd492effbee
taka@cfn10:~$ sudo swapon /swapfile
taka@cfn10:~$ free
               total        used        free      shared  buff/cache   available
Mem:        12129188     1692208     6943968      157732     3973836    10436980
Swap:       12582908           0    12582908



taka@cfn10:~$ sudo vim /etc/fstab 

taka@cfn10:~$ cat /etc/fstab 
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sda4 during curtin installation
/dev/disk/by-uuid/8ee09f92-db5b-403c-b056-4896fbe0ef12 / ext4 defaults 0 1
/swap.img	none	swap	sw	0	0
//192.168.11.3/share /media/ls2t cifs guest,uid=1000,vers=2.0 0 0
swapfile none swap sw 0 0


taka@cfn10:~$ findmnt / -o UUID
UUID
8ee09f92-db5b-403c-b056-4896fbe0ef12
taka@cfn10:~$ sudo filefrag -v /swapfile | awk '$1=="0:" {print $4}' | sed 's/\.\.//'
4102144


taka@cfn10:~$ sudo vim /etc/default/grub
[sudo] taka のパスワード: 

taka@cfn10:~$ cat /etc/default/grub
# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
#   info -f grub -n 'Simple configuration'

#以下の3行追加 2025/1/9
GRUB_DISABLE_OS_PROBER=false
GRUB_TIMEOUT_STYLE=menu
GRUB_TIMEOUT=10

GRUB_DEFAULT=0
#以下2行コメントアウト
#GRUB_TIMEOUT_STYLE=hidden
#GRUB_TIMEOUT=0
GRUB_DISTRIBUTOR=`( . /etc/os-release; echo ${NAME:-Ubuntu} ) 2>/dev/null || echo Ubuntu`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX_DEFAULT="$GRUB_CMDLINE_LINUX_DEFAULT resume=UUID=8ee09f92-db5b-403c-b056-4896fbe0ef12 resume_offset=4102144"
GRUB_CMDLINE_LINUX=""

# If your computer has multiple operating systems installed, then you
# probably want to run os-prober. However, if your computer is a host
# for guest OSes installed via LVM or raw disk devices, running
# os-prober can cause damage to those guest OSes as it mounts
# filesystems to look for things.
#GRUB_DISABLE_OS_PROBER=false

# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

# Uncomment to disable graphical terminal
#GRUB_TERMINAL=console

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY="true"

# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"
taka@cfn10:~$ sudo update-grub
Sourcing file `/etc/default/grub'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-6.8.0-51-generic
Found initrd image: /boot/initrd.img-6.8.0-51-generic
Found memtest86+x64 image: /boot/memtest86+x64.bin
Warning: os-prober will be executed to detect other bootable partitions.
Its output will be used to detect bootable binaries on them and create new boot entries.
Found Windows 10 on /dev/sda1
Adding boot menu entry for UEFI Firmware Settings ...
done


taka@cfn10:~$ sudo ls /etc/polkit-1/rules.d/
taka@cfn10:~$ sudo vim /etc/polkit-1/rules.d/10-enable-hibernate.rules
taka@cfn10:~$ sudo ls /etc/polkit-1/rules.d/
10-enable-hibernate.rules
taka@cfn10:~$ cat /etc/polkit-1/rules.d/10-enable-hibernate.rules
cat: /etc/polkit-1/rules.d/10-enable-hibernate.rules: 許可がありません
taka@cfn10:~$ sudo cat /etc/polkit-1/rules.d/10-enable-hibernate.rules
polkit.addRule(function(action, subject) {
    if (action.id == "org.freedesktop.login1.hibernate" ||
        action.id == "org.freedesktop.login1.hibernate-multiple-sessions" ||
        action.id == "org.freedesktop.upower.hibernate" ||
        action.id == "org.freedesktop.login1.handle-hibernate-key" ||
        action.id == "org.freedesktop.login1.hibernate-ignore-inhibit") {
        return polkit.Result.YES;
    }
});


ここで再起動

ハイバーネーションテスト

taka@cfn10:~$ systemctl hibernate 
Call to Hibernate failed: Invalid argument
taka@cfn10:~$ 

う、エラー発生。あと、sudoつけなかったら、パスワード入力ウィンドウがポップアップしました。やっぱり、権限必要ですよね。

→ grubの設定のUUID間違えていました。修正して、もう一度再起動します。
→更にNG、今度は、swap領域が少ないと出ました。
なぜかというと、fstab で、swapをもう一つ設定していることが原因でした。

fstabには、こう書かれています。

/dev/disk/by-uuid/8ee09f92-db5b-403c-b056-4896fbe0ef12 / ext4 defaults 0 1 /swap.img none swap sw 0 0
//192.168.11.3/share /media/ls2t cifs guest,uid=1000,vers=2.0 0 0
swapfile none swap sw 0 0

この内、/swap.img none swap sw 0 0
が、問題で、/swap.imgが4GBのファイルでした。

fstabを修正します。
/swap.img を削除して、あと、/swapfileの行、swapfileだったのですが、絶対パスにしました。

taka@cfn10:~$ cat /etc/fstab 
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sda4 during curtin installation
/dev/disk/by-uuid/8ee09f92-db5b-403c-b056-4896fbe0ef12 / ext4 defaults 0 1
//192.168.11.3/share /media/ls2t cifs guest,uid=1000,vers=2.0 0 0
/swapfile none swap sw 0 0

さて、再起動します。
ふう、ちゃんと休止し、また、復帰しました。



いいなと思ったら応援しよう!