最近遇到了一些系統問題。當我嘗試掛載 /dev/sdc1
(100GB) 到根目錄時,發生了一些問題,系統顯示為只讀文件系統。
Read-only file system 發生連串問題
Read-only file system 問題
當嘗試創建文件時,系統顯示為只讀文件系統:
1
2
|
user:~$ touch test
touch: cannot touch 'test': Read-only file system
|
解決方法
在網路上找到解決方法,可以使用以下指令重新掛載根目錄為可讀寫模式:
1
|
sudo mount -o remount,rw /
|
DNS 問題
在嘗試 ping Google 或進行 git pull 操作時,出現 DNS 錯誤:
1
2
3
4
5
6
7
8
9
|
ping google.com
# ping: google.com: Temporary failure in name resolution
git pull
# ssh: Could not resolve hostname github.com: Temporary failure in name resolution
# fatal: Could not read from remote repository.
#
# Please make sure you have the correct access rights
# and the repository exists.
|
這個問題是由於 DNS 無效造成的。
解決方法
可以通過修改 /etc/systemd/resolved.conf
文件來解決這個問題:
1
2
3
4
5
6
7
|
vim /etc/systemd/resolved.conf
# 寫 DNS
DNS=1.1.1.1 1.0.0.1
FallbackDNS=8.8.8.8 8.8.4.4
sudo systemctl restart systemd-resolved
|
Tip
但後續解決這個問題,其實系統是空的,不知道他抓到是什麼地方 DNS。
1
2
3
4
5
6
7
8
9
10
11
12
13
|
Server: 127.0.0.53
Address: 127.0.0.53#53
Non-authoritative answer:
tw.yahoo.com canonical name = fp-ycpi.g03.yahoodns.net.
Name: fp-ycpi.g03.yahoodns.net
Address: 180.222.119.248
Name: fp-ycpi.g03.yahoodns.net
Address: 180.222.119.247
Name: fp-ycpi.g03.yahoodns.net
Address: 2406:2000:a4:807::1
Name: fp-ycpi.g03.yahoodns.net
Address: 2406:2000:a4:807::
|
Docker 啟動錯誤:failed to start daemon
docker 發生 failed to start daemon: failed to dial “/run/containerd/containerd.sock”: Unimplemented: unknown service containerd.services.namespaces.v1.Namespaces: not implemented 錯誤
1
|
root# systemctl stop containerd && systemctl start containerd && systemctl start docker.service
|
然後docker就能使用了。
最後重開機又會發生 Read-only file system
,查看 /etc/fstab
讀取硬碟發生 error 會進到 read-only
模式,所以目前推估是這樣造成的。
深入探討
網路看到 Read-only file system
解法都是用 sudo mount -o remount,rw /
可以解決;但上面說過重開機這個問題就會出現了,我看到 /etc/fstab
有 errors=remount-ro
設定,導致磁區變成 read-only
模式。
1
2
3
4
|
# CLOUD_IMG: This file was created/modified by the Cloud Image build process
UUID=358b6661-aad0-485d-8424-6d1f2193f2a1 / ext4 discard,errors=remount-ro 0 1
UUID=A9BC-232B /boot/efi vfat umask=0077 0 1
/dev/disk/cloud/azure_resource-part1 /mnt auto defaults,nofail,x-systemd.after=cloud-init.service,_netdev,comment=cloudconfig 0 2
|
我從 ./bash_history
看到
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
sudo -s
df -h
df -h
mount /dev/sdc1 /
blkid
mount /dev/sdc1 /
df -h
blkid
parted /dev/sdc --script mklabel gpt mkpart xfspart ext4 0% 100%
sudo -s
lsblk -o NAME,HCTL,SIZE,MOUNTPOINT | grep -i "sd"
df -h
sudo blkid
lsblk
mount /dev/sda1 /
sudo -s
df -h
sudo -s
df -h
vi /etc/fstab
sudo -s
df -h
|
我的認知 /
根目錄是不能unmount
,這時候 MIS 有說 /
是樹狀結構可以mount
,最後重用主機就沒有這個問題。目前猜想掛根目錄所發生問題,但目前不知道發生什麼問題造成,重灌系統就可以順利解決。
/ can’t be unmounted from the system, as / is in use (thus the message you see) by the system itself.
You will need to do this procedure from a Live-CD.
參考來源: ubuntu - How to umount / ? It’s busy - Super User