Automatic mounting of USB HDD FLASH Pen

Here you can discuss every aspect of Debian. Note: not for support requests!
Post Reply
Message
Author
user1213213
Posts: 18
Joined: 2024-10-25 13:17

Automatic mounting of USB HDD FLASH Pen

#1 Post by user1213213 »

Does anyone in simplest possible terms know how to automatically mount USB HDD's, FLASH Pen's etc?
I'm on Debian server and would like the mounting to be autonomous. Thank you.

arzgi
Posts: 1388
Joined: 2008-02-21 17:03
Location: Finland
Been thanked: 52 times

Re: Automatic mounting of USB HDD FLASH Pen

#2 Post by arzgi »

For me works out of the box, Debian 12.7 Xfce, when I insert for examply an usb stick, it gets mounted to /media/$USER/nnn, and I can see it in thunar (Xfce's file manager) also in the terminal.

User avatar
pbear
Posts: 507
Joined: 2023-08-27 15:05
Location: San Francisco
Has thanked: 2 times
Been thanked: 81 times

Re: Automatic mounting of USB HDD FLASH Pen

#3 Post by pbear »

Does "Debian server" mean no desktop is installed? If so, the simplest answer would be to install one. XFCE is a good choice. Relatively low overhead and, as arzgi says, will mount removable devices hot-plugged at boot. If you don't want a desktop (or have no way to interface with one), you're looking at reproducing what XFCE does with a script. udisks is the tool actually doing the mount, by the way.

From how you wrote the question, I infer you want the system to mount any-and-all devices which might be attached. If you have specific devices in mind, you also can mount with fstab. Be sure to include a nofail parameter.

User avatar
dilberts_left_nut
Administrator
Administrator
Posts: 5441
Joined: 2009-10-05 07:54
Location: enzed
Has thanked: 21 times
Been thanked: 87 times

Re: Automatic mounting of USB HDD FLASH Pen

#4 Post by dilberts_left_nut »

I do it with my backup drives on a headless machine with udev rules triggering a mounting script.
AdrianTM wrote:There's no hacker in my grandma...

user1213213
Posts: 18
Joined: 2024-10-25 13:17

Re: Automatic mounting of USB HDD FLASH Pen

#5 Post by user1213213 »

Sounds complicated. Thanks for the tip.

User avatar
pbear
Posts: 507
Joined: 2023-08-27 15:05
Location: San Francisco
Has thanked: 2 times
Been thanked: 81 times

Re: Automatic mounting of USB HDD FLASH Pen

#6 Post by pbear »

In between. Scripting is neither simple nor brain surgery. It's learnable. You weren't born knowing how to drive a car either. A quick internet search turns up a bunch of hits.

arzgi
Posts: 1388
Joined: 2008-02-21 17:03
Location: Finland
Been thanked: 52 times

Re: Automatic mounting of USB HDD FLASH Pen

#7 Post by arzgi »

user1213213 wrote: 2024-11-07 07:44 Sounds complicated. Thanks for the tip.
It is not, I have done a lot this before. This is a good guide I have used http://reactivated.net/writing_udev_rules.html

User avatar
bw123
Posts: 4038
Joined: 2011-05-09 06:02
Has thanked: 1 time
Been thanked: 32 times

Re: Automatic mounting of USB HDD FLASH Pen

#8 Post by bw123 »

I ran across this today, hope it helps...

Code: Select all

$ man systemd-mount | grep -A3 EXAMPLE
EXAMPLE
       Use a udev rule like the following to automatically mount all USB
       storage plugged in:
resigned by AI ChatGPT

User avatar
pbear
Posts: 507
Joined: 2023-08-27 15:05
Location: San Francisco
Has thanked: 2 times
Been thanked: 81 times

Re: Automatic mounting of USB HDD FLASH Pen

#9 Post by pbear »

Interesting, I've not heard of that before. OTOH, (a) I have a desktop and (b) one of the first things I do after installation is disable automount of USB drives. :lol:

Anyhoo, the output got truncated somehow. Here's the whole thing:

Code: Select all

~$ man systemd-mount | grep -A3 EXAMPLE
EXAMPLE
       Use a udev rule like the following to automatically mount all USB storage plugged in:

           ACTION=="add", SUBSYSTEMS=="usb", SUBSYSTEM=="block", ENV{ID_FS_USAGE}=="filesystem", \
Next question is, where does the OP put that udev rule? Frankly, I don't know.

CwF
Global Moderator
Global Moderator
Posts: 3059
Joined: 2018-06-20 15:16
Location: Colorado
Has thanked: 63 times
Been thanked: 253 times

Re: Automatic mounting of USB HDD FLASH Pen

#10 Post by CwF »

pbear wrote: 2024-11-09 01:54 Next question is, where does the OP put that udev rule?
/etc/udev/rules.d/99-automounts.rules, or similar.
Mottainai

User avatar
sunrat
Site admin
Site admin
Posts: 7339
Joined: 2006-08-29 09:12
Location: Melbourne, Australia
Has thanked: 130 times
Been thanked: 642 times

Re: Automatic mounting of USB HDD FLASH Pen

#11 Post by sunrat »

There's another line:

Code: Select all

$ man systemd-mount | grep -A4 EXAMPLE
EXAMPLE
       Use a udev rule like the following to automatically mount all USB storage plugged in:

           ACTION=="add", SUBSYSTEMS=="usb", SUBSYSTEM=="block", ENV{ID_FS_USAGE}=="filesystem", \
                   RUN{program}+="/usr/bin/systemd-mount --no-block --automount=yes --collect $devnode"
“ computer users can be divided into 2 categories:
Those who have lost data
...and those who have not lost data YET ”
Remember to BACKUP!

User avatar
dilberts_left_nut
Administrator
Administrator
Posts: 5441
Joined: 2009-10-05 07:54
Location: enzed
Has thanked: 21 times
Been thanked: 87 times

Re: Automatic mounting of USB HDD FLASH Pen

#12 Post by dilberts_left_nut »

Won't work for me ... my backup server is still running squeeze!
AdrianTM wrote:There's no hacker in my grandma...

Post Reply