LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-23-2016, 01:30 PM   #1
netpumber
Member
 
Registered: Sep 2007
Location: In My Box
Distribution: Arch Linux
Posts: 423

Rep: Reputation: 33
Discussion on specific USB devices mount


Hello all.

I want to discuss here a specific idea.

First of all i use for my job only two USB devices. One portable hard disk and a USB flash disk.
I always hated the idea of auto mounting devices and thus on my machine, to be able to mount a device you have to be a root and execute mount/umount commands.

Today i was thinking, instead of executing that whole command as root
Code:
mount -o guid=...,uid=...,umask=... /dev/sdc1/ /mnt/usb
to execute something like
Code:
mount -label WDDisk
for the portable disk

and
Code:
mount -label FlashD
for the flash disk.

The first command should automatically mount the portable disk e.g to /mnt/WD while the second one mount the flash disk in /mnt/FLS.

The thing here, is that how can i make system recognize that the usb device just inserted is the portable disk or the usb flash disk, then assign a label to them and finally to give them a specific mount path.

For example, if i plug the HDD, independently the device block name in /dev/sd*, to be able to recognize that this is the portable disk and if user run "mount -label WDDisk", this should be mounted on the /mnt/WD. Respectively for the USB flash drive. I want that, only for those two devices not for anything else that will someday be plugged into my machine.

Is something like that possible? How should i approach its solution ?

P.S I don't know if this plays a role, but i'm using Arch linux.

Thank you.

Last edited by netpumber; 01-23-2016 at 01:31 PM.
 
Old 01-24-2016, 01:40 PM   #2
ferrari
LQ Guru
 
Registered: Sep 2003
Location: Auckland, NZ
Distribution: openSUSE Leap
Posts: 5,807

Rep: Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140
You could use Udisks2 for user-monting, which mounts in /run/media/$USER/

https://wiki.archlinux.org/index.php...ips_and_tricks

For example, as user-mount USB device /dev/sdb1
Code:
udisksctl mount -b /dev/sdb1
If you want to mount by volume label, this might be useful

http://askubuntu.com/questions/34218...m-command-line

Quote:

A simple solution that works as required (mounts to /media/{user}/{diskid}) except that it can not list devices but needs to be given the exact, case sensitive, volume label as argument $1

To mount:

DEVICE=$(findfs LABEL=$1) && udisksctl mount -b $DEVICE

To unmount:

DEVICE=$(findfs LABEL=$1) && udisksctl unmount -b $DEVICE
 
Old 01-24-2016, 01:45 PM   #3
ferrari
LQ Guru
 
Registered: Sep 2003
Location: Auckland, NZ
Distribution: openSUSE Leap
Posts: 5,807

Rep: Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140
I'm using openSUSE, but just successfully mounted my USB 3 flash storage device by name using
Code:
DEVICE=$(/usr/sbin/findfs LABEL="HOPPY") && udisksctl mount -b $DEVICE
Mounted /dev/sdb1 at /run/media/dmartin/HOPPY
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Way to make autofs mount to specific USB flash drive to specific folder? utahnix Linux - Software 2 11-24-2010 05:27 PM
move grub to usb + mount encrypted devices from usb question Lancelot1 Linux - Security 1 02-26-2009 09:51 AM
Can't mount USB devices cdale77 Slackware 15 01-27-2008 09:42 PM
Can't mount my usb devices captain chaos Slackware 18 04-23-2006 08:35 AM
Mounting specific hardware devices to specfic mount points tallguy999 Linux - Newbie 3 11-27-2003 02:07 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:33 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration