Jump to content

Do drives in Linux change their /dev/ location?

Hi!

I am running Linux on my Raspberry Pi and I have hdparm set to stop my hdd that is on /dev/sda after 10 minutes. I was wondering if when I add another drive or reboot it it will change the drive's location.

 

Thanks!

i'm a potato

Link to comment
Share on other sites

Link to post
Share on other sites

I don't know what exactly determines device order (BIOS/hardware?) but it can change if a higher priority device is introduced. I don't think it will change if you don't add new devices or move things around to different ports.

 

You can reference disks by ID which will never change. Show symlink mappings like this:

ls -la /dev/disk/by-id/

This will probably work with most things.

Link to comment
Share on other sites

Link to post
Share on other sites

Well, in the quest to answer your question I learned a little bit more myself!

 

In my experience, the device file names do not change much. My 2 sata disks have had the same file names since I first set up the system (/dev/sda and /dev/sdb) as far as I know (I don't check it every time). However I never changed/switched them.

On the other hand, external USB HDDs and pen drives tend to share the same name (sdc) if I plug one, unplug, then plug the other. This is expected, since the names are given in the order the drives are registered, but the files are removed after unplugging.

So, in theory, you should not trust the device file names.

 

Enter, udev.

udev creates symbolic links with fixed names to identify the drives. Since each different device has a different id, this is the best method to unambiguously identify them.

You can find the links in /dev/disk/by-*. You have 3 methods of identification: by-id, by-label and by-uuid.

According to an answer in http://askubuntu.com/questions/39760/how-can-i-control-hdd-spin-down-time you can configure hdparm using these links.

 

More reading material: http://www.reactivated.net/writing_udev_rules.html

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×