silentheaven83
Posts: 7
Joined: Sat May 01, 2021 2:09 pm

Automount NTFS USB drive on Lite

Tue May 04, 2021 6:04 pm

Hi everybody,

I need your help. I installed Raspberry Pi OS Lite and usbmount with this tutorial:

https://raspberrypi.stackexchange.com/q ... essie-lite

The problem is that as soon as I connect my NTFS USB drive and try to browse /media/ it says:

Code: Select all

ls: cannot access 'usb0': Transport endpoint is not connected
usb  usb0  usb1  usb2  usb3  usb4  usb5  usb6  usb7
What can I do?
Thanks

User avatar
DougieLawson
Posts: 41321
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Automount NTFS USB drive on Lite

Tue May 04, 2021 7:16 pm

Did you installed the USB automounter? sudo apt-get install usbmount
Any language using left-hand whitespace for syntax is ridiculous

Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.

Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

User avatar
thagrol
Posts: 5032
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Automount NTFS USB drive on Lite

Tue May 04, 2021 11:53 pm

silentheaven83 wrote:
Tue May 04, 2021 6:04 pm
Hi everybody,

I need your help. I installed Raspberry Pi OS Lite and usbmount with this tutorial:

https://raspberrypi.stackexchange.com/q ... essie-lite

The problem is that as soon as I connect my NTFS USB drive and try to browse /media/ it says:

Code: Select all

ls: cannot access 'usb0': Transport endpoint is not connected
usb  usb0  usb1  usb2  usb3  usb4  usb5  usb6  usb7
What can I do?
Thanks
That guide is over five years old.

Do you want to be able to hotplug the NTFS drive or is it your intention to have it connected at boot and for it to remain connected until shutdown?

If the former, usbmount may be one way to go however last time I tried it I couldn't get it to work on RPiOS Buster lite. A hacky alternative might be to add the drive/partition to /etc/fstab and include x-systemd.aurtomount in the mount options. You won't get mount on hotplug but you should get mount on access to the mount point.

If the latter, forget usbmount and use fstab.

If you don't know how to use fstab, start with my guide: viewtopic.php?f=91&t=302752&p=1815316#p1815316
I'm a volunteer. Take me for granted or abuse my support and I will walk away

All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides

silentheaven83
Posts: 7
Joined: Sat May 01, 2021 2:09 pm

Re: Automount NTFS USB drive on Lite

Wed May 05, 2021 3:54 pm

Thank you everybody.

Yes I installed usbmount. I'd like to have all the USB drive that I connect auto-mounted, but usbmount seems to hate NTFS.
If I connect a FAT32 drive it mounts immediately.

I think I should use fstab for NTFS and keep usbmount for the rest.

User avatar
DougieLawson
Posts: 41321
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Automount NTFS USB drive on Lite

Wed May 05, 2021 4:25 pm

silentheaven83 wrote:
Wed May 05, 2021 3:54 pm
but usbmount seems to hate NTFS.
If it's never going to be connected to a Windows system again, then reformat as ext4.
Linux, generally, hates NTFS as it doesn't use the same owner, group, world permissions system.

It's also a very slow thing as there's more for the ntfs-3g module to do to make an NTFS drive accessible from the Linux kernel.

If it's going to be permanently connected to your RPi then do the mount in /etc/fstab (or with a systemd xxx.mount unit).
Any language using left-hand whitespace for syntax is ridiculous

Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.

Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

silentheaven83
Posts: 7
Joined: Sat May 01, 2021 2:09 pm

Re: Automount NTFS USB drive on Lite

Wed May 05, 2021 5:12 pm

Thanks.

The "strange fact" is that in Raspberry OS "full", once you login in the GUI the same drive gets automatically mount no problem.

User avatar
thagrol
Posts: 5032
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Automount NTFS USB drive on Lite

Wed May 05, 2021 6:55 pm

silentheaven83 wrote:
Wed May 05, 2021 5:12 pm
Thanks.

The "strange fact" is that in Raspberry OS "full", once you login in the GUI the same drive gets automatically mount no problem.
Different auotmounter. The desktop doesn't use usbmount, it uses, I think, the filemanager (pcmanfm).
I'm a volunteer. Take me for granted or abuse my support and I will walk away

All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides

User avatar
thagrol
Posts: 5032
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Automount NTFS USB drive on Lite

Wed May 05, 2021 7:00 pm

silentheaven83 wrote:
Wed May 05, 2021 3:54 pm
Thank you everybody.

Yes I installed usbmount. I'd like to have all the USB drive that I connect auto-mounted, but usbmount seems to hate NTFS.
If I connect a FAT32 drive it mounts immediately.
sounds like it's potentially a usbmount configuration issue:
The Special Case of FUSE Filesystems
Many users use removable drives with NTFS filesystems and the user-space filesystem NTFS-3g, since it provides more flexibility than the native module present in the Linux kernel.

Such users have difficulty when unmounting the filesystems, since they are present in the system /etc/mtab with a filesystem type of fuseblk, not with ntfs (or ntfs-3g) as one might expect.

For such filesystems, it may be convenient to:

add ntfs-3g to /etc/usbmount/usbmount.conf's variable FILESYSTEMS (for mounting purposes)
add fuseblk to /etc/usb/usbmount.conf's variable FILESYSTEMS (for unmounting purposes).
Similar comments may apply to other FUSE-managed filesystems. In general, if you need a FUSE filesystem, it may be a good idea to add the name of that filesystem to the FILESYSTEMS variable as well as making sure that the special fuseblk filesystem is contained in that list.

This subsection is an adaptation of descriptions made by Thomas Jancar and Jan Schulz.
Source: https://github.com/rbrito/usbmount#readme
I think I should use fstab for NTFS and keep usbmount for the rest.
Use it for everyrthing. usbmount doesn't consitently mount a device to the same mountpoint. If you connect them in a different order or only connect some of them at a time they'll be oon different mount points.

If you're not going to be hot plugging the drives/devices fstab is definitely the way to go.
I'm a volunteer. Take me for granted or abuse my support and I will walk away

All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides

silentheaven83
Posts: 7
Joined: Sat May 01, 2021 2:09 pm

Re: Automount NTFS USB drive on Lite

Fri May 07, 2021 1:22 pm

thagrol wrote:
Wed May 05, 2021 7:00 pm
sounds like it's potentially a usbmount configuration issue:
I'm a total newbie in the Linux world. This is what I did in SSH on a fresh OS Lite install:

Code: Select all

sudo apt-get update
sudo apt-get-upgrade
Reboot.

Code: Select all

sudo apt-get install ntfs-3g (not needed really)
sudo apt-get install usbmount
The CLI said:

Code: Select all

The following additional packages will be installed:
  liblockfile-bin liblockfile1 lockfile-progs pmount
Suggested packages:
  cryptsetup
The following NEW packages will be installed:
  liblockfile-bin liblockfile1 lockfile-progs pmount usbmount
After that, reboot. Then:

Code: Select all

sudo nano /etc/usbmount/usbmount.conf
Changed FILESYSTEMS from:

Code: Select all

FILESYSTEMS="vfat ext2 ext3 ext4 hfsplus"
to

Code: Select all

FILESYSTEMS="vfat ext2 ext3 ext4 hfsplus ntfs-3g fuseblk"	
saved, reboot, then I connected the NTFS USB HDD.

Code: Select all

cd /media/
cd usb
ls
And ls returned no data. :cry:
Then I found this one: https://raspberrypi.stackexchange.com/a/100375
So:

Code: Select all

sudo nano /lib/systemd/system/systemd-udevd.service
changed

Code: Select all

PrivateMounts=yes
to

Code: Select all

PrivateMounts=no
saved, reboot with the HDD connected, same result, /media/usb/ empty. The HDD works normally on any other OS. If I write

Code: Select all

sudo fdisk -l

Disk /dev/sda: 298.1 GiB, 320072933376 bytes, 625142448 sectors
Disk model: 3200BMV External
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: DD80708B-EE49-423F-9AE1-8857964E9C8A

Device     Start       End   Sectors   Size Type
/dev/sda1   2048 625142414 625140367 298.1G Microsoft basic data
The drive does exists. Is that "gpt" the problem? I need it to be NTFS since I have to connect it also on Windows 10.

User avatar
thagrol
Posts: 5032
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Automount NTFS USB drive on Lite

Fri May 07, 2021 3:42 pm

Firstly, I'm not an expert on usbmout. As I said, last time I tried to use it I couldn't get it to work.

AIUI in the default configuration, usbmount does not mount to /media/usb. It mounts to the first free directory with a path of /media/usb[0-7] i.e. /media/usb0, /media/usb1, etc.

If you have an entry in your fstab for that drive it's possible that usbmount will ignore the drive.

Code: Select all

mount|grep sda1
will tell if and where sda1 is mounted (no results if not mounted).

Code: Select all

mountpoint /media/usb
will tell you if /media/usb has something mounted on it.
I'm a volunteer. Take me for granted or abuse my support and I will walk away

All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides

silentheaven83
Posts: 7
Joined: Sat May 01, 2021 2:09 pm

Re: Automount NTFS USB drive on Lite

Fri May 07, 2021 5:46 pm

thagrol wrote:
Fri May 07, 2021 3:42 pm
Firstly, I'm not an expert on usbmout. As I said, last time I tried to use it I couldn't get it to work.
thagrol thank your for you support. This is my CLI with both the command you said.

Code: Select all

pi@raspberrypi:~ $ mount|grep sda1
pi@raspberrypi:~ $ mountpoint /media/usb
/media/usb is not a mountpoint
The first command gave no results, the second one said that it's not mounted.
I also tried to cd /media/usb0 and usb1, no data in there.

Is it me that I'm dumb or this simple thing seems so unnecessarily complicated?

LTolledo
Posts: 5378
Joined: Sat Mar 17, 2018 7:29 am
Location: Anime Heartland

Re: Automount NTFS USB drive on Lite

Fri May 07, 2021 9:37 pm

I'd junk the use of the usbmount....
and as mentioned by DougieLawson....mount the USB drive via /etc/fstab

this is my version of an fstab entry that will mount any USB drive (up to 2 drives, each drive formatted with just 1 partition), which is in turn shared to the network by samba. (sorry, have not tried with NFS...yet)

Code: Select all

/dev/sda1  /mnt/USBdrive1  auto  noatime,rw,nofail,noauto,x-systemd.automount
/dev/sdb1  /mnt/USBdrive2  auto  noatime,rw,nofail,noauto,x-systemd.automount
just make sure to make the mount point first....
"Don't come to me with 'issues' for I don't know how to deal with those
Come to me with 'problems' and I'll help you find solutions"

Some people be like:
"Help me! Am drowning! But dont you dare touch me nor come near me!"

User avatar
thagrol
Posts: 5032
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Automount NTFS USB drive on Lite

Fri May 07, 2021 10:07 pm

silentheaven83 wrote:
Fri May 07, 2021 5:46 pm
thagrol wrote:
Fri May 07, 2021 3:42 pm
Firstly, I'm not an expert on usbmout. As I said, last time I tried to use it I couldn't get it to work.
thagrol thank your for you support. This is my CLI with both the command you said.

Code: Select all

pi@raspberrypi:~ $ mount|grep sda1
pi@raspberrypi:~ $ mountpoint /media/usb
/media/usb is not a mountpoint
The first command gave no results, the second one said that it's not mounted.
I also tried to cd /media/usb0 and usb1, no data in there.
Looks to me like usbmount hasn't worked. If it had I'd expect something from the first command but still a message that /media/usb is not a mount point aas if usbmount had worked it would have mounted the drive to /media/usb0.
Is it me that I'm dumb or this simple thing seems so unnecessarily complicated?
I can't possibly comment.

Try LTolledo's suggestion but be aware that mounts on access to the mount point not on drive connection.
I'm a volunteer. Take me for granted or abuse my support and I will walk away

All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides

silentheaven83
Posts: 7
Joined: Sat May 01, 2021 2:09 pm

Re: Automount NTFS USB drive on Lite

Fri May 07, 2021 10:33 pm

Thanks guys, the fstab solution works. As you said it mounts on startup and not on connection.

I'm thinking about installing the full version of Raspberry OS with GUI and autologin in the GUI, even if I would use it headless, so I could use that working automount feature.

Otherwise I would need to reboot from the CLI everytime I connect a new drive.

RonR
Posts: 2196
Joined: Tue Apr 12, 2016 10:29 pm
Location: US

Re: Automount NTFS USB drive on Lite

Sat May 08, 2021 8:13 am

silentheaven83 wrote:
Fri May 07, 2021 10:33 pm
Otherwise I would need to reboot from the CLI everytime I connect a new drive.

If you use PARTUUID references in fstab rather than /dev/sdX, can't you simply run 'mount -a' after connecting a new drive instead of rebooting?

User avatar
thagrol
Posts: 5032
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Automount NTFS USB drive on Lite

Sat May 08, 2021 11:21 am

RonR wrote:
Sat May 08, 2021 8:13 am
silentheaven83 wrote:
Fri May 07, 2021 10:33 pm
Otherwise I would need to reboot from the CLI everytime I connect a new drive.

If you use PARTUUID references in fstab rather than /dev/sdX, can't you simply run 'mount -a' after connecting a new drive instead of rebooting?
It doesn't matter whether you've used device node, UUID, PARTUUID, LABEL etc in fstab. As long as you haven't included the noauto mount option sudo mount -a will mount it. mount -a will only run for the root user.

If something is in fstab you can also mount it as follows:

Code: Select all

sudo mount /path/to/mount/point
or

Code: Select all

sudo mount /dev/sda1
I've not tried using PARTUUID, UUID, LABEL, etc.

If you don't want to have to use sudo, add user to the mount options in fstab. That allows a normal user to mount and unmount the device (unmount only if they were the user who mounted it).
I'm a volunteer. Take me for granted or abuse my support and I will walk away

All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides

RonR
Posts: 2196
Joined: Tue Apr 12, 2016 10:29 pm
Location: US

Re: Automount NTFS USB drive on Lite

Sat May 08, 2021 5:59 pm

thagrol wrote:
Sat May 08, 2021 11:21 am
It doesn't matter whether you've used device node, UUID, PARTUUID, LABEL etc in fstab. As long as you haven't included the noauto mount option sudo mount -a will mount it. mount -a will only run for the root user.

It does if you want specific devices mounted on specific mount points.

User avatar
thagrol
Posts: 5032
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Automount NTFS USB drive on Lite

Sat May 08, 2021 8:37 pm

RonR wrote:
Sat May 08, 2021 5:59 pm
thagrol wrote:
Sat May 08, 2021 11:21 am
It doesn't matter whether you've used device node, UUID, PARTUUID, LABEL etc in fstab. As long as you haven't included the noauto mount option sudo mount -a will mount it. mount -a will only run for the root user.

It does if you want specific devices mounted on specific mount points.
True. But 1. that isn't quite the case here, and 2. that wasn't the point I was trying to make (that you don't need to use PARTUUID in order for mount -a to work)
I'm a volunteer. Take me for granted or abuse my support and I will walk away

All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides

RonR
Posts: 2196
Joined: Tue Apr 12, 2016 10:29 pm
Location: US

Re: Automount NTFS USB drive on Lite

Sat May 08, 2021 9:01 pm

thagrol wrote:
Sat May 08, 2021 8:37 pm
RonR wrote:
Sat May 08, 2021 5:59 pm
thagrol wrote:
Sat May 08, 2021 11:21 am
It doesn't matter whether you've used device node, UUID, PARTUUID, LABEL etc in fstab. As long as you haven't included the noauto mount option sudo mount -a will mount it. mount -a will only run for the root user.

It does if you want specific devices mounted on specific mount points.
True. But 1. that isn't quite the case here, and 2. that wasn't the point I was trying to make (that you don't need to use PARTUUID in order for mount -a to work)

My response to the OP was related to his worry that a reboot would be required for mount entries in fstab to take effect after connecting a new device..

Using multiple /dev/sdX entries in fstab for devices not always present would be pretty meaningless as a poor-mans auto-mount capability.

User avatar
thagrol
Posts: 5032
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Automount NTFS USB drive on Lite

Sat May 08, 2021 9:09 pm

RonR wrote:
Sat May 08, 2021 9:01 pm
thagrol wrote:
Sat May 08, 2021 8:37 pm
RonR wrote:
Sat May 08, 2021 5:59 pm


It does if you want specific devices mounted on specific mount points.
True. But 1. that isn't quite the case here, and 2. that wasn't the point I was trying to make (that you don't need to use PARTUUID in order for mount -a to work)

My response to the OP was related to his worry that a reboot would be required for mount entries in fstab to take effect after connecting a new device..
I'm not trying to start (continue?) an argument. I commented because, as I saw it, your post left the impression that sudo mount -a would only work when using PARTUUID and would work for normal, non-root users.
Using multiple /dev/sdX entries in fstab for devices not always present would be pretty meaningless as a poor-mans auto-mount capability.
I don't disagree. It wasn't my suggestion.

However I can think of one circumstance where it could be usefull: where /dev/sd?? is awlays a USB device and you want a normal user to be able to mount and umount it. You'd need an fstab entry with the user or users option much like how optical drives are handled.
I'm a volunteer. Take me for granted or abuse my support and I will walk away

All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides

LTolledo
Posts: 5378
Joined: Sat Mar 17, 2018 7:29 am
Location: Anime Heartland

Re: Automount NTFS USB drive on Lite

Sat May 08, 2021 11:45 pm

RonR wrote:
Sat May 08, 2021 9:01 pm

Using multiple /dev/sdX entries in fstab for devices not always present would be pretty meaningless as a poor-mans auto-mount capability.
on another post about "auto-mounting"..... I've tested what I've written, and outlined how it worked
viewtopic.php?f=91&t=310516&p=1857630#p1857391

the mount points of those drives are also accessed by samba, that make the "auto-mounting" possible....

if the OP uses just one drive and that drive is permanently connected to the RPi at startup, then the OP should definitely use PARTUUID or UUID on fstab ...
that way the drive gets auto-mounted to the OP's specified mount point.

it would be better if usbmount get fixed....if and when is still up in the air.... ;)
am a poor man... and prefer poor-man's method.... :D
"Don't come to me with 'issues' for I don't know how to deal with those
Come to me with 'problems' and I'll help you find solutions"

Some people be like:
"Help me! Am drowning! But dont you dare touch me nor come near me!"

Return to “Raspberry Pi OS”