1

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 - mount returns me an error:

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

Same error if I'm trying to sed manually:

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

And so on.

The entry in /etc/fstab looks absolutely correct, but...

What I'm doing wrong here?

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

Azure file share documentation - here.

setevoy
  • 4,374
  • 11
  • 50
  • 87
  • 1
    cat out /etc/fstab with -v to make sure there are no spurious characters in there. – Raman Sailopal Jul 21 '17 at 12:42
  • Also you have no firth and sixth fields i.e. 0 and 0. – Raman Sailopal Jul 21 '17 at 12:45
  • @RamanSailopal Thanks! `cat -v` show me the problem: `//ggg.file.core.windows.net/sashareM-BM- /dataM-BM- cifsM-BM- vers=3.0,username=ggg,password=sakey,dir_mode=0755,file_mode=0644,serverino` Not shure yet where `M-BM-` came from but this is the reason. Could you add you comment as answer? – setevoy Jul 21 '17 at 12:49

1 Answers1

9

Use:

cat -v /etc/fstab

This will show any spurious character causing any problems.

Raman Sailopal
  • 12,320
  • 2
  • 11
  • 18
  • Cool. helped with problem copying nfs mount line from fstab help page on a wiki (vi and terminal copy/paste gnome). cat -v showed: '192.168.128.100:/vol/dataM-BM- M-BM- M-BM- M-BM- M-BM- /dataM-BM- M-BM- M-BM- M-BM- M-BM- nfs'. Removing the apparent whitespace and replacing with one space solved it. – gaoithe Jan 20 '20 at 15:45