USBMount not mounting problem


I had a portable harddisk connected using USB to my Raspberry Pi B+ Rev3 running Raspbian 9. The harddisk had two partitions: NTFS and ext4. I had usbmount installed and configured as described here. When Raspbian is booted up with the harddisk already plugged in, I could see using sudo fdisk -l that the ext4 partition was visible. So, usbmount should have automatically mounted this ext4 partition to /media/usb0, but it was not doing that.

I had verbose logging enabled for usbmount as described here. When I searched the system log I could see that usbmount was actually mounting the ext4 partition, but surprisingly it was not visible at /media/usb0:

$ cat /var/log/syslog | grep usbmount
980:May 18 11:42:28 my-pi usbmount[373]: /dev/sda2 contains filesystem type ext4
989:May 18 11:42:28 my-pi usbmount[373]: mountpoint /media/usb0 is available for /dev/sda2
991:May 18 11:42:28 my-pi usbmount[373]: executing command: mount -text4 -osync,noexec,nodev,noatime,nodiratime /dev/sda2 /media/usb0
1010:May 18 11:42:28 my-pi usbmount[373]: executing command: run-parts /etc/usbmount/mount.d
1013:May 18 11:42:28 my-pi usbmount[373]: usbmount execution finished


Turned out that systemd was the culprit. It was having a MountFlags=slave in its systemd-udevd.service file. So, the mount operation of usbmount was mounting into the namespace of systemd and not to the user.

To change this mount option, run this command:

$ sudo systemctl edit systemd-udevd

Add these lines to the file that is opened:


I found that this created the file /etc/systemd/system/systemd-udevd.service.d/override.conf with the above lines.

Restart systemd or your Pi:

$ sudo systemctl daemon-reload
$ sudo service systemd-udevd --full-restart

After the restart, I found that usbmount had automatically mounted my ext4 partition.


NFS error access denied by server while mounting


I wanted to share a directory that was on my local computer to a remote computer named medusa using NFS. I did the setup of the NFS server on my local computer and NFS client on the remote computer as described here. However, when I mounted the NFS share on the remote computer, I got this error:

$ sudo mount /mnt/my_nfs_share
mount.nfs: access denied by server while mounting my-local-computer:/path/i/shared


This turned out to be tricky one! The error message is quite a bit misleading because it turned out that the problem had nothing to do with access. Turns out this remote computer medusa had two Ethernet cards and thus two IP addresses. One of the IP addresses was set to the hostname medusa, but the NFS client was using the second IP address.

The solution was to add the second IP address as an entry in the /etc/exports file:

/path/i/shared medusa(rw,sync,no_subtree_check)

The rest of the steps I repeated as described in this post. Everything worked fine and I was able to mount the NFS share on the remote computer.


Tried with: Ubuntu 14.04

How to view NFS mount options

If your NFS directory is automatically mounted at boot, then find its mount options in /etc/fstab. There might be options such as defaults which are expanded to actual options at mount. These can be found in its actual mounted entry in /etc/mtab. For example, using defaults on my machine expands to rw,vers=4,addr=nfs_server_ip,clientaddr=nfs_client_addr

If it is mounted manually at the shell, then find its mount options in /etc/mtab.

How to mount and unmount ISO or IMG in Windows

Windows 8 or 10

Since Windows 8, there has been support in the OS for mounting an ISO or IMG file to a drive letter.

  • To mount, open Powershell and use Mount-DiskImage command:
$ Mount-DiskImage -ImagePath C:\MyFiles\foo.iso

Remember that you need to provide the full path to the file. The file will be mounted on the lowest available drive letter.

  • To unmount, open a command prompt with administrator privileges and use the mountvol command:
$ mountvol F: /d

Windows 7 and older

Windows 7 and older versions of Windows do not have internal support for mounting ISO or IMG file. Use the Virtual CloneDrive tool as described here to mount and unmount.

How to configure USBMount

USBMount is a useful program and daemon that can be used to automount disk drives and flash drives plugged into USB ports. I use it with Raspbian for this purpose.

All the settings of USBMount can be changed from its configuration file /etc/usbmount/usbmount.conf

The parameters that can be modified from this file:

  • ENABLED: 1 to enable, 0 to disable USBMount.

  • MOUNTPOINTS: String of space-delimited mount points that should be used.

  • FILESYSTEMS: String of space-delimited filesystems that should be mounted.

  • MOUNTOPTIONS: String of comma-delimited mount options that will be used with the mount program to mount all the filesystems.

  • FS_MOUNTOPTIONS: Mount options that are specific to particular filesystem.

  • VERBOSE: no is brief logging to /var/syslog, yes is verbose logging. I like to change to yes so that it is easy to diagnose usbmount problems by looking at the syslog.

Tried with: USBMount 0.0.22 and Raspbian 7

How to mount Moto G on Ubuntu using MTP

Moto G is an Android smartphone that does not have a microSD slot. So, the storage of the smartphone cannot be extended. If you want to transfer files between your Ubuntu computer and the Moto G, there are 3 possible ways to do that: FTP over wireless, PTP over USB and MTP over USB.

If your Ubuntu computer has wireless, I highly recommend using FTP over wireless. It is convenient (no wires!), offers good transfer speed and the entire /sdcard contents are available for read and write.

If your Ubuntu computer does not have wireless, then your next option is to use a micro-USB-to-USB cable. The choices here are PTP and MTP. You can enable and switch between the two after you connect Moto G to your computer using a USB cable. If you enable PTP, then Moto G is automatically mounted as a partition in Nautilus. However, you will only be able to see the /sdcard/DCIM and /sdcard/Pictures directories. If you are transferring photos, then this option offers good transfer speed.

If your Ubuntu computer does not have wireless and you still want to read and write to the contents of /sdcard then the option left to you is MTP. Note that with MTP, Moto G takes a really long time to mount and the transfer speeds are really really low. It can take ages to transfer even a small file. You have been warned! πŸ™‚

There are many solutions offered online to mount the contents of /sdcard using MTP. This solution is the only one that worked for me:

  • Install the MTP packages:
$ sudo apt-get install mtp-tools mtpfs
  • Connect Moto G using a USB cable to your computer. Make sure MTP is selected, and not PTP.

  • Find out the vendor ID and product ID of Moto G using mtp-detect. For my smartphone I got:

$ sudo mtp-detect
Unable to open ~/.mtpz-data for reading, MTPZ disabled.libmtp version: 1.1.3

Listing raw device(s)
Device 0 (VID=22b8 and PID=2e82) is UNKNOWN.
Please report this VID/PID and the device model to the libmtp development team
 Β Β Found 1 device(s):
 Β Β 22b8:2e82 @ bus 1, dev 12
Attempting to connect device(s)
Android device detected, assigning default bug flags

You need to press Ctrl+C to stop the command. For the Moto G, you can see that the vendor ID is 22b8 and product ID is 2e82.

  • Open a new file /etc/udev/rules.d/51-android.rules using sudo and add this line:
SUBSYSTEM=="usb", ATTR{idVendor}=="22b8", ATTR{idProduct}=="2e82", MODE="0666"
  • Restart the USB service and create a directory to mount the Moto G:
$ sudo service udev restart
$ sudo mkdir /media/motog
$ sudo chmod a+rwx /media/motog
$ sudo adduser your-user-name fuse
  • Open the /etc/fuse.conf file as sudo and uncomment the line for user_allow_other

  • Restart your computer. Connect back the Moto G to the computer.

  • You can now mount the /sdcard of your Moto G using this command:

$ mtpfs -o allow_other /media/motog/

Note that the mounting operation is slow and might take about a minute.

  • You can find all the directories and files in /sdcard of Moto G in /media/motog. You can read and write to these directories.

  • To unmount use this command:

$ fusermount -u /media/motog/

That is it! You may want to create aliases for the mount and unmount command to make it easy to use πŸ™‚

Note: You will not get the USB mass storage option in Moto G since that can be provided for external storage, not for partitions from which the Linux kernel is currently running. And in any case, you will need root access on the phone to touch those directories.

Tried with: Moto G and Ubuntu 12.04

How to remove duplicate entry in Devices list in Nautilus


The Devices list shown at the top of the Sidebar in Nautilus lists the other partitions found in the hard disk or any other storage devices plugged into the computer. Since I dual-boot between Windows and Ubuntu, the Devices list shows the NTFS partitions on the hard disk. I added a line to /etc/fstab to mount one of my NTFS partitions automatically at boot. After I did this, the Devices list in Nautilus started to show a duplicate entry for this partition, with one of it mounted and the other unmounted.


There seems to be a simple solution to this bizarre problem. The fstab entry I am using to mount the NTFS partition uses the UUID of the partition. Replacing this with the old style /dev/sda partition name fixed this problem.

For example, my fstab entry read UUID=A5190634180941Z5. I changed that to /dev/sda5 You can list the dev and UUID entries for all your partitions by using the command sudo blkid

Tried with: Ubuntu 12.04.2 LTS

How to mount or unmount a ISO file in Ubuntu

One option to mount and unmount ISO files in Ubuntu is to use the fuseiso package. First install the package using the name fuseiso.

To mount a ISO file, first create a directory where it can be mounted and then mount it:

$ mkdir dir-to-mount-iso
$ fuseiso foo-disc.iso dir-to-mount-iso

To unmount the ISO file, unmount the directory where it was mounted:

$ fusermount -u dir-to-mount-iso

Tried with: fuseiso 20070708 and Ubuntu 12.04 LTS