我决定从使用交换分区切换到使用/swapfile.
但是有一个问题。系统仍在使用交换分区/dev/sda8,而不是/swapfile.
/swapfile使用适当的dd命令等创建了。/etc/fstab使用/swapfile而不是旧的交换分区/etc/initramfs-tools/conf.d/resume了反映resume=/swapfile/etc/default/grub没有参考恢复或交换然而,当我执行swapon -sor 时free -h,它仍然显示/dev/sda8, 而不是/swapfile。
我需要删除/dev/sda8交换分区才能工作吗?
20.04.1 是否使用它找到的任何交换分区,即使它不在/etc/fstab?
更新 #1:
只是为了记录我的/swapfile创作过程......
注意:dd命令使用不当会导致数据丢失。建议复制/粘贴。
在终端...
sudo swapoff -a # turn off swap
sudo rm -i /swapfile # remove old /swapfile
sudo dd if=/dev/zero of=/swapfile bs=1M count=4096
sudo chmod 600 /swapfile # set proper file protections
sudo mkswap /swapfile # init /swapfile
sudo swapon /swapfile # turn on swap
free -h # confirm 16G RAM and 4G swap
Run Code Online (Sandbox Code Playgroud)
/swapfile在...的末尾确认这一行,/etc/fstab并确认没有其他“交换”行...
编辑、使用sudo -H gedit /etc/fstab或sudo pico /etc/fstab
/swapfile none swap sw 0 0
Run Code Online (Sandbox Code Playgroud)
reboot # reboot and verify operation
Run Code Online (Sandbox Code Playgroud)
这是我的 /proc/swaps(从今天早上开始)...
Filename Type Size Used Priority
/dev/sda8 partition 9081852 0 -2
Run Code Online (Sandbox Code Playgroud)
这是我的适当部分/etc/fstab:
# swap was on /dev/sda8 during installation
# UUID=071f8b0e-8e16-4f4d-90ff-a4ae9cc56e2b none swap sw 0 0
/swapfile none swap sw 0 0
Run Code Online (Sandbox Code Playgroud)
这是我的/etc/initramfs-tools/conf.d/resume:
# RESUME=UUID=071f8b0e-8e16-4f4d-90ff-a4ae9cc56e2b
RESUME=/swapfile
Run Code Online (Sandbox Code Playgroud)
sudo update-initramfs -c -k $(uname -r) 没有帮助。
嗯,它是固定的。
当我尝试执行 a 时sudo swapoff -a,它在我的 /etc/fstab 中的以下行中给了我一个解析错误...
/swapfile none swap sw 0 0
Run Code Online (Sandbox Code Playgroud)
我重新输入了该行,并确保使用空格...
/swapfile none swap sw 0 0
Run Code Online (Sandbox Code Playgroud)
你看有什么不同吗?
现在一切正常!
感谢这里的所有良好反馈!
| 归档时间: |
|
| 查看次数: |
1490 次 |
| 最近记录: |