Is it possible to make the device filesystem name , /dev/sd?1 , stay constant every time we reconnect the SanDisk USB Cruzer drive?
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
Is it possible to make the device filesystem name , /dev/sdi1 , shown by lsblk -f
stay constant every time we disconnect and reconnect the SanDisk USB Cruzer drive? I am running Ubuntu Linux 16.04 on an Lenovo Thinkstation desktop computer.
I believe the SanDisk USB Cruzer drive automatically mounts on insertion.
If it is possible, what are the steps necessary to make this possible?
ubuntu usb udev devices
add a comment |Â
up vote
1
down vote
favorite
Is it possible to make the device filesystem name , /dev/sdi1 , shown by lsblk -f
stay constant every time we disconnect and reconnect the SanDisk USB Cruzer drive? I am running Ubuntu Linux 16.04 on an Lenovo Thinkstation desktop computer.
I believe the SanDisk USB Cruzer drive automatically mounts on insertion.
If it is possible, what are the steps necessary to make this possible?
ubuntu usb udev devices
Most applications dont care what/dev/sd?
is used, as it can always be found (egfindmnt
) if you use a disc LABEL or UUID for example. Can you say why you need to fix the device?
â meuh
May 25 '16 at 17:50
@meuh, Thank you for your comment. Currently we are looking at how to make usb device filename persist across reboots or unplugging and replugging in the usb for Ubuntu Linux 16.04. When I keep plugging them in and pulling them out from the USB ports and they keep getting names like /dev/sdg1 or /dev/sdi1 . However, the device names are not persistent â whether the BusPirate pops up as /dev/sdg1 or /dev/sdi1 depends on the order in which are the devices discovered by the kernel.
â Frank
May 25 '16 at 18:00
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
Is it possible to make the device filesystem name , /dev/sdi1 , shown by lsblk -f
stay constant every time we disconnect and reconnect the SanDisk USB Cruzer drive? I am running Ubuntu Linux 16.04 on an Lenovo Thinkstation desktop computer.
I believe the SanDisk USB Cruzer drive automatically mounts on insertion.
If it is possible, what are the steps necessary to make this possible?
ubuntu usb udev devices
Is it possible to make the device filesystem name , /dev/sdi1 , shown by lsblk -f
stay constant every time we disconnect and reconnect the SanDisk USB Cruzer drive? I am running Ubuntu Linux 16.04 on an Lenovo Thinkstation desktop computer.
I believe the SanDisk USB Cruzer drive automatically mounts on insertion.
If it is possible, what are the steps necessary to make this possible?
ubuntu usb udev devices
ubuntu usb udev devices
edited Sep 22 at 12:30
Jeff Schaller
33.3k849111
33.3k849111
asked May 25 '16 at 17:39
Frank
2781618
2781618
Most applications dont care what/dev/sd?
is used, as it can always be found (egfindmnt
) if you use a disc LABEL or UUID for example. Can you say why you need to fix the device?
â meuh
May 25 '16 at 17:50
@meuh, Thank you for your comment. Currently we are looking at how to make usb device filename persist across reboots or unplugging and replugging in the usb for Ubuntu Linux 16.04. When I keep plugging them in and pulling them out from the USB ports and they keep getting names like /dev/sdg1 or /dev/sdi1 . However, the device names are not persistent â whether the BusPirate pops up as /dev/sdg1 or /dev/sdi1 depends on the order in which are the devices discovered by the kernel.
â Frank
May 25 '16 at 18:00
add a comment |Â
Most applications dont care what/dev/sd?
is used, as it can always be found (egfindmnt
) if you use a disc LABEL or UUID for example. Can you say why you need to fix the device?
â meuh
May 25 '16 at 17:50
@meuh, Thank you for your comment. Currently we are looking at how to make usb device filename persist across reboots or unplugging and replugging in the usb for Ubuntu Linux 16.04. When I keep plugging them in and pulling them out from the USB ports and they keep getting names like /dev/sdg1 or /dev/sdi1 . However, the device names are not persistent â whether the BusPirate pops up as /dev/sdg1 or /dev/sdi1 depends on the order in which are the devices discovered by the kernel.
â Frank
May 25 '16 at 18:00
Most applications dont care what
/dev/sd?
is used, as it can always be found (eg findmnt
) if you use a disc LABEL or UUID for example. Can you say why you need to fix the device?â meuh
May 25 '16 at 17:50
Most applications dont care what
/dev/sd?
is used, as it can always be found (eg findmnt
) if you use a disc LABEL or UUID for example. Can you say why you need to fix the device?â meuh
May 25 '16 at 17:50
@meuh, Thank you for your comment. Currently we are looking at how to make usb device filename persist across reboots or unplugging and replugging in the usb for Ubuntu Linux 16.04. When I keep plugging them in and pulling them out from the USB ports and they keep getting names like /dev/sdg1 or /dev/sdi1 . However, the device names are not persistent â whether the BusPirate pops up as /dev/sdg1 or /dev/sdi1 depends on the order in which are the devices discovered by the kernel.
â Frank
May 25 '16 at 18:00
@meuh, Thank you for your comment. Currently we are looking at how to make usb device filename persist across reboots or unplugging and replugging in the usb for Ubuntu Linux 16.04. When I keep plugging them in and pulling them out from the USB ports and they keep getting names like /dev/sdg1 or /dev/sdi1 . However, the device names are not persistent â whether the BusPirate pops up as /dev/sdg1 or /dev/sdi1 depends on the order in which are the devices discovered by the kernel.
â Frank
May 25 '16 at 18:00
add a comment |Â
3 Answers
3
active
oldest
votes
up vote
2
down vote
accepted
You would need to specify the mounting point based on the device's UUID.
You should refer to the official Ubuntu documentation page on the subject for usage details.
Here are examples (your output will be different, but similarly formatted). The command:
sudo blkid
produces an output similar to:
/dev/sda1: TYPE="ntfs" UUID="72C0DE8EC0DE57C5" LABEL="windows"
/dev/sda2: UUID="30fcb748-ad1e-4228-af2f-951e8e7b56df" TYPE="ext4"
/dev/sda5: TYPE="swap" UUID="8c4e69f8-5074-42c0-8134-0b2429c4c02c"
/dev/sdb1: SEC_TYPE="msdos" UUID="4848-E35A" TYPE="vfat"
you would then have to change the entry in fstab
from:
/dev/sda2 /mnt/Mint ext4 defaults 0 0
to something like:
UUID=30fcb748-ad1e-4228-af2f-951e8e7b56df /mnt/Mint ext4 defaults 0 0
Thank you for your nice answer. Thank you for your comment. Currently we are looking at how to make usb device filename persist across reboots or unplugging and replugging in the usb for Ubuntu Linux 16.04. When I keep plugging them in and pulling them out from the USB ports and they keep getting names like /dev/sdg1 or /dev/sdi1 . However, the device names are not persistent because it depends on the order in which are the devices discovered by the kernel. May I ask why does specifying the mounting point based on the USB device's UUID solve our requirement?
â Frank
May 25 '16 at 18:04
Yes, that's exactly the point.
â Julie Pelletier
May 25 '16 at 19:40
@Fergus-Incoronato: Nice edit!
â Julie Pelletier
May 26 '16 at 0:07
I enjoyed reading your answer. If I change your fstab example to: /dev/usbhd1 /mnt/Mint ext4 defaults 0 0 where /dev/usbhd1 is Serge's symbolic link, what should the lsblk -f output look like? My architect manager would like to find out what the significance of your nice answer is on preserving mount points across reboots and USB reinsertions?
â Frank
May 26 '16 at 0:21
@Frank:lsblk -f
's output is not affected by mounts. What will change is the actual device associated (/dev/sda2) but the UUID will always match that actual USB key. (with the only exception would be if you would have cloned the key.)
â Julie Pelletier
May 26 '16 at 0:51
 |Â
show 10 more comments
up vote
2
down vote
I am almost sure it's not possible to assign the # of sd, but you might work this around with udev
rule that would set up links to the actual sdX and sdXY upon disk drive connection:
KERNEL=="sd*", SUBSYSTEMS=="scsi", ATTRSmodel=="USB 2.0 Storage
Device", SYMLINK+="usbhd%n"
would create these links:
- /dev/usbhd - The fdiskable node
- /dev/usbhd1 - The first partition (mountable)
- /dev/usbhd2 - The second partition (mountable)
Source
Thank you for your nice answer. Once I create your rule using sudo nano /etc/udev/rules.d/10-local.rules, how do I make sure the 3 links you mentioned in your answer get created properly? What should I do after: sudo /etc/init.d/udev restart?
â Frank
May 25 '16 at 18:10
Just reconnect the device. Alternatively, useudevadm trigger
command (seeman udevadm
)
â Serge
May 25 '16 at 18:35
Please note, that you might have to change the model string in the rule. Also you could use serial no of the device to match. Seeudev
docs for details and samples
â Serge
May 25 '16 at 18:37
Thank you for your 2 great comments. I just followed your recommendation to just reconnect the USB device and I can now see the links /dev/usbhd and /dev/usbhd1. Could I ask why it's not possible to assign the # of the sd?
â Frank
May 25 '16 at 18:41
@Fergus-Incoronato, Nice edit of Julie Pelletier's answer. How do I use Serge's answer with /etc/fstab? Thank you very much.
â Frank
May 26 '16 at 0:35
 |Â
show 7 more comments
up vote
1
down vote
Another way of finding the /dev/sd
device that corresponds to a disc that has no LABEL nor UUID is to use its serial id. For example, my SSD says
$ sudo hdparm -I /dev/sda
Model Number: KINGSTON SH103S3240G
Serial Number: 50999B9999926F99
And I can find which /dev/sd
device it is by following the link in /dev/disk/by-id/
using the serial id built from this information. Eg
$ ls -l /dev/disk/by-id/ata-KINGSTON_SH103S3240G_50999B9999926F99
lrwxrwxrwx 1 root root 9 Apr 28 17:22 /dev/disk/by-id/ata-KINGSTON_SH103S3240G_50999B9999926F99 -> ../../sda
Usually, we set a UUID on a partition then we can find the device simply with findmnt
. Eg
$ findmnt -n -o source UUID=e7522030-f6e3-472d-8013-3a3316fd15a3
/dev/sda3
Thank you for your nice answer and comment. Here is my udev rule using your serial id suggestion: SUBSYSTEMS=="usb",ATTRSserial=="4C530001041030118021",KERNEL=="sd*", SYMLINK+="usbhd%n". After I restart the udev service using sudo /etc/init.d/udev restart I still cannot find the links /dev/usbhd , /dev/usbhd1 or/dev/usbhd2. May I ask what steps I forgot to do or what mistakes I made?
â Frank
May 25 '16 at 18:31
Did you unplug/replug the device? You might want to addACTION=="add",
and put your file last in the rules (ie rename it 99-...)
â meuh
May 25 '16 at 18:37
@mueh, Thank you for your comment. Do I need to unplug and replug the device after I add ACTION=="add" to the udev rule?
â Frank
May 25 '16 at 18:43
I see from the other answer you have created the links ok. TheACTION=="add",
is for the future, to only create the links when the device is plugged in (added). I'm not sure if you need to create another rule to remove the link when you unplug the device (ACTION=="remove",
).
â meuh
May 25 '16 at 18:48
Thank you for your comments and answer today. Why does not the /dev/usbhd1 , the symbolic link to the first partition, show up in the lsblk -f output? What happens if change the mount point from /home/frank/data1 to /home/frank/data59 corresponding to the symbolic link /dev/usbhd1?
â Frank
May 25 '16 at 19:00
 |Â
show 6 more comments
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
You would need to specify the mounting point based on the device's UUID.
You should refer to the official Ubuntu documentation page on the subject for usage details.
Here are examples (your output will be different, but similarly formatted). The command:
sudo blkid
produces an output similar to:
/dev/sda1: TYPE="ntfs" UUID="72C0DE8EC0DE57C5" LABEL="windows"
/dev/sda2: UUID="30fcb748-ad1e-4228-af2f-951e8e7b56df" TYPE="ext4"
/dev/sda5: TYPE="swap" UUID="8c4e69f8-5074-42c0-8134-0b2429c4c02c"
/dev/sdb1: SEC_TYPE="msdos" UUID="4848-E35A" TYPE="vfat"
you would then have to change the entry in fstab
from:
/dev/sda2 /mnt/Mint ext4 defaults 0 0
to something like:
UUID=30fcb748-ad1e-4228-af2f-951e8e7b56df /mnt/Mint ext4 defaults 0 0
Thank you for your nice answer. Thank you for your comment. Currently we are looking at how to make usb device filename persist across reboots or unplugging and replugging in the usb for Ubuntu Linux 16.04. When I keep plugging them in and pulling them out from the USB ports and they keep getting names like /dev/sdg1 or /dev/sdi1 . However, the device names are not persistent because it depends on the order in which are the devices discovered by the kernel. May I ask why does specifying the mounting point based on the USB device's UUID solve our requirement?
â Frank
May 25 '16 at 18:04
Yes, that's exactly the point.
â Julie Pelletier
May 25 '16 at 19:40
@Fergus-Incoronato: Nice edit!
â Julie Pelletier
May 26 '16 at 0:07
I enjoyed reading your answer. If I change your fstab example to: /dev/usbhd1 /mnt/Mint ext4 defaults 0 0 where /dev/usbhd1 is Serge's symbolic link, what should the lsblk -f output look like? My architect manager would like to find out what the significance of your nice answer is on preserving mount points across reboots and USB reinsertions?
â Frank
May 26 '16 at 0:21
@Frank:lsblk -f
's output is not affected by mounts. What will change is the actual device associated (/dev/sda2) but the UUID will always match that actual USB key. (with the only exception would be if you would have cloned the key.)
â Julie Pelletier
May 26 '16 at 0:51
 |Â
show 10 more comments
up vote
2
down vote
accepted
You would need to specify the mounting point based on the device's UUID.
You should refer to the official Ubuntu documentation page on the subject for usage details.
Here are examples (your output will be different, but similarly formatted). The command:
sudo blkid
produces an output similar to:
/dev/sda1: TYPE="ntfs" UUID="72C0DE8EC0DE57C5" LABEL="windows"
/dev/sda2: UUID="30fcb748-ad1e-4228-af2f-951e8e7b56df" TYPE="ext4"
/dev/sda5: TYPE="swap" UUID="8c4e69f8-5074-42c0-8134-0b2429c4c02c"
/dev/sdb1: SEC_TYPE="msdos" UUID="4848-E35A" TYPE="vfat"
you would then have to change the entry in fstab
from:
/dev/sda2 /mnt/Mint ext4 defaults 0 0
to something like:
UUID=30fcb748-ad1e-4228-af2f-951e8e7b56df /mnt/Mint ext4 defaults 0 0
Thank you for your nice answer. Thank you for your comment. Currently we are looking at how to make usb device filename persist across reboots or unplugging and replugging in the usb for Ubuntu Linux 16.04. When I keep plugging them in and pulling them out from the USB ports and they keep getting names like /dev/sdg1 or /dev/sdi1 . However, the device names are not persistent because it depends on the order in which are the devices discovered by the kernel. May I ask why does specifying the mounting point based on the USB device's UUID solve our requirement?
â Frank
May 25 '16 at 18:04
Yes, that's exactly the point.
â Julie Pelletier
May 25 '16 at 19:40
@Fergus-Incoronato: Nice edit!
â Julie Pelletier
May 26 '16 at 0:07
I enjoyed reading your answer. If I change your fstab example to: /dev/usbhd1 /mnt/Mint ext4 defaults 0 0 where /dev/usbhd1 is Serge's symbolic link, what should the lsblk -f output look like? My architect manager would like to find out what the significance of your nice answer is on preserving mount points across reboots and USB reinsertions?
â Frank
May 26 '16 at 0:21
@Frank:lsblk -f
's output is not affected by mounts. What will change is the actual device associated (/dev/sda2) but the UUID will always match that actual USB key. (with the only exception would be if you would have cloned the key.)
â Julie Pelletier
May 26 '16 at 0:51
 |Â
show 10 more comments
up vote
2
down vote
accepted
up vote
2
down vote
accepted
You would need to specify the mounting point based on the device's UUID.
You should refer to the official Ubuntu documentation page on the subject for usage details.
Here are examples (your output will be different, but similarly formatted). The command:
sudo blkid
produces an output similar to:
/dev/sda1: TYPE="ntfs" UUID="72C0DE8EC0DE57C5" LABEL="windows"
/dev/sda2: UUID="30fcb748-ad1e-4228-af2f-951e8e7b56df" TYPE="ext4"
/dev/sda5: TYPE="swap" UUID="8c4e69f8-5074-42c0-8134-0b2429c4c02c"
/dev/sdb1: SEC_TYPE="msdos" UUID="4848-E35A" TYPE="vfat"
you would then have to change the entry in fstab
from:
/dev/sda2 /mnt/Mint ext4 defaults 0 0
to something like:
UUID=30fcb748-ad1e-4228-af2f-951e8e7b56df /mnt/Mint ext4 defaults 0 0
You would need to specify the mounting point based on the device's UUID.
You should refer to the official Ubuntu documentation page on the subject for usage details.
Here are examples (your output will be different, but similarly formatted). The command:
sudo blkid
produces an output similar to:
/dev/sda1: TYPE="ntfs" UUID="72C0DE8EC0DE57C5" LABEL="windows"
/dev/sda2: UUID="30fcb748-ad1e-4228-af2f-951e8e7b56df" TYPE="ext4"
/dev/sda5: TYPE="swap" UUID="8c4e69f8-5074-42c0-8134-0b2429c4c02c"
/dev/sdb1: SEC_TYPE="msdos" UUID="4848-E35A" TYPE="vfat"
you would then have to change the entry in fstab
from:
/dev/sda2 /mnt/Mint ext4 defaults 0 0
to something like:
UUID=30fcb748-ad1e-4228-af2f-951e8e7b56df /mnt/Mint ext4 defaults 0 0
edited May 26 '16 at 0:06
Fergus Incoronato
32
32
answered May 25 '16 at 17:51
Julie Pelletier
6,90211239
6,90211239
Thank you for your nice answer. Thank you for your comment. Currently we are looking at how to make usb device filename persist across reboots or unplugging and replugging in the usb for Ubuntu Linux 16.04. When I keep plugging them in and pulling them out from the USB ports and they keep getting names like /dev/sdg1 or /dev/sdi1 . However, the device names are not persistent because it depends on the order in which are the devices discovered by the kernel. May I ask why does specifying the mounting point based on the USB device's UUID solve our requirement?
â Frank
May 25 '16 at 18:04
Yes, that's exactly the point.
â Julie Pelletier
May 25 '16 at 19:40
@Fergus-Incoronato: Nice edit!
â Julie Pelletier
May 26 '16 at 0:07
I enjoyed reading your answer. If I change your fstab example to: /dev/usbhd1 /mnt/Mint ext4 defaults 0 0 where /dev/usbhd1 is Serge's symbolic link, what should the lsblk -f output look like? My architect manager would like to find out what the significance of your nice answer is on preserving mount points across reboots and USB reinsertions?
â Frank
May 26 '16 at 0:21
@Frank:lsblk -f
's output is not affected by mounts. What will change is the actual device associated (/dev/sda2) but the UUID will always match that actual USB key. (with the only exception would be if you would have cloned the key.)
â Julie Pelletier
May 26 '16 at 0:51
 |Â
show 10 more comments
Thank you for your nice answer. Thank you for your comment. Currently we are looking at how to make usb device filename persist across reboots or unplugging and replugging in the usb for Ubuntu Linux 16.04. When I keep plugging them in and pulling them out from the USB ports and they keep getting names like /dev/sdg1 or /dev/sdi1 . However, the device names are not persistent because it depends on the order in which are the devices discovered by the kernel. May I ask why does specifying the mounting point based on the USB device's UUID solve our requirement?
â Frank
May 25 '16 at 18:04
Yes, that's exactly the point.
â Julie Pelletier
May 25 '16 at 19:40
@Fergus-Incoronato: Nice edit!
â Julie Pelletier
May 26 '16 at 0:07
I enjoyed reading your answer. If I change your fstab example to: /dev/usbhd1 /mnt/Mint ext4 defaults 0 0 where /dev/usbhd1 is Serge's symbolic link, what should the lsblk -f output look like? My architect manager would like to find out what the significance of your nice answer is on preserving mount points across reboots and USB reinsertions?
â Frank
May 26 '16 at 0:21
@Frank:lsblk -f
's output is not affected by mounts. What will change is the actual device associated (/dev/sda2) but the UUID will always match that actual USB key. (with the only exception would be if you would have cloned the key.)
â Julie Pelletier
May 26 '16 at 0:51
Thank you for your nice answer. Thank you for your comment. Currently we are looking at how to make usb device filename persist across reboots or unplugging and replugging in the usb for Ubuntu Linux 16.04. When I keep plugging them in and pulling them out from the USB ports and they keep getting names like /dev/sdg1 or /dev/sdi1 . However, the device names are not persistent because it depends on the order in which are the devices discovered by the kernel. May I ask why does specifying the mounting point based on the USB device's UUID solve our requirement?
â Frank
May 25 '16 at 18:04
Thank you for your nice answer. Thank you for your comment. Currently we are looking at how to make usb device filename persist across reboots or unplugging and replugging in the usb for Ubuntu Linux 16.04. When I keep plugging them in and pulling them out from the USB ports and they keep getting names like /dev/sdg1 or /dev/sdi1 . However, the device names are not persistent because it depends on the order in which are the devices discovered by the kernel. May I ask why does specifying the mounting point based on the USB device's UUID solve our requirement?
â Frank
May 25 '16 at 18:04
Yes, that's exactly the point.
â Julie Pelletier
May 25 '16 at 19:40
Yes, that's exactly the point.
â Julie Pelletier
May 25 '16 at 19:40
@Fergus-Incoronato: Nice edit!
â Julie Pelletier
May 26 '16 at 0:07
@Fergus-Incoronato: Nice edit!
â Julie Pelletier
May 26 '16 at 0:07
I enjoyed reading your answer. If I change your fstab example to: /dev/usbhd1 /mnt/Mint ext4 defaults 0 0 where /dev/usbhd1 is Serge's symbolic link, what should the lsblk -f output look like? My architect manager would like to find out what the significance of your nice answer is on preserving mount points across reboots and USB reinsertions?
â Frank
May 26 '16 at 0:21
I enjoyed reading your answer. If I change your fstab example to: /dev/usbhd1 /mnt/Mint ext4 defaults 0 0 where /dev/usbhd1 is Serge's symbolic link, what should the lsblk -f output look like? My architect manager would like to find out what the significance of your nice answer is on preserving mount points across reboots and USB reinsertions?
â Frank
May 26 '16 at 0:21
@Frank:
lsblk -f
's output is not affected by mounts. What will change is the actual device associated (/dev/sda2) but the UUID will always match that actual USB key. (with the only exception would be if you would have cloned the key.)â Julie Pelletier
May 26 '16 at 0:51
@Frank:
lsblk -f
's output is not affected by mounts. What will change is the actual device associated (/dev/sda2) but the UUID will always match that actual USB key. (with the only exception would be if you would have cloned the key.)â Julie Pelletier
May 26 '16 at 0:51
 |Â
show 10 more comments
up vote
2
down vote
I am almost sure it's not possible to assign the # of sd, but you might work this around with udev
rule that would set up links to the actual sdX and sdXY upon disk drive connection:
KERNEL=="sd*", SUBSYSTEMS=="scsi", ATTRSmodel=="USB 2.0 Storage
Device", SYMLINK+="usbhd%n"
would create these links:
- /dev/usbhd - The fdiskable node
- /dev/usbhd1 - The first partition (mountable)
- /dev/usbhd2 - The second partition (mountable)
Source
Thank you for your nice answer. Once I create your rule using sudo nano /etc/udev/rules.d/10-local.rules, how do I make sure the 3 links you mentioned in your answer get created properly? What should I do after: sudo /etc/init.d/udev restart?
â Frank
May 25 '16 at 18:10
Just reconnect the device. Alternatively, useudevadm trigger
command (seeman udevadm
)
â Serge
May 25 '16 at 18:35
Please note, that you might have to change the model string in the rule. Also you could use serial no of the device to match. Seeudev
docs for details and samples
â Serge
May 25 '16 at 18:37
Thank you for your 2 great comments. I just followed your recommendation to just reconnect the USB device and I can now see the links /dev/usbhd and /dev/usbhd1. Could I ask why it's not possible to assign the # of the sd?
â Frank
May 25 '16 at 18:41
@Fergus-Incoronato, Nice edit of Julie Pelletier's answer. How do I use Serge's answer with /etc/fstab? Thank you very much.
â Frank
May 26 '16 at 0:35
 |Â
show 7 more comments
up vote
2
down vote
I am almost sure it's not possible to assign the # of sd, but you might work this around with udev
rule that would set up links to the actual sdX and sdXY upon disk drive connection:
KERNEL=="sd*", SUBSYSTEMS=="scsi", ATTRSmodel=="USB 2.0 Storage
Device", SYMLINK+="usbhd%n"
would create these links:
- /dev/usbhd - The fdiskable node
- /dev/usbhd1 - The first partition (mountable)
- /dev/usbhd2 - The second partition (mountable)
Source
Thank you for your nice answer. Once I create your rule using sudo nano /etc/udev/rules.d/10-local.rules, how do I make sure the 3 links you mentioned in your answer get created properly? What should I do after: sudo /etc/init.d/udev restart?
â Frank
May 25 '16 at 18:10
Just reconnect the device. Alternatively, useudevadm trigger
command (seeman udevadm
)
â Serge
May 25 '16 at 18:35
Please note, that you might have to change the model string in the rule. Also you could use serial no of the device to match. Seeudev
docs for details and samples
â Serge
May 25 '16 at 18:37
Thank you for your 2 great comments. I just followed your recommendation to just reconnect the USB device and I can now see the links /dev/usbhd and /dev/usbhd1. Could I ask why it's not possible to assign the # of the sd?
â Frank
May 25 '16 at 18:41
@Fergus-Incoronato, Nice edit of Julie Pelletier's answer. How do I use Serge's answer with /etc/fstab? Thank you very much.
â Frank
May 26 '16 at 0:35
 |Â
show 7 more comments
up vote
2
down vote
up vote
2
down vote
I am almost sure it's not possible to assign the # of sd, but you might work this around with udev
rule that would set up links to the actual sdX and sdXY upon disk drive connection:
KERNEL=="sd*", SUBSYSTEMS=="scsi", ATTRSmodel=="USB 2.0 Storage
Device", SYMLINK+="usbhd%n"
would create these links:
- /dev/usbhd - The fdiskable node
- /dev/usbhd1 - The first partition (mountable)
- /dev/usbhd2 - The second partition (mountable)
Source
I am almost sure it's not possible to assign the # of sd, but you might work this around with udev
rule that would set up links to the actual sdX and sdXY upon disk drive connection:
KERNEL=="sd*", SUBSYSTEMS=="scsi", ATTRSmodel=="USB 2.0 Storage
Device", SYMLINK+="usbhd%n"
would create these links:
- /dev/usbhd - The fdiskable node
- /dev/usbhd1 - The first partition (mountable)
- /dev/usbhd2 - The second partition (mountable)
Source
answered May 25 '16 at 17:51
Serge
5,42521324
5,42521324
Thank you for your nice answer. Once I create your rule using sudo nano /etc/udev/rules.d/10-local.rules, how do I make sure the 3 links you mentioned in your answer get created properly? What should I do after: sudo /etc/init.d/udev restart?
â Frank
May 25 '16 at 18:10
Just reconnect the device. Alternatively, useudevadm trigger
command (seeman udevadm
)
â Serge
May 25 '16 at 18:35
Please note, that you might have to change the model string in the rule. Also you could use serial no of the device to match. Seeudev
docs for details and samples
â Serge
May 25 '16 at 18:37
Thank you for your 2 great comments. I just followed your recommendation to just reconnect the USB device and I can now see the links /dev/usbhd and /dev/usbhd1. Could I ask why it's not possible to assign the # of the sd?
â Frank
May 25 '16 at 18:41
@Fergus-Incoronato, Nice edit of Julie Pelletier's answer. How do I use Serge's answer with /etc/fstab? Thank you very much.
â Frank
May 26 '16 at 0:35
 |Â
show 7 more comments
Thank you for your nice answer. Once I create your rule using sudo nano /etc/udev/rules.d/10-local.rules, how do I make sure the 3 links you mentioned in your answer get created properly? What should I do after: sudo /etc/init.d/udev restart?
â Frank
May 25 '16 at 18:10
Just reconnect the device. Alternatively, useudevadm trigger
command (seeman udevadm
)
â Serge
May 25 '16 at 18:35
Please note, that you might have to change the model string in the rule. Also you could use serial no of the device to match. Seeudev
docs for details and samples
â Serge
May 25 '16 at 18:37
Thank you for your 2 great comments. I just followed your recommendation to just reconnect the USB device and I can now see the links /dev/usbhd and /dev/usbhd1. Could I ask why it's not possible to assign the # of the sd?
â Frank
May 25 '16 at 18:41
@Fergus-Incoronato, Nice edit of Julie Pelletier's answer. How do I use Serge's answer with /etc/fstab? Thank you very much.
â Frank
May 26 '16 at 0:35
Thank you for your nice answer. Once I create your rule using sudo nano /etc/udev/rules.d/10-local.rules, how do I make sure the 3 links you mentioned in your answer get created properly? What should I do after: sudo /etc/init.d/udev restart?
â Frank
May 25 '16 at 18:10
Thank you for your nice answer. Once I create your rule using sudo nano /etc/udev/rules.d/10-local.rules, how do I make sure the 3 links you mentioned in your answer get created properly? What should I do after: sudo /etc/init.d/udev restart?
â Frank
May 25 '16 at 18:10
Just reconnect the device. Alternatively, use
udevadm trigger
command (see man udevadm
)â Serge
May 25 '16 at 18:35
Just reconnect the device. Alternatively, use
udevadm trigger
command (see man udevadm
)â Serge
May 25 '16 at 18:35
Please note, that you might have to change the model string in the rule. Also you could use serial no of the device to match. See
udev
docs for details and samplesâ Serge
May 25 '16 at 18:37
Please note, that you might have to change the model string in the rule. Also you could use serial no of the device to match. See
udev
docs for details and samplesâ Serge
May 25 '16 at 18:37
Thank you for your 2 great comments. I just followed your recommendation to just reconnect the USB device and I can now see the links /dev/usbhd and /dev/usbhd1. Could I ask why it's not possible to assign the # of the sd?
â Frank
May 25 '16 at 18:41
Thank you for your 2 great comments. I just followed your recommendation to just reconnect the USB device and I can now see the links /dev/usbhd and /dev/usbhd1. Could I ask why it's not possible to assign the # of the sd?
â Frank
May 25 '16 at 18:41
@Fergus-Incoronato, Nice edit of Julie Pelletier's answer. How do I use Serge's answer with /etc/fstab? Thank you very much.
â Frank
May 26 '16 at 0:35
@Fergus-Incoronato, Nice edit of Julie Pelletier's answer. How do I use Serge's answer with /etc/fstab? Thank you very much.
â Frank
May 26 '16 at 0:35
 |Â
show 7 more comments
up vote
1
down vote
Another way of finding the /dev/sd
device that corresponds to a disc that has no LABEL nor UUID is to use its serial id. For example, my SSD says
$ sudo hdparm -I /dev/sda
Model Number: KINGSTON SH103S3240G
Serial Number: 50999B9999926F99
And I can find which /dev/sd
device it is by following the link in /dev/disk/by-id/
using the serial id built from this information. Eg
$ ls -l /dev/disk/by-id/ata-KINGSTON_SH103S3240G_50999B9999926F99
lrwxrwxrwx 1 root root 9 Apr 28 17:22 /dev/disk/by-id/ata-KINGSTON_SH103S3240G_50999B9999926F99 -> ../../sda
Usually, we set a UUID on a partition then we can find the device simply with findmnt
. Eg
$ findmnt -n -o source UUID=e7522030-f6e3-472d-8013-3a3316fd15a3
/dev/sda3
Thank you for your nice answer and comment. Here is my udev rule using your serial id suggestion: SUBSYSTEMS=="usb",ATTRSserial=="4C530001041030118021",KERNEL=="sd*", SYMLINK+="usbhd%n". After I restart the udev service using sudo /etc/init.d/udev restart I still cannot find the links /dev/usbhd , /dev/usbhd1 or/dev/usbhd2. May I ask what steps I forgot to do or what mistakes I made?
â Frank
May 25 '16 at 18:31
Did you unplug/replug the device? You might want to addACTION=="add",
and put your file last in the rules (ie rename it 99-...)
â meuh
May 25 '16 at 18:37
@mueh, Thank you for your comment. Do I need to unplug and replug the device after I add ACTION=="add" to the udev rule?
â Frank
May 25 '16 at 18:43
I see from the other answer you have created the links ok. TheACTION=="add",
is for the future, to only create the links when the device is plugged in (added). I'm not sure if you need to create another rule to remove the link when you unplug the device (ACTION=="remove",
).
â meuh
May 25 '16 at 18:48
Thank you for your comments and answer today. Why does not the /dev/usbhd1 , the symbolic link to the first partition, show up in the lsblk -f output? What happens if change the mount point from /home/frank/data1 to /home/frank/data59 corresponding to the symbolic link /dev/usbhd1?
â Frank
May 25 '16 at 19:00
 |Â
show 6 more comments
up vote
1
down vote
Another way of finding the /dev/sd
device that corresponds to a disc that has no LABEL nor UUID is to use its serial id. For example, my SSD says
$ sudo hdparm -I /dev/sda
Model Number: KINGSTON SH103S3240G
Serial Number: 50999B9999926F99
And I can find which /dev/sd
device it is by following the link in /dev/disk/by-id/
using the serial id built from this information. Eg
$ ls -l /dev/disk/by-id/ata-KINGSTON_SH103S3240G_50999B9999926F99
lrwxrwxrwx 1 root root 9 Apr 28 17:22 /dev/disk/by-id/ata-KINGSTON_SH103S3240G_50999B9999926F99 -> ../../sda
Usually, we set a UUID on a partition then we can find the device simply with findmnt
. Eg
$ findmnt -n -o source UUID=e7522030-f6e3-472d-8013-3a3316fd15a3
/dev/sda3
Thank you for your nice answer and comment. Here is my udev rule using your serial id suggestion: SUBSYSTEMS=="usb",ATTRSserial=="4C530001041030118021",KERNEL=="sd*", SYMLINK+="usbhd%n". After I restart the udev service using sudo /etc/init.d/udev restart I still cannot find the links /dev/usbhd , /dev/usbhd1 or/dev/usbhd2. May I ask what steps I forgot to do or what mistakes I made?
â Frank
May 25 '16 at 18:31
Did you unplug/replug the device? You might want to addACTION=="add",
and put your file last in the rules (ie rename it 99-...)
â meuh
May 25 '16 at 18:37
@mueh, Thank you for your comment. Do I need to unplug and replug the device after I add ACTION=="add" to the udev rule?
â Frank
May 25 '16 at 18:43
I see from the other answer you have created the links ok. TheACTION=="add",
is for the future, to only create the links when the device is plugged in (added). I'm not sure if you need to create another rule to remove the link when you unplug the device (ACTION=="remove",
).
â meuh
May 25 '16 at 18:48
Thank you for your comments and answer today. Why does not the /dev/usbhd1 , the symbolic link to the first partition, show up in the lsblk -f output? What happens if change the mount point from /home/frank/data1 to /home/frank/data59 corresponding to the symbolic link /dev/usbhd1?
â Frank
May 25 '16 at 19:00
 |Â
show 6 more comments
up vote
1
down vote
up vote
1
down vote
Another way of finding the /dev/sd
device that corresponds to a disc that has no LABEL nor UUID is to use its serial id. For example, my SSD says
$ sudo hdparm -I /dev/sda
Model Number: KINGSTON SH103S3240G
Serial Number: 50999B9999926F99
And I can find which /dev/sd
device it is by following the link in /dev/disk/by-id/
using the serial id built from this information. Eg
$ ls -l /dev/disk/by-id/ata-KINGSTON_SH103S3240G_50999B9999926F99
lrwxrwxrwx 1 root root 9 Apr 28 17:22 /dev/disk/by-id/ata-KINGSTON_SH103S3240G_50999B9999926F99 -> ../../sda
Usually, we set a UUID on a partition then we can find the device simply with findmnt
. Eg
$ findmnt -n -o source UUID=e7522030-f6e3-472d-8013-3a3316fd15a3
/dev/sda3
Another way of finding the /dev/sd
device that corresponds to a disc that has no LABEL nor UUID is to use its serial id. For example, my SSD says
$ sudo hdparm -I /dev/sda
Model Number: KINGSTON SH103S3240G
Serial Number: 50999B9999926F99
And I can find which /dev/sd
device it is by following the link in /dev/disk/by-id/
using the serial id built from this information. Eg
$ ls -l /dev/disk/by-id/ata-KINGSTON_SH103S3240G_50999B9999926F99
lrwxrwxrwx 1 root root 9 Apr 28 17:22 /dev/disk/by-id/ata-KINGSTON_SH103S3240G_50999B9999926F99 -> ../../sda
Usually, we set a UUID on a partition then we can find the device simply with findmnt
. Eg
$ findmnt -n -o source UUID=e7522030-f6e3-472d-8013-3a3316fd15a3
/dev/sda3
answered May 25 '16 at 18:22
meuh
30.3k11752
30.3k11752
Thank you for your nice answer and comment. Here is my udev rule using your serial id suggestion: SUBSYSTEMS=="usb",ATTRSserial=="4C530001041030118021",KERNEL=="sd*", SYMLINK+="usbhd%n". After I restart the udev service using sudo /etc/init.d/udev restart I still cannot find the links /dev/usbhd , /dev/usbhd1 or/dev/usbhd2. May I ask what steps I forgot to do or what mistakes I made?
â Frank
May 25 '16 at 18:31
Did you unplug/replug the device? You might want to addACTION=="add",
and put your file last in the rules (ie rename it 99-...)
â meuh
May 25 '16 at 18:37
@mueh, Thank you for your comment. Do I need to unplug and replug the device after I add ACTION=="add" to the udev rule?
â Frank
May 25 '16 at 18:43
I see from the other answer you have created the links ok. TheACTION=="add",
is for the future, to only create the links when the device is plugged in (added). I'm not sure if you need to create another rule to remove the link when you unplug the device (ACTION=="remove",
).
â meuh
May 25 '16 at 18:48
Thank you for your comments and answer today. Why does not the /dev/usbhd1 , the symbolic link to the first partition, show up in the lsblk -f output? What happens if change the mount point from /home/frank/data1 to /home/frank/data59 corresponding to the symbolic link /dev/usbhd1?
â Frank
May 25 '16 at 19:00
 |Â
show 6 more comments
Thank you for your nice answer and comment. Here is my udev rule using your serial id suggestion: SUBSYSTEMS=="usb",ATTRSserial=="4C530001041030118021",KERNEL=="sd*", SYMLINK+="usbhd%n". After I restart the udev service using sudo /etc/init.d/udev restart I still cannot find the links /dev/usbhd , /dev/usbhd1 or/dev/usbhd2. May I ask what steps I forgot to do or what mistakes I made?
â Frank
May 25 '16 at 18:31
Did you unplug/replug the device? You might want to addACTION=="add",
and put your file last in the rules (ie rename it 99-...)
â meuh
May 25 '16 at 18:37
@mueh, Thank you for your comment. Do I need to unplug and replug the device after I add ACTION=="add" to the udev rule?
â Frank
May 25 '16 at 18:43
I see from the other answer you have created the links ok. TheACTION=="add",
is for the future, to only create the links when the device is plugged in (added). I'm not sure if you need to create another rule to remove the link when you unplug the device (ACTION=="remove",
).
â meuh
May 25 '16 at 18:48
Thank you for your comments and answer today. Why does not the /dev/usbhd1 , the symbolic link to the first partition, show up in the lsblk -f output? What happens if change the mount point from /home/frank/data1 to /home/frank/data59 corresponding to the symbolic link /dev/usbhd1?
â Frank
May 25 '16 at 19:00
Thank you for your nice answer and comment. Here is my udev rule using your serial id suggestion: SUBSYSTEMS=="usb",ATTRSserial=="4C530001041030118021",KERNEL=="sd*", SYMLINK+="usbhd%n". After I restart the udev service using sudo /etc/init.d/udev restart I still cannot find the links /dev/usbhd , /dev/usbhd1 or/dev/usbhd2. May I ask what steps I forgot to do or what mistakes I made?
â Frank
May 25 '16 at 18:31
Thank you for your nice answer and comment. Here is my udev rule using your serial id suggestion: SUBSYSTEMS=="usb",ATTRSserial=="4C530001041030118021",KERNEL=="sd*", SYMLINK+="usbhd%n". After I restart the udev service using sudo /etc/init.d/udev restart I still cannot find the links /dev/usbhd , /dev/usbhd1 or/dev/usbhd2. May I ask what steps I forgot to do or what mistakes I made?
â Frank
May 25 '16 at 18:31
Did you unplug/replug the device? You might want to add
ACTION=="add",
and put your file last in the rules (ie rename it 99-...)â meuh
May 25 '16 at 18:37
Did you unplug/replug the device? You might want to add
ACTION=="add",
and put your file last in the rules (ie rename it 99-...)â meuh
May 25 '16 at 18:37
@mueh, Thank you for your comment. Do I need to unplug and replug the device after I add ACTION=="add" to the udev rule?
â Frank
May 25 '16 at 18:43
@mueh, Thank you for your comment. Do I need to unplug and replug the device after I add ACTION=="add" to the udev rule?
â Frank
May 25 '16 at 18:43
I see from the other answer you have created the links ok. The
ACTION=="add",
is for the future, to only create the links when the device is plugged in (added). I'm not sure if you need to create another rule to remove the link when you unplug the device (ACTION=="remove",
).â meuh
May 25 '16 at 18:48
I see from the other answer you have created the links ok. The
ACTION=="add",
is for the future, to only create the links when the device is plugged in (added). I'm not sure if you need to create another rule to remove the link when you unplug the device (ACTION=="remove",
).â meuh
May 25 '16 at 18:48
Thank you for your comments and answer today. Why does not the /dev/usbhd1 , the symbolic link to the first partition, show up in the lsblk -f output? What happens if change the mount point from /home/frank/data1 to /home/frank/data59 corresponding to the symbolic link /dev/usbhd1?
â Frank
May 25 '16 at 19:00
Thank you for your comments and answer today. Why does not the /dev/usbhd1 , the symbolic link to the first partition, show up in the lsblk -f output? What happens if change the mount point from /home/frank/data1 to /home/frank/data59 corresponding to the symbolic link /dev/usbhd1?
â Frank
May 25 '16 at 19:00
 |Â
show 6 more comments
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f285475%2fis-it-possible-to-make-the-device-filesystem-name-dev-sd1-stay-constant-ev%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Most applications dont care what
/dev/sd?
is used, as it can always be found (egfindmnt
) if you use a disc LABEL or UUID for example. Can you say why you need to fix the device?â meuh
May 25 '16 at 17:50
@meuh, Thank you for your comment. Currently we are looking at how to make usb device filename persist across reboots or unplugging and replugging in the usb for Ubuntu Linux 16.04. When I keep plugging them in and pulling them out from the USB ports and they keep getting names like /dev/sdg1 or /dev/sdi1 . However, the device names are not persistent â whether the BusPirate pops up as /dev/sdg1 or /dev/sdi1 depends on the order in which are the devices discovered by the kernel.
â Frank
May 25 '16 at 18:00