Ubuntu 20.04 Raspberry Pi - 无法写入任何内容,每个文件似乎都是只读的

Ubuntu 20.04 Raspberry Pi - 无法写入任何内容,每个文件似乎都是只读的

我目前正在跑步Ubuntu 20.04(服务器,不是桌面)在我的树莓派我注意到似乎什么都不起作用。我能够通过 SSH 进入我的设备,但我发现的第一个问题是“每日消息”没有出现。通常,我会收到一条消息,显示设备的温度、存储空间、负载等。但现在,当我通过 SSH 进入我的 Pi 时,我只能看到我上次登录的日期和时间。

当我在主目录中时,我尝试用 创建一个新文本文件sudo nano。Nano 打开了,但在底部显示[Directory '.' is not writable]

当我尝试执行时sudo apt update,我得到以下信息:

ubuntu@ubuntu:~$ sudo apt update
Err:1 http://ports.ubuntu.com/ubuntu-ports focal InRelease
  Temporary failure resolving 'ports.ubuntu.com'
Err:2 http://ports.ubuntu.com/ubuntu-ports focal-updates InRelease
  Temporary failure resolving 'ports.ubuntu.com'
Err:3 http://ports.ubuntu.com/ubuntu-ports focal-backports InRelease
  Temporary failure resolving 'ports.ubuntu.com'
Err:4 http://ports.ubuntu.com/ubuntu-ports focal-security InRelease
  Temporary failure resolving 'ports.ubuntu.com'
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.
W: chown to _apt:root of directory /var/lib/apt/lists/partial failed - SetupAPTPartialDirectory (30: Read-only file system)
W: chmod 0700 of directory /var/lib/apt/lists/partial failed - SetupAPTPartialDirectory (30: Read-only file system)
W: chown to _apt:root of directory /var/lib/apt/lists/auxfiles failed - SetupAPTPartialDirectory (30: Read-only file system)
W: chmod 0700 of directory /var/lib/apt/lists/auxfiles failed - SetupAPTPartialDirectory (30: Read-only file system)
W: Not using locking for read only lock file /var/lib/apt/lists/lock
W: Problem unlinking the file /var/lib/apt/lists/partial/.apt-acquire-privs-test.qi7Ajt - IsAccessibleBySandboxUser (30: Read-only file system)
W: Problem unlinking the file /var/lib/apt/lists/partial/.apt-acquire-privs-test.VGXMSt - IsAccessibleBySandboxUser (30: Read-only file system)
W: Problem unlinking the file /var/lib/apt/lists/partial/.apt-acquire-privs-test.GdwBDs - IsAccessibleBySandboxUser (30: Read-only file system)
W: Problem unlinking the file /var/lib/apt/lists/partial/.apt-acquire-privs-test.zJIneu - IsAccessibleBySandboxUser (30: Read-only file system)
W: Problem unlinking the file /var/lib/apt/lists/partial/ports.ubuntu.com_ubuntu-ports_dists_focal_InRelease - PrepareFiles (30: Read-only file system)
W: Problem unlinking the file /var/lib/apt/lists/partial/ports.ubuntu.com_ubuntu-ports_dists_focal-updates_InRelease - PrepareFiles (30: Read-only file system)
W: Problem unlinking the file /var/lib/apt/lists/partial/ports.ubuntu.com_ubuntu-ports_dists_focal-backports_InRelease - PrepareFiles (30: Read-only file system)
W: Problem unlinking the file /var/lib/apt/lists/partial/ports.ubuntu.com_ubuntu-ports_dists_focal-security_InRelease - PrepareFiles (30: Read-only file system)
W: Failed to fetch http://ports.ubuntu.com/ubuntu-ports/dists/focal/InRelease  Temporary failure resolving 'ports.ubuntu.com'
W: Failed to fetch http://ports.ubuntu.com/ubuntu-ports/dists/focal-updates/InRelease  Temporary failure resolving 'ports.ubuntu.com'
W: Failed to fetch http://ports.ubuntu.com/ubuntu-ports/dists/focal-backports/InRelease  Temporary failure resolving 'ports.ubuntu.com'
W: Failed to fetch http://ports.ubuntu.com/ubuntu-ports/dists/focal-security/InRelease  Temporary failure resolving 'ports.ubuntu.com'
W: Some index files failed to download. They have been ignored, or old ones used instead.
W: Problem unlinking the file /var/cache/apt/pkgcache.bin - RemoveCaches (30: Read-only file system)
W: Problem unlinking the file /var/cache/apt/srcpkgcache.bin - RemoveCaches (30: Read-only file system)

这让我相信我的整个系统现在都是只读的。当我在 Nextcloud(使用 Docker 托管)上移动一些文件时,这种情况开始发生,我的设备冻结了。我别无选择,只能拔掉插头,现在一切都被锁定了。我该怎么做才能解决这个问题?不确定这是否有用,但我的 Nextcloud 文件存储在我的外部硬盘上,而我的 Ubuntu 存储在我的 microSD 上。

答案1

我找到了解决方案。结果发现我的 microSD 卡可能已损坏。我做了以下操作:

  1. 将另一个操作系统(在我的情况下是 Raspbian 操作系统)安装到单独的 USB 驱动器中
  2. 拔下损坏的 microSD 并插入装有 Raspbian OS 的 USB 记忆棒
  3. 从 USB 启动我的 Raspberry Pi
  4. 插入损坏的 microSD
  5. 运行sudo fdisk -l以查找我的 microSD(就我而言,它是/dev/mmcblk0p1/dev/mmcblk0p2
  6. 运行sudo fsck -y /dev/mmcblk0p1sudo fsck -y /dev/mmcblk0p2然后它会尝试修复在我的 microSD 上发现的任何损坏。
  7. 重新插入 microSD 后一切就会恢复正常。

相关内容