sudo mount -t ntfs 抱怨仅当从 bash 完成时才不在 fstab 中

sudo mount -t ntfs complains about not being in fstab only when done from bash

我对 sudo mount -t ntfs4 server/drive /home/larry/folder 没有问题,但是当我将其放入 bash 脚本时,它会抱怨不在 fstab 中。有人可以帮我吗?

这是完整的脚本。它允许我安装或卸载驱动器。有些服务器是 Debian,有些是 Ubuntu。我的客户是 Debian 10.

#!/bin/bash

function mountit()
{
    verb=
    from=
    to=
    echo "Input is $verb $from $to"
    if [ "$verb" == "mount" ]; then
    echo "sudo mount -t nfs4 $from $to"
    sudo /bin/mount -t nfs4 "$from $to" || true
    else
    echo "sudo umount $to"
    sudo /bin/umount "$to" || true
    fi
}

verb="mount"
if [ "" == "0" ]; then
verb="umount"
fi

if [  == "umount" ]; then
verb="umount"
fi

echo "$verb drives"
echo "poseidon vhosts - webs"
mountit $verb "192.168.18.2:/var/www/vhosts" "/home/larry/webs"

echo "ramses data - data"
mountit $verb "192.168.18.8:/data" "/home/larry/data"

echo "ramses data1 - data1"
mountit $verb "192.168.18.8:/data1" "/home/larry/data1"

echo "ramses mydata - data2"
mountit $verb "192.168.18.8:/mydata" "/home/larry/data2"

echo "pavilion data1 - data3"
mountit $verb "192.168.18.66:/home/larry/data1" "/home/larry/data3"

echo "ramses data2 - data4"
mountit $verb "192.168.18.8:/data2" "/home/larry/data4"

echo "pavilion data3 - data5"
mountit $verb "192.168.18.66:/home/larry/data3" "/home/larry/data5"

替换

sudo /bin/mount -t nfs4 "$from $to"

sudo /bin/mount -t nfs4 "$from" "$to"