秋栈博客

七月

处理阿里云ECS挂载,前台未报错目录未挂载

3
2023-02-02

处理挂载目录,前台不报错,目录未挂载。

背景

处理今天新开的几台阿里云ECS中硬盘未挂载问题。
$ lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
vda    253:0    0   50G  0 disk
└─vda1 253:1    0   50G  0 part /
vdb    253:16   0  100G  0 disk

$ mount /dev/vdb /data/

$ df -Th
Filesystem     Type      Size  Used Avail Use% Mounted on
devtmpfs       devtmpfs  3.7G     0  3.7G   0% /dev
tmpfs          tmpfs     3.7G     0  3.7G   0% /dev/shm
tmpfs          tmpfs     3.7G  532K  3.7G   1% /run
tmpfs          tmpfs     3.7G     0  3.7G   0% /sys/fs/cgroup
/dev/vda1      ext4       50G  2.7G   45G   6% /
tmpfs          tmpfs     756M     0  756M   0% /run/user/0

排查原因

$ tail -10 /var/log/messages

Feb  6 09:50:01 hangzhou208226 systemd: Started Session 9 of user root.
Feb  6 09:50:01 hangzhou208226 systemd: Started Session 10 of user root.
Feb  6 09:50:08 hangzhou208226 kernel: EXT4-fs (vdb): mounted filesystem with ordered data mode. Opts: (null)
Feb  6 09:50:08 hangzhou208226 systemd: Unit data.mount is bound to inactive unit dev-disk-by\x2duuid.device. Stopping, too.
Feb  6 09:50:08 hangzhou208226 systemd: Unmounting /data...
Feb  6 09:50:08 hangzhou208226 systemd: Unmounted /data.
Feb  6 09:50:19 hangzhou208226 systemd: Unit data.mount is bound to inactive unit dev-disk-by\x2duuid.device. Stopping, too.
Feb  6 09:50:19 hangzhou208226 kernel: EXT4-fs (vdb): mounted filesystem with ordered data mode. Opts: (null)
Feb  6 09:50:19 hangzhou208226 systemd: Unmounting /data...
Feb  6 09:50:19 hangzhou208226 systemd: Unmounted /data.
查看到fstab中有一条无效的挂载信息,判断是自动化脚本在阿里云ECS云盘还未生效时执行了判断。
$ cat /etc/fstab

#
# /etc/fstab
# Created by anaconda on Wed Aug 24 06:13:12 2022
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=4f4de78b-e926-4e41-9ab6-0643a8eed46f /                       ext4    defaults        1 1
UUID=                                     /data                   ext4    defaults        0 0

解决方案

删除无效挂载信息,重启守护进程后挂载。
$ systemctl daemon-reload
查看硬盘UUID
$ blkid
/dev/vda1: UUID="4f4de78b-e926-4e41-9ab6-0643a8eed46f" TYPE="ext4"
/dev/vdb: UUID="9830b39c-8120-4fa0-a923-dacccc5b57da" TYPE="ext4"

$ cat /etc/fstab
UUID=4f4de78b-e926-4e41-9ab6-0643a8eed46f /           ext4    defaults        1 1
UUID=9830b39c-8120-4fa0-a923-dacccc5b57da /data       ext4    defaults        0 0
执行挂载命令
$ mount -a
$ df -Th
Filesystem     Type      Size  Used Avail Use% Mounted on
devtmpfs       devtmpfs  3.7G     0  3.7G   0% /dev
tmpfs          tmpfs     3.7G     0  3.7G   0% /dev/shm
tmpfs          tmpfs     3.7G  532K  3.7G   1% /run
tmpfs          tmpfs     3.7G     0  3.7G   0% /sys/fs/cgroup
/dev/vda1      ext4       50G  2.7G   45G   6% /
tmpfs          tmpfs     756M     0  756M   0% /run/user/0
/dev/vdb       ext4       99G   61M   94G   1% /data
 
  • 0