In the Terminal, the command

myuser@TomE:~$ sleep 5 && /home/myuser/mountF
works OK with mountF containing
#! /bin/bash
pkexec mount -t vfat /dev/sdb7 /home/myuser/F
. But if I place the same command in the Startup Applications dialog and check it, it does not work after I log in, even if I have unchecked the antivirus program there and disconnected external USB disks. In my home directory is a file .xsession-errors, with the logging time, containing
openConnection: connect: No such file or directory
cannot connect to brltty at :0 
. Is it related to this problem? (According to the Software Updater, my system is up to date.) Thanks!

  • 1
    use sudo rather then pkexec as mount is not a graphical tool. Also better to mount by UUID or label rather then /dev/sdb7, but that is minor. Did you configure sudo to run without a password ? Probably the best solution is to add an entry to fstab using the options noauto and users then you can mount without sudo. help.ubuntu.com/community/Fstab – Panther Aug 24 '17 at 16:54

Add this to /etc/fstab

sudo nano /etc/fstab

Add in

/dev/sdb7 /home/myuser/F vfat noauto,users,uid=1000,gid=100,dmask=027,fmask=137,utf8  0  0

Now you can mount at login with or without a script and without sudo

mount /dev/sdb7

So just run that command, mount /dev/sdb7 at login, no need for a script or anything complex.

See https://help.ubuntu.com/community/Fstab for details and other options.

  • I have changed the command in the mountF file to 'mount /dev/sdb7' only, left it checked in the Startup Applications dialog and added that '/dev/sdb7 /home/myuser/F vfat noauto,users,uid=1000,gid=100,dmask=027,fmask=137,utf8 0 0' row at the end of the /etc/fstab. After restart and login as the myuser, the directory /home/myuser/F appears to be empty. In Terminal, after the command from the question, the /home/myuser/F directory denies access. Moreover I need to use the /dev/sdb7 partition also as another user, e.g. as the root. Thanks! – Tomáš Pečený Aug 25 '17 at 10:07
  • Well, FAT partitions do not support permissions and IMO if you are using the partition as root I would mount it elsewhere. At any rate, you set the permissions at the time of mount , options would be uid=0, gid=0,dmask and fmask are probably fine. See help.ubuntu.com/community/Fstab and man mount for details or ask a new question with the details you want. – Panther Aug 25 '17 at 16:31
  • Thanks, but the mount command is not run at login even without the pkexec : the directory /home/myuser/F is then permitted for myuser. How can I achieve running a similar mounting command at login? – Tomáš Pečený Aug 25 '17 at 18:52
  • I can not tell from what you have posted and your user case seems complicated. Ask a new question, post your fstab, run the mount command in a terminal and any error. To some extent I think half your problem is permissions and the other half is you are trying to mount at login in rather then boot. – Panther Aug 25 '17 at 18:54
  • The general question about it is askubuntu.com/questions/949848/… – Tomáš Pečený Aug 25 '17 at 20:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.