sudo mount -o iocharset=utf8 /dev/sdb1 /your_mount_point
例外:检查是否存在u盘驱动,有则判断是否挂载了,没挂载则挂载。
#!/bin/bash
# 检查 /dev/sdb1 是否存在
if [ -e "/dev/sdb1" ]; then
echo "Device /dev/sdb1 exists."
# 检查 /dev/sdb1 是否已挂载
if grep -q "/dev/sdb1" /proc/mounts; then
echo "Device /dev/sdb1 is already mounted."
else
echo "Device /dev/sdb1 is not mounted. Mounting..."
sudo mount -o iocharset=utf8 /dev/sdb1 /media/mjlighting/sdb1
if [ $? -eq 0 ]; then
echo "Device /dev/sdb1 successfully mounted at /media/mjlighting/sdb1."
else
echo "Failed to mount device /dev/sdb1."
fi
fi
else
echo "Device /dev/sdb1 does not exist."
fi