Friday, 5 April 2019

linux - Is it possible to mount a ntfs drive by name?


So I am currently using ntfs-3g /dev/sdb1 /home/mountpoint/ to mount an external usb drive.


But what I want to be able to do is mount it using its volume name, in my head it would look something like this ntfs-3g -l /dev/DRIVENAME /home/mountpoint/


Is there any way that I can do this? I have googled around and found no trace of any soloutions, but maybe I'm being so stupid no one has ever thought to bother googling it before.


Thanks in advance


Alex Spicer



Answer



Yes, you can use udev to write a rule which will then create a symbolic link of /dev/sdb1 to /dev/mydiskname1. To do this you need to do the following:



  1. Use udevadm to "walk" down the device tree and find the serial number of your drive.

  2. Create a udev rule which creates your symbolic link when that drive is inserted.


This Page has the most concise description of how to go about this, and if you scroll down to the heading entitled "udevadm info" then all will be revealed. But in a nutshell, your process will be something like this:




  1. Run the following to look at your device tree, where /dev/sdX is your sdX device - not sdX1 the partition, but the sdX, device itself


    udevadm info --name=/dev/sdX --attribute-walk


    udevadm info --name=/dev/sdX




  2. Using what's been gleaned from the above, then write a udev rule in /etc/udev/rules.d/70-myusbdisk.rules which looks something like:


    KERNEL=="sd*", SUBSYSTEM=="block", ENV{ID_SERIAL}=="TOSHIBA_DT01ACA100_248UZVBNS", SYMLINK+="mydisk%n"




ENV{ID_SERIAL} will be whatever the above command displayed it as, and SYMLINK+ will add symlinks for all your partitions (hence the %n - /dev/sdb1 will be /dev/mydisk1 and so on).


Read the link above but if you get stuck post the output of the two above commands to your original post (as a code block!) and then we can try to help you build a rule.


HTH!


Edit: Of course this superuser post goes into some detail too...


No comments:

Post a Comment

How can I VLOOKUP in multiple Excel documents?

I am trying to VLOOKUP reference data with around 400 seperate Excel files. Is it possible to do this in a quick way rather than doing it m...