Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have a S2 SAMSUNG 320GB USB-HDD which I use in both Ubuntu 13.10 (Kernel 3.11.0-17-generic) and Fedora 17.

It works fine; I can read/write from/to them. Although, I am experiencing an issue with a software that deals with pen drive and other USB devices. This program tries to list the available devices by running the following:

ls -l /dev/disk/by-id/usb*

and returns nothing.

So, I ran in terminal: ls -l /dev/disk/by-id/* and got this:

ata-hp_DVDRAM_GT30L_KZEA6810820
ata-SAMSUNG_HM321HX_C5733G82AB0BPW
ata-WDC_WD3200BEKT-60V5T1_WD-WX81A50J4370
wwn-0x50000f00ab0b000b
wwn-0x50014ee20495cc9f

in /dev/disk/by-uuid, my UBS-HDD is: 19ED-1878 -> ../../sdb

My external HD is, so, listed as "ata-SAMSUNG...." and can not be found as "usb*...".

I googled a lot about that. Found that editing /etc/fstab or /boot/grub/grub.conf would help me (haven't found anything related to my USB dev in grub.conf nor fstab). Or something like ZFS, zpool.. and even a tool that deals (only?) with the UUID, tune2fs.

But as a beginner-level Linux user, I don't know what to do.

So, is it possible to change /dev/disk/by-id/ata-SAMSUNG... to ../../by-id/usb-SAMSUNG...? And if so, how?

share|improve this question
    
You could try adding a symlink there manually. It may persist at best until next reboot, but still. –  mirabilos Feb 28 at 17:04
    
What distro are you using? –  Graeme Feb 28 at 17:58
    
@mirabilos Symlink was the solution for my problem. Thanks a lot, pal. –  Nic61629 Mar 7 at 0:01
    
@Graeme I am using Ubuntu 13.10 and Fedora 17. –  Nic61629 Mar 7 at 0:01
    
Ok, those both use udev, so my answer should put you on the right track. –  Graeme Mar 7 at 0:07

1 Answer 1

up vote 1 down vote accepted

Ok I guessing this is a udev issue (most Linux distros use this by default), this is what creates the symlinks. You can fix this by add a new rule. I will give some info on this, but it is largely anchored in my own distro - Debian.

First off, you need to find where your rules are. Debian has them in two locations - /lib/udev/rules.d and /etc/udev/rules.d. If this is the case for you should only add/change the ones under /etc as changing another location is more likely to lead to being overwritten by an update.

Go to the rules directory and see if you can find the file(s) with the rules for creating the links under disk/by-id. The command grep -r disk/by-id/ is going to help here (though only run it in the rules directory to avoid searching other places). For me the file is /var/lib/rules.d/60-persistent-storage.rules. Here are the lines that are creating the`disk/by-id/usb-* links for me:

ENV{DEVTYPE}=="disk",   ENV{ID_BUS}=="?*", ENV{ID_SERIAL}=="?*", \
  SYMLINK+="disk/by-id/$env{ID_BUS}-$env{ID_SERIAL}"

ENV{DEVTYPE}=="partition",  ENV{ID_BUS}=="?*", ENV{ID_SERIAL}=="?*", \
  SYMLINK+="disk/by-id/$env{ID_BUS}-$env{ID_SERIAL}-part%n"

There are two possibilities here (apart from the one where your system doesn't use udev at all):

  1. You have no line similar to this and you need to create one.
  2. You do, but it just doesn't work for you disk.

The lines might look like gibberish, but basically the first two (really one as the \ is just a way of splitting long line) are for links relating to the disk itself, the other two are for its partitions.

Hopefully running this command should make things less confusing:

udevadm info --name=/dev/sdb --query=property

This shows the names/values of all the properties of your device. Basically all the rule does is go through all the properties of each device and matches them against the first part of the line (eg the first looks for devices with DEVTYPE=disk, and non-empty ID_BUS and ID_SERIAL). The next part creates a symlink with its name containing ID_BUS and ID_SERIAL.

Anyway, what this boils down to is if you have ID_BUS=usb, you can probably go ahead and add the above rule. If not, you probably need to add specific rules for your device. Something like:

ENV{ID_SERIAL}=="SAMSUNG_HM321HX_C5733G82AB0BPW", \
  SYMLINK+="disk/by-id/usb-$env{ID_SERIAL}"

ENV{ID_SERIAL}=="SAMSUNG_HM321HX_C5733G82AB0BPW", \
  SYMLINK+="disk/by-id/usb-$env{ID_SERIAL}-part%n"

I have guessed your ID_SERIAL from the question, if its wrong go ahead and put in the right one.

The rules are probably best in a file of their own, something like s2-samsung-usb.rules in the directory you found at the start.

Update: the below probably isn't necessary, just unplug and the plug the device in again - How to reload udev rules without reboot?

Once you are done, you can reload the rules with (unplug your device first):

udevadm control --reload-rules

Then plug in your device again. If this doesn't work, you can always try rebooting (in fact this may be safer anyway).

share|improve this answer
    
Superb! Your answer solved my problem. Learned a lot from it. Thank you very much. –  Nic61629 Mar 7 at 0:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.