USB mount

If none of the more specific forums is the right place to ask

USB mount

Postby NewToLinux » 2020-10-27 14:55

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.
NewToLinux
 
Posts: 49
Joined: 2017-09-17 11:30

Re: USB mount

Postby sgosnell » 2020-10-27 15:13

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.
sgosnell
 
Posts: 906
Joined: 2011-03-14 01:49

Re: USB mount

Postby NewToLinux » 2020-10-27 19:23

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: 49
Joined: 2017-09-17 11:30

Re: USB mount

Postby NewToLinux » 2020-10-27 20:04

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.
NewToLinux
 
Posts: 49
Joined: 2017-09-17 11:30

Re: USB mount

Postby sgosnell » 2020-10-27 20:46

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.
sgosnell
 
Posts: 906
Joined: 2011-03-14 01:49

Re: USB mount

Postby allnikol » 2020-11-05 01:21

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
allnikol
 
Posts: 4
Joined: 2020-11-04 01:25


Return to General Questions

Who is online

Users browsing this forum: MagicPoulp and 28 guests

fashionable