• 欢迎光临~

linux添加新硬盘自动挂载目录

开发技术 开发技术 2022-08-06 次浏览
mountdisk(){
    if [ ! -e /dev/storage ];then
    pvcreate $1
    vgcreate storage $1
    lvcreate -n lv1 -l 100%FREE storage
    mkfs.ext4 /dev/storage/lv1
    mkdir /appdata
    sed -i '$a /dev/storage/lv1 /appdata ext4 defaults 0 0' /etc/fstab
    mount -a
    df -h
    else
    echo "vggroup name storage has existed"
    fi
}

strlsblk=`lsblk |awk '{print $1}'|tr "n" ":"`
for i in `lsblk |grep disk|awk '{print $1}'`
do
  key=$i":├""|"$i":└"
  if [ -z `echo $strlsblk | grep -E $key` ];then
    disk='/dev/'$i
    mountdisk $disk
  fi
done




程序员灯塔
转载请注明原文链接:linux添加新硬盘自动挂载目录
喜欢 (0)