LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Mount USB flash drive earlier in boot process - systemd adjustment? (https://www.linuxquestions.org/questions/linux-general-1/mount-usb-flash-drive-earlier-in-boot-process-systemd-adjustment-4175611780/)

taylorkh 08-11-2017 01:49 PM

Mount USB flash drive earlier in boot process - systemd adjustment?
 
I have a Dell Latitude 2100 mini-laptop (Ubuntu Mate 16.04) re-purposed to serve as a jukebox for my workshop. My 400+ albums converted to .mp3 on the SSD and a next-to-no privileges account which executed an auto logon at boot time. Caja (Nautilue) and audacity (music player) are set as startup programs for the auto logon account. Works great. I boot it up and the music play picks up from where it was when I shut the computer down (or suspended it if I will only be a way for a short time.)

Recently I acquired some additional mp3 files. I had them on a USB flash drive. I plugged in the drive and copied a selection of tracks to the audacity playlist. They played just fine. I then shut down the PC for the evening. Next day when I booted the machine back up I noticed, in a LARGE dialog, that the files on the flash drive which were listed in audacity were not available. I cleared the dialog and resumed playing the listed tracks in audacity.

It appears that audacity started BEFORE the USB flash drive had mounted. This leads me to the question... Is it possible to cause the USB drive to mount earlier in the boot process - before the auto logon perhaps? I suspect this could be done through systemd but while I have come concept of how systemd works, I have never actually made any adjustments to the boot process. Any advice?

TIA,

Ken

p.s. While composing this post and thinking about the situation... I suspect it might be a problem if the boot process mounted the flash drive rather than the user. If I plug in a USB drive it mounts at /run/media/username. If it is mounted by the boot process (as root?) I might have to address permissions. A little more complex that plug-and-play but still worth a try.

IsaacKuo 08-11-2017 02:26 PM

Personally, I'd go for a much simpler solution - instead of running audacity, run a dumb little script that looks something like this:

Code:

#!/bin/sh

sleep 15
audacity

Set that script to autostart instead of audacity itself. It will wait 15 seconds and then run audacity. That should be plenty of time for the USB drive to automount (what is mounting it? I guess not /etc/fstab, because that would mount really early on...but I guess it's something the GUI desktop environment is set to do or something).

You can, of course, experiment with how much of a time delay is good enough.

taylorkh 08-11-2017 02:57 PM

Thank you IsaacKuo !!!

That is in keeping with my normal pick and shovel (or BFH) approach to fixing problems:D It sort of reminds me of a script I used on my Osborn (CP/M) computer to start Wordstar. Instead of actually starting Wordstar ws<Enter> would execute the script which would:

Start Wordstar (which was patched to look on the B diskette for data files)
Upon exiting from Wordstar it would prompt me to put my backup diskette in the A drive
Use PIP (peripheral interchange program) to backup any new or changed files from the data diskette in B to the backup diskette in A

The music file question is not really critical. I AM looking for little tasks to start building my knowledge and skills in managing systemd. The task I really want to accomplish is to configure my servers to conditionally unlock and mount encrypted file systems IF and ONLY IF a certain USB drive is present and contains the appropriate key file(s). Currently is use /etc/crypttab and /etc/fstab. If the key file is not available the server will not boot. I have a script roughed out to do the conditional unlock/mount but I have no idea how and where to shove it into the systemd universe.

Ken


All times are GMT -5. The time now is 03:14 PM.