我正在尝试在笔记本电脑上的 ubuntu 18 上添加休眠功能。有 3 个磁盘,ssd m2、ssd 和 sd-card。之前SSD m2上有windows 10,SSD上有ubuntu;现在我的SSD M2上只有一个ubuntu。所以我创建了 10gb 交换文件:
fjod@fjod-HP-Laptop-15-db1xxx:~$ swapon --show
NAME TYPE SIZE USED PRIO
/swapfile file 9,8G 0B -2
fjod@fjod-HP-Laptop-15-db1xxx:~$ ls -l /dev/disk/by-uuid/
total 0
lrwxrwxrwx 1 root root 15 фев 6 16:36 18f88db1-b367-45b1-9444-0f2ca150583b -> ../../nvme0n1p2
lrwxrwxrwx 1 root root 15 фев 6 16:36 513E-F188 -> ../../nvme0n1p1
lrwxrwxrwx 1 root root 10 фев 6 16:36 a1c2f79e-34ac-410e-b110-ba52f526face -> ../../sda1
fjod@fjod-HP-Laptop-15-db1xxx:~$ cat /proc/swaps
Filename Type Size Used Priority
/swapfile file 10239996 0 -2
fjod@fjod-HP-Laptop-15-db1xxx:~$ grep swap /etc/fstab
/swapfile none swap sw 0 0
/swapfile none swap sw 0 0
fjod@fjod-HP-Laptop-15-db1xxx:~$ cd / && ls -l swapfile
-rw------- 1 root root 10485760000 фев 6 16:33 swapfile
fjod@fjod-HP-Laptop-15-db1xxx:/$ cat /etc/fstab | grep -i swap
/swapfile none swap sw 0 0
/swapfile none swap sw 0 0
现在我需要添加它的 UUID 以使休眠工作正常,所以:
fjod@fjod-HP-Laptop-15-db1xxx:/$ sudo blkid
/dev/loop0: TYPE="squashfs"
/dev/loop1: TYPE="squashfs"
/dev/loop2: TYPE="squashfs"
/dev/loop3: TYPE="squashfs"
/dev/loop4: TYPE="squashfs"
/dev/loop5: TYPE="squashfs"
/dev/loop6: TYPE="squashfs"
/dev/loop7: TYPE="squashfs"
/dev/nvme0n1: PTUUID="e5f2647b-98c1-45cd-93c1-4bdeb2bd11d1" PTTYPE="gpt"
/dev/nvme0n1p1: UUID="513E-F188" TYPE="vfat" PARTLABEL="EFI System Partition" PARTUUID="20210fff-3590-4c0f-826c-e64cb03894a8"
/dev/nvme0n1p2: UUID="18f88db1-b367-45b1-9444-0f2ca150583b" TYPE="ext4" PARTUUID="ce5ffbc2-5f80-4d12-9167-34d2b9676755"
/dev/sda1: UUID="a1c2f79e-34ac-410e-b110-ba52f526face" TYPE="ext4" PARTLABEL="kingston" PARTUUID="6e777b1f-a124-4821-8bae-c1b956e7e3fe"
/dev/loop8: TYPE="squashfs"
/dev/loop9: TYPE="squashfs"
/dev/loop10: TYPE="squashfs"
/dev/loop11: TYPE="squashfs"
/dev/loop12: TYPE="squashfs"
/dev/loop13: TYPE="squashfs"
/dev/loop14: TYPE="squashfs"
/dev/loop15: TYPE="squashfs"
/dev/loop16: TYPE="squashfs"
/dev/loop17: TYPE="squashfs"
/dev/loop18: TYPE="squashfs"
/dev/loop19: TYPE="squashfs"
/dev/loop20: TYPE="squashfs"
/dev/loop21: TYPE="squashfs"
/dev/loop22: TYPE="squashfs"
/dev/sdb1: TYPE="exfat"
fjod@fjod-HP-Laptop-15-db1xxx:/$ grep swap /etc/fstab
/swapfile none swap sw 0 0
/swapfile none swap sw 0 0
但我在任何地方都没有看到它的 UUID。我应该怎么办?看起来我在磁盘上的某个地方有交换文件,但如何将休眠指向它?
----------编辑1--------------------
使用本教程
fjod@fjod-HP-Laptop-15-db1xxx:~$ mount | grep " / "
/dev/nvme0n1p2 on / type ext4 (rw,relatime,errors=remount-ro)
fjod@fjod-HP-Laptop-15-db1xxx:~$ sudo blkid -g
[sudo] password for fjod:
fjod@fjod-HP-Laptop-15-db1xxx:~$ sudo blkid -g
fjod@fjod-HP-Laptop-15-db1xxx:~$ sudo blkid
/dev/loop0: TYPE="squashfs"
/dev/loop1: TYPE="squashfs"
/dev/loop2: TYPE="squashfs"
/dev/loop3: TYPE="squashfs"
/dev/loop4: TYPE="squashfs"
/dev/loop5: TYPE="squashfs"
/dev/loop6: TYPE="squashfs"
/dev/loop7: TYPE="squashfs"
/dev/nvme0n1: PTUUID="e5f2647b-98c1-45cd-93c1-4bdeb2bd11d1" PTTYPE="gpt"
/dev/nvme0n1p1: UUID="513E-F188" TYPE="vfat" PARTLABEL="EFI System Partition" PARTUUID="20210fff-3590-4c0f-826c-e64cb03894a8"
/dev/nvme0n1p2: UUID="18f88db1-b367-45b1-9444-0f2ca150583b" TYPE="ext4" PARTUUID="ce5ffbc2-5f80-4d12-9167-34d2b9676755"
/dev/sda1: UUID="a1c2f79e-34ac-410e-b110-ba52f526face" TYPE="ext4" PARTLABEL="kingston" PARTUUID="6e777b1f-a124-4821-8bae-c1b956e7e3fe"
所以 id = 18f88db1-b367-45b1-9444-0f2ca150583b 偏移量:
od@fjod-HP-Laptop-15-db1xxx:~$ sudo filefrag -v /swapfile
Filesystem type is: ef53
File size of /swapfile is 10485760000 (2560000 blocks of 4096 bytes)
ext: logical_offset: physical_offset: length: expected: flags:
0: 0.. 8191: 50290688.. 50298879: 8192:
1: 8192.. 10239: 50302976.. 50305023: 2048: 50298880:
2: 10240.. 14335: 50307072.. 50311167: 4096: 50305024:
3: 14336.. 38911: 50472960.. 50497535: 24576: 50311168:
4: 38912.. 45055: 50505728.. 50511871: 6144: 50497536:
到底 :
fjod@fjod-HP-Laptop-15-db1xxx:~$ cat /etc/initramfs-tools/conf.d/resume
resume=UUID=18f88db1-b367-45b1-9444-0f2ca150583b resume_offset=50290688
/etc/默认/grub:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash resume=UUID=18f88db1-b367-45b1-9444-0f2ca150583b resume_offset=50290688"
我尝试休眠,但计算机根本无法启动。
------------编辑2--------------
我发现了另一个很棒的教程这里,现在它休眠得很好,但休眠后电源仍然打开,我必须使用电源按钮关闭笔记本电脑。打开后,我看到我的程序启动了。
-------------编辑3------------------------
从休眠状态恢复的效率是 50/50,而且速度慢得令人痛苦。最后,我不会使用它(叹气)。
答案1
答案2
您应该使用的 UUID 是您的“/”所在的位置,在您的情况下,它似乎是 /dev/sda1,UUID 为 a1c2f79e-34ac-410e-b110-ba52f526face”。