wildbillnj1975
Posts: 60
Joined: Mon Apr 17, 2017 12:39 pm

USB storage auto-mount in /media/pi

Mon Jun 08, 2020 3:23 am

My Pi 3B's, usually, automatically mount a newly inserted uSD card (in a USB adapter) in /media/pi, which is convenient for my script that dumps all my "standard" customizations to a newly flashed card.
But one of them doesn't auto-mount at all. I tried applying the usbmount package, but now they're mounting in /media/usb0, /media/usb1, etc. which is not really what I want.

Does anyone know how to restore (or add) the feature that mounts them in /media/pi?

User avatar
Botspot
Posts: 1853
Joined: Thu Jan 17, 2019 9:47 pm
Location: Texas

Re: USB storage auto-mount in /media/pi

Mon Jun 08, 2020 2:13 pm

Pcmanfm does the auto-mounting. It uses udiskctl to do it from the backend.
You can run this manually:

Code: Select all

udisksctl mount -b /dev/sda1
/dev/sda is the path to the device you want to mount. Find your device with lsblk.
/dev/sda1 is the path to a certain partition on your selected disk. Change to 2 if your usb device has a second partition.

If that ^ doesn't work, then maybe your uSD card is corrupted or unformatted. Use SD Card Copier to duplicate a good sd card to this faulty one, and see if that solves your problem.
Easily install anything on your Pi using Pi-Apps. Over 2 million users.
Over 200 apps including image editors, IDEs, games, web browsers, appearance themes, and more to upgrade your Raspberry Pi desktop.
More info: https://github.com/Botspot/pi-apps

wildbillnj1975
Posts: 60
Joined: Mon Apr 17, 2017 12:39 pm

Re: USB storage auto-mount in /media/pi

Mon Jun 08, 2020 4:26 pm

Botspot wrote:
Mon Jun 08, 2020 2:13 pm
Pcmanfm does the auto-mounting. It uses udiskctl to do it from the backend.
You can run this manually:

Code: Select all

udisksctl mount -b /dev/sda1
/dev/sda is the path to the device you want to mount. Find your device with lsblk.
/dev/sda1 is the path to a certain partition on your selected disk. Change to 2 if your usb device has a second partition.

If that ^ doesn't work, then maybe your uSD card is corrupted or unformatted. Use SD Card Copier to duplicate a good sd card to this faulty one, and see if that solves your problem.
Interesting. For reasons unknown, I can't connect to the X desktop on this Pi (it's headless, and I can't plug it into a monitor right now).
Since I can't get a graphical display, I can't run pcmanfm.

But more to the point: rather than running it manually - is there a way to enable the automatic behavior?

User avatar
Botspot
Posts: 1853
Joined: Thu Jan 17, 2019 9:47 pm
Location: Texas

Re: USB storage auto-mount in /media/pi

Mon Jun 08, 2020 4:34 pm

wildbillnj1975 wrote:
Mon Jun 08, 2020 4:26 pm
Interesting. For reasons unknown, I can't connect to the X desktop on this Pi (it's headless, and I can't plug it into a monitor right now).
Since I can't get a graphical display, I can't run pcmanfm.

But more to the point: rather than running it manually - is there a way to enable the automatic behavior?
The "automatic behavior" is based on pcmanfm. But if you can't run pcmanfm (because you can't run a X server), then you can't run the automatic behavior.

One thing to try:

Code: Select all

vncserver
This will run a virtual instance of vnc. It starts a virtual desktop (and pcmanfm!). See if that works for you.
Easily install anything on your Pi using Pi-Apps. Over 2 million users.
Over 200 apps including image editors, IDEs, games, web browsers, appearance themes, and more to upgrade your Raspberry Pi desktop.
More info: https://github.com/Botspot/pi-apps

wildbillnj1975
Posts: 60
Joined: Mon Apr 17, 2017 12:39 pm

Re: USB storage auto-mount in /media/pi

Mon Jun 08, 2020 4:41 pm

wildbillnj1975 wrote:
Mon Jun 08, 2020 4:26 pm
Botspot wrote:
Mon Jun 08, 2020 2:13 pm
Pcmanfm does the auto-mounting. It uses udiskctl to do it from the backend.
You can run this manually:

Code: Select all

udisksctl mount -b /dev/sda1
/dev/sda is the path to the device you want to mount. Find your device with lsblk.
/dev/sda1 is the path to a certain partition on your selected disk. Change to 2 if your usb device has a second partition.

If that ^ doesn't work, then maybe your uSD card is corrupted or unformatted. Use SD Card Copier to duplicate a good sd card to this faulty one, and see if that solves your problem.
I connected it to another Pi for X display, and ran pcmanfm. Inserted the card. Nothing happened.
(I checked the preferences for mounting newly inserted cards. They're all checked.)
Card itself is definitely, absolutely, unquestionably fine. It's not the card. Same card inserted in another Pi is automounted in /media/pi (/boot in /media/pi/boot and / in /media/pi/rootfs).

But more to the point: rather than running it manually - is there a way to enable the automatic behavior?
The fact that it's automounting in /media/pi with knowledge of what the two partitions mean, suggests to me that it has to be a specific service or feature that's doing this.

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

Re: USB storage auto-mount in /media/pi

Mon Jun 08, 2020 4:51 pm

wildbillnj1975 wrote:
Mon Jun 08, 2020 4:26 pm
Interesting. For reasons unknown, I can't connect to the X desktop on this Pi (it's headless, and I can't plug it into a monitor right now).
Since I can't get a graphical display, I can't run pcmanfm.
That's not strictly true...

Enable vnc. Connect over that and run pcmanfm

Or enable X11 forwarding over ssh and run it on a remote X server though that'll take more setup and you'll need to know what command to use to run it.
Knowledge, skills, & experience have value. If you expect to profit from someone's you should expect to pay for them.

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
Botspot
Posts: 1853
Joined: Thu Jan 17, 2019 9:47 pm
Location: Texas

Re: USB storage auto-mount in /media/pi

Mon Jun 08, 2020 5:10 pm

thagrol wrote:
Mon Jun 08, 2020 4:51 pm
Enable vnc. Connect over that and run pcmanfm

Or enable X11 forwarding over ssh and run it on a remote X server though that'll take more setup and you'll need to know what command to use to run it.
Or do what I suggested and run vncserver. It loads the default desktop session (with a pcmanfm desktop background), and so takes no more user interaction than that one single command.
Easily install anything on your Pi using Pi-Apps. Over 2 million users.
Over 200 apps including image editors, IDEs, games, web browsers, appearance themes, and more to upgrade your Raspberry Pi desktop.
More info: https://github.com/Botspot/pi-apps

wildbillnj1975
Posts: 60
Joined: Mon Apr 17, 2017 12:39 pm

Re: USB storage auto-mount in /media/pi

Mon Jun 08, 2020 6:00 pm

Botspot wrote:
Mon Jun 08, 2020 5:10 pm
thagrol wrote:
Mon Jun 08, 2020 4:51 pm
Enable vnc. Connect over that and run pcmanfm

Or enable X11 forwarding over ssh and run it on a remote X server though that'll take more setup and you'll need to know what command to use to run it.
Or do what I suggested and run vncserver. It loads the default desktop session (with a pcmanfm desktop background), and so takes no more user interaction than that one single command.
I must have been editing my post while you were replying to it.
I was able to run pcmanfm but that didn't automount the card (and yes, I checked the preferences to ensure that was enabled).

But more to the point: rather than running it manually - is there a way to enable the automatic behavior?
The fact that it's automounting in /media/pi with knowledge of what the two partitions mean, suggests to me that it has to be a specific service or feature that's doing this.

The problem I'm trying to solve isn't "How can I automount this card?"
The problem I'm trying to solve is "How can I permanently and universally restore the missing automount-in-/media/pi behavior?"

User avatar
Botspot
Posts: 1853
Joined: Thu Jan 17, 2019 9:47 pm
Location: Texas

Re: USB storage auto-mount in /media/pi

Mon Jun 08, 2020 6:14 pm

wildbillnj1975 wrote:
Mon Jun 08, 2020 6:00 pm
The fact that it's automounting in /media/pi with knowledge of what the two partitions mean, suggests to me that it has to be a specific service or feature that's doing this.
Yes. this "service or feature" is pcmanfm, and it runs by default in graphical Raspberry Pi OS.
So if you are running headless (i.e., no desktop), then it won't work.

Specifically, it's the pcmanfm desktop process. So if you only run pcmanfm, nothing will happen.

I noticed you added some stuff to your main post and now I'm confused. What is your real question?
  • "usb drives are auto-mounting, but to the wrong spot. How to make them auto-mount to /media/pi like they did before?"
    Answer: uninstall usbmount. You may have to reboot afterwards to stop any residual in-memory processes. Still not working? Provide more information.
  • "All my uSD cards auto-mount, except for this one weird uSD card that doesn't auto-mount. How to fix it?"
    Answer: I'd try to re-flash the SD card (with "New Partition UUIDs" checked) and see if that fixes it. Sometimes a partition ID matches another partition ID, and the kernel struggles to keep track which is which.
  • "All my Pies auto-mount, except for this one Pi. Why?"
    Answer: Likely that one Pi is headless, or not running pcmanfm --desktop. Or it;s possible you're having a UUID problem (see above)
Easily install anything on your Pi using Pi-Apps. Over 2 million users.
Over 200 apps including image editors, IDEs, games, web browsers, appearance themes, and more to upgrade your Raspberry Pi desktop.
More info: https://github.com/Botspot/pi-apps

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

Re: USB storage auto-mount in /media/pi

Mon Jun 08, 2020 6:26 pm

wildbillnj1975 wrote:
Mon Jun 08, 2020 6:00 pm
I must have been editing my post while you were replying to it.
Very possibly. The possibility is why I try to avoid major edits once a post has gone "live"

Oh, one more thing: headless and doesn't have the desktop installed/running are not the same thing. It's perfectly possible to have a pi booting into a loged in desktop without having a monitor, mouse or keyboard connected. Wouldn't be sensible but it is possible.

Likewise, it's possible to have a pi with monitor, mouse, and keyboard attached but booting to command line even if the desktop is installed.
Knowledge, skills, & experience have value. If you expect to profit from someone's you should expect to pay for them.

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

wildbillnj1975
Posts: 60
Joined: Mon Apr 17, 2017 12:39 pm

Re: USB storage auto-mount in /media/pi

Mon Jun 08, 2020 8:24 pm

Botspot wrote:
Mon Jun 08, 2020 6:14 pm
wildbillnj1975 wrote:
Mon Jun 08, 2020 6:00 pm
The fact that it's automounting in /media/pi with knowledge of what the two partitions mean, suggests to me that it has to be a specific service or feature that's doing this.
Yes. this "service or feature" is pcmanfm, and it runs by default in graphical Raspberry Pi OS.
So if you are running headless (i.e., no desktop), then it won't work.

Specifically, it's the pcmanfm desktop process. So if you only run pcmanfm, nothing will happen.

I noticed you added some stuff to your main post and now I'm confused. What is your real question?
  • "usb drives are auto-mounting, but to the wrong spot. How to make them auto-mount to /media/pi like they did before?"
    Answer: uninstall usbmount. You may have to reboot afterwards to stop any residual in-memory processes. Still not working? Provide more information.
  • "All my uSD cards auto-mount, except for this one weird uSD card that doesn't auto-mount. How to fix it?"
    Answer: I'd try to re-flash the SD card (with "New Partition UUIDs" checked) and see if that fixes it. Sometimes a partition ID matches another partition ID, and the kernel struggles to keep track which is which.
  • "All my Pies auto-mount, except for this one Pi. Why?"
    Answer: Likely that one Pi is headless, or not running pcmanfm --desktop. Or it;s possible you're having a UUID problem (see above)
Ok. I've always used "headless" to refer to a machine with no KVM attached. "Head" being part of the "body" from which physically there head is missing, regardless whether there's a software desktop. And it sure does make sense to have a full desktop running on those machines. I don't have spare monitors to attach to Pis. The ones with a desktop, I access via VNC.
Generally I always install the full desktop version on 3's (and later), and the "lite" no-desktop version on Zeroes.
This is a 3B+ with the X desktop installed, but it's not running, so I need to go diagnose that.

Thanks for clarifying that it's specifically an X desktop feature.
Since my Zeroes don't have convenient spare USB ports, I have not used them for this sort of thing, therefore never noticed that none of them do the auto-mounting-in-/media/pi thing.

User avatar
Botspot
Posts: 1853
Joined: Thu Jan 17, 2019 9:47 pm
Location: Texas

Re: USB storage auto-mount in /media/pi

Mon Jun 08, 2020 8:30 pm

wildbillnj1975 wrote:
Mon Jun 08, 2020 8:24 pm
This is a 3B+ with the X desktop installed, but it's not running, so I need to go diagnose that.

Thanks for clarifying that it's specifically an X desktop feature.
No problem. Thank you too for clarifying.

If the 3B+ doesn't boot with a monitor attached, it will not start the desktop. To override that, edit /boot/config.txt:

Code: Select all

sudo nano /boot/config.txt
And add this line to the bottom of the file:

Code: Select all

hdmi_force_hotplug=1
Or, use the trick I mentioned above to run a virtual desktop session: run vncserver. You don't have to connect to the server, but that command will start a virtual desktop, and will therefore start the necessary auto-mounting process.
Easily install anything on your Pi using Pi-Apps. Over 2 million users.
Over 200 apps including image editors, IDEs, games, web browsers, appearance themes, and more to upgrade your Raspberry Pi desktop.
More info: https://github.com/Botspot/pi-apps

wildbillnj1975
Posts: 60
Joined: Mon Apr 17, 2017 12:39 pm

Re: USB storage auto-mount in /media/pi

Tue Jun 09, 2020 3:28 am

Botspot wrote:
Mon Jun 08, 2020 8:30 pm
wildbillnj1975 wrote:
Mon Jun 08, 2020 8:24 pm
This is a 3B+ with the X desktop installed, but it's not running, so I need to go diagnose that.

Thanks for clarifying that it's specifically an X desktop feature.
No problem. Thank you too for clarifying.

If the 3B+ doesn't boot with a monitor attached, it will not start the desktop. To override that, edit /boot/config.txt:

Code: Select all

sudo nano /boot/config.txt
And add this line to the bottom of the file:

Code: Select all

hdmi_force_hotplug=1
Or, use the trick I mentioned above to run a virtual desktop session: run vncserver. You don't have to connect to the server, but that command will start a virtual desktop, and will therefore start the necessary auto-mounting process.
I actually have scripts that set up all my "standard" customizations on every Pi... which is why it's handy to be able to expect their boot & root sectors to automagically show up in /media/pi...
One of them is that I always add that hotplug parameter in config.txt
Results, IMHO, can be inconsistent.
But I have that one relocated now, to a place where I always can plug in a monitor if I need to reboot it.
Or if not, I'll start a vncserver.
So the problem is essentially resolved.

Thanks for your help.

asian
Posts: 16
Joined: Sat Jul 18, 2020 3:23 am

Re: USB storage auto-mount in /media/pi

Thu Jul 30, 2020 9:41 pm

Does the vncserver solution still work? I have a fresh Buster (desktop version) Pi4, which boots into CLI and when I run

Code: Select all

vncserver
then it didn't seem to automount. Apologies if my noobishness is causing me not to understand. Is there some kind of vncserver setting I need to change

I am running Buster full version, but edited

Code: Select all

sudo raspi-config
to boot into CLI auto-logged in and I also changed the resolution to a specific figure as recommended by this post. However, the pi is not auto-mounting USB drives. I also changed the video output to analog, tried other resolutions, and enabled VNC all within raspi-config, but no effect.

Thanks

Return to “Troubleshooting”