Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

USB mount

If none of the specific sub-forums seem right for your thread, ask here.
Post Reply
Message
Author
NewToLinux
Posts: 71
Joined: 2017-09-17 11:30

USB mount

#1 Post by NewToLinux »

If a filesystem in /etc/fstab has a noauto entry, can that filesystem only be mounted manually using the mount command or
is there any chance that it will be automatically mounted by usbmount ?

The filesystem is used in a USB port.

sgosnell
Posts: 975
Joined: 2011-03-14 01:49

Re: USB mount

#2 Post by sgosnell »

You will need to manually mount it. I know of few good reasons for using noauto. I do see good reasons for using nofail with USB drive, however. If it were my system, I would replace noauto with nofail. Unless you really need to prevent the drive from being automounted for some reason.
Take my advice, I'm not using it.

NewToLinux
Posts: 71
Joined: 2017-09-17 11:30

Re: USB mount

#3 Post by NewToLinux »

In a system running Debian, will a USB device always be automatically be mounted if the device is plugged in while
the system is running ?

Is the /etc/fstab file only inspected during a system reboot ?

NewToLinux
Posts: 71
Joined: 2017-09-17 11:30

Re: USB mount

#4 Post by NewToLinux »

It now seems to me that the situation is as follows :-

Filesystems in /etc/fstab which have the noauto option are not automatically mounted at boot time, so if these filesystems are already plugged into USB ports at boot time, they would subsequently have to be manually mounted in order to be used.

Filesystems which are plugged into a port after the system has been booted are automatically mounted.

sgosnell
Posts: 975
Joined: 2011-03-14 01:49

Re: USB mount

#5 Post by sgosnell »

The system can be configured in several ways, including not mounting automatically or automatically mounting if connected later. It's not a fixed setting. Like most things in Linux, it's possible to set it how you want it.
Take my advice, I'm not using it.

allnikol
Posts: 4
Joined: 2020-11-04 01:25

Re: USB mount

#6 Post by allnikol »

Depending on exactly what it is you're trying to accomplish, you may want to look at systemd's .mount and .automount unit types. There's a lot to take in, and systemd is very picky about the exact syntax, naming, and location of unit files, but if you get a .mount/.automount pair set up correctly, you can have on-demand automounting of arbitrary filesystems. A setup I use for certain network filesystems is to have the mount defined with noauto, and set up a corresponding .automount unit. The result is that the filesystem is not mounted at boot even if it is connected and available, and it's also not mounted automatically on connecting it. But when something tries to access the filesystem (whether it's a user, a system daemon, a cron job, whatever), then systemd attempts to mount it. It will, of course, fail with an error if the device the filesystem is on is not available. You can set up the .automount unit to automatically unmount the filesystem again after it sits idle with nothing accessing it for a certain time, too. I will admit that I haven't looked at how this might interact with usbmount, as the default handling of usb storage devices (without fstab entries) has been good enough for my purposes.

Depending how deep you end up getting into this, you may find it valuable to know that nowadays fstab is actually just consumed by systemd as a source of configuration input from which it generates .mount units, and interactions such as mounting and unmounting are consequently handled by systemd via those .mount units. One of the reasons this might be helpful is that systemd mount units have lots of capabilities beyond what you can put in fstab entries. Using systemd's "override" capability, you can customize the behaviour of the mount units that it generated from fstab in a non-destructive way, ie without editing the unit file itself. IIRC, systemd normally just parses fstab once each boot, but there's definitely at least one command (which I don't remember off the top of my head) to manually make it parse fstab and re-generate all the corresponding units while the system is up and running.

But you're going way beyond what you would generally need for normal user purposes if you get into all that. :D

Post Reply