bash /etc/fstab:解析错误:忽略行中的条目

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/45237775/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 16:18:51  来源:igfitidea点击:

/etc/fstab: parse error: ignore entry at line

linuxbashfstab

提问by setevoy

I have scrip with function:

我有以下功能的脚本:

mount_share () {

    mkdir /data
    echo //$STORAGE_NAME.file.core.windows.net/$STORAGE_SHARE?/data?cifs?vers=3.0,username=$STORAGE_NAME,password=$STORAGE_KEY,dir_mode=0755,file_mode=0644,serverino >> /etc/fstab
    mount -a

}

After execution - mountreturns me an error:

执行后 -mount返回一个错误:

root@xx255rs2sptry000001:~# mount -a mount: /etc/fstab: parse error: ignore entry at line 9.

root@xx255rs2sptry000001:~# mount -a mount: /etc/fstab: parse error: ignore entry at line 9.

Same error if I'm trying to sedmanually:

如果我尝试sed手动执行相同的错误:

root@xx255rs2sptry000001:~# STORAGE_NAME=ggg
root@xx255rs2sptry000001:~# STORAGE_KEY=sakey
root@xx255rs2sptry000001:~# STORAGE_SHARE=sashare
root@xx255rs2sptry000001:~# echo //$STORAGE_NAME.file.core.windows.net/$STORAGE_SHARE?/data?cifs?vers=3.0,username=$STORAGE_NAME,password=$STORAGE_KEY,dir_mode=0755,file_mode=0644,serverino >> /etc/fstab
root@xx255rs2sptry000001:~# cat /etc/fstab 
# CLOUD_IMG: This file was created/modified by the Cloud Image build process
UUID=e990f8b3-1d6b-4615-8280-8ead4ed2fe7c       /        ext4   defaults,discard        0 0

# CLOUD_IMG: This file was created/modified by the Cloud Image build process
# The following is used to dynamically configured additional
# NICs. Do not remove unless you know what you are doing.
none /etc/network/interfaces.dynamic.d tmpfs   nodev,noexec,nosuid,size=64K 0 0
/dev/disk/cloud/azure_resource-part1    /mnt    auto    defaults,nofail,x-systemd.requires=cloud-init.service,comment=cloudconfig       0       2
//ggg.file.core.windows.net/sashare?/data?cifs?vers=3.0,username=ggg,password=sakey,dir_mode=0755,file_mode=0644,serverino
root@xx255rs2sptry000001:~# mount -a
mount: /etc/fstab: parse error: ignore entry at line 9.

I tried to close variables in "" - but no luck:

我试图关闭“”中的变量 - 但没有运气:

echo "//$STORAGE_NAME.file.core.windows.net/$STORAGE_SHARE?/data?cifs?vers=3.0,username=$STORAGE_NAME,password=$STORAGE_KEY,dir_mode=0755,file_mode=0644,serverino" >> /etc/fstab

echo "//$STORAGE_NAME.file.core.windows.net/$STORAGE_SHARE?/data?cifs?vers=3.0,username=$STORAGE_NAME,password=$STORAGE_KEY,dir_mode=0755,file_mode=0644,serverino" >> /etc/fstab

echo //"$STORAGE_NAME".file.core.windows.net/"$STORAGE_SHARE"?/data?cifs?vers=3.0,username="$STORAGE_NAME",password="$STORAGE_KEY",dir_mode=0755,file_mode=0644,serverino >> /etc/fstab

echo //"$STORAGE_NAME".file.core.windows.net/"$STORAGE_SHARE"?/data?cifs?vers=3.0,username="$STORAGE_NAME",password="$STORAGE_KEY",dir_mode=0755,file_mode=0644,serverino >> /etc/fstab

And so on.

等等。

The entry in /etc/fstablooks absolutely correct, but...

输入/etc/fstab看起来绝对正确,但是......

What I'm doing wrong here?

我在这里做错了什么?

If add mount entry manually, with vimand without variables - everything works fine.

如果手动添加挂载条目,带vim和不带变量 - 一切正常。

Azure file share documentation - here.

Azure 文件共享文档 -此处

回答by Raman Sailopal

Use:

用:

cat -v /etc/fstab

This will show any spurious character causing any problems.

这将显示导致任何问题的任何虚假字符。