系统未启动 - 无法激活交换 /swapfile

Jor*_*man 6 partitioning boot 20.04

到昨天为止,我 100% 是 Linux 新手,我似乎做错了什么。昨晚我让系统启动并运行,没有明显问题,但今天当我尝试启动时出现错误,整个过程失败。

一些背景:我的电脑有一个 500 GB 的 SSD,它是 Ubuntu(版本 20.04.1)安装的,还有一个 2TB 的 HDD,我昨晚格式化了它以供使用。我怀疑我的问题与该事实有关,因为在格式化之前我能够多次重新启动系统而没有问题。不幸的是,我对 Ubuntu 知之甚少,甚至不知道从哪里开始,而且我似乎无法在网上找到针对我的特定情况的任何帮助。

在启动时,我会看到 3 个选项

  • Ubuntu
  • ubuntu 的高级选项
  • UEFI 固件设置

这是我在选择 Ubuntu 后得到的具体输出:

    [Failed] Failed to activate swap /swapfile
    [Depend] Dependency failed for Swap
Run Code Online (Sandbox Code Playgroud)

让我知道是否有与该问题相关的任何其他信息,或者是否有任何我应该尝试的信息。感谢所有建议。

以下是在 root 访问中运行推荐命令的输出:

    grep -i swap /etc/fstab
    /swapfile          none          swap    sw          0     0

    ls -al /swapfile
    -rw------- 1 root root 2147483648 Sep 24 03:41 /swapfile
Run Code Online (Sandbox Code Playgroud)

hey*_*ema 5

一切看起来都很正常,但让我们重新创建 /swapfile。

\n

像刚才一样启动到恢复模式,然后执行以下操作...

\n

注意:命令使用不当dd可能会导致数据丢失。建议复制/粘贴。

\n

terminal(或 root # 提示符)...

\n
sudo swapoff -a           # turn off swap\nsudo rm -i /swapfile      # remove old /swapfile\n\nsudo dd if=/dev/zero of=/swapfile bs=1M count=4096\n\nsudo chmod 600 /swapfile  # set proper file protections\nsudo mkswap /swapfile     # init /swapfile\nsudo swapon /swapfile     # turn on swap\nfree -h                   # confirm nnG RAM and 4G swap\n
Run Code Online (Sandbox Code Playgroud)\n

确认 /etc/fstab 末尾的 /swapfile 行...并确认没有其他 \xe2\x80\x9cswap\xe2\x80\x9d 行...

\n

要编辑、使用sudo -H gedit /etc/fstabsudo pico /etc/fstab

\n
/swapfile \xc2\xa0 \xc2\xa0none \xc2\xa0 \xc2\xa0swap \xc2\xa0 \xc2\xa0sw \xc2\xa0 \xc2\xa0 \xc2\xa00   0\n
Run Code Online (Sandbox Code Playgroud)\n
\n
reboot                    # reboot and verify operation\n
Run Code Online (Sandbox Code Playgroud)\n

更新#1:

\n

/etc/fstab 被搞乱并导致文件系统变为只读。新安装的 Ubuntu 只用了 1 个小时,所以我建议再次重新安装 Ubuntu。

\n
UUID="fae3ba3a-abaf-4eca-8139-40d5328d017c" /srv ext4 errors=remount-ro 0\n
Run Code Online (Sandbox Code Playgroud)\n