0

Could somebody assist me in creating a persistent symlink for the block devices, using udev ?

I have a cloud server, where I can attach a separate device (/dev/xvdb) as a storage.

I want to create a persistent symlink (/dev/test_link) which should always target to /dev/xvdb storage.

Regards,

Imrank
  • 51
  • Are you just looking to have the device mounted in the same place every time you connect it to your system? Maybe try giving the USB device a permanent mount point on the system. USB Drives can change their designation between reboots on the system. See https://askubuntu.com/a/940060/231142 – Terrance Dec 14 '18 at 19:36
  • yes, but I would like to achieve it using udev and its just for a one-time testing so that I can understand how symlink works persistently using udev rules. – Imrank Dec 14 '18 at 20:38
  • Ah, OK. This might help: https://askubuntu.com/questions/783357/create-a-symlink-in-dev-using-etc-udev-rules – Terrance Dec 14 '18 at 20:46
  • nope, it didn't help. I used the given post: https://askubuntu.com/questions/783357/create-a-symlink-in-dev-using-etc-udev-rules and https://hackaday.com/2009/09/18/how-to-write-udev-rules/#comments created a rule file with the below settings and still unable to find that symlink created. file: /etc/udev/rules.d/81-drive.rules which has below attributes KERNEL=="xvdb1", SUBSYSTEM=="block", ATTR{size}=="4192256", SYMLINK+="/dev/prod_data" – Imrank Dec 14 '18 at 22:30
  • The examples in the posts are of the usb devices, however I am using a virtual block device which is /dev/xvdb1.. would this change something? – Imrank Dec 14 '18 at 22:33
  • According to https://en.wikipedia.org/wiki/Udev udev runs with the Linux Kernel. Hardware is controlled by the Linux Kernel, but virtual drives would be controlled by drivers. So, I don't think that it would be possible for udev to detect if the virtual drive existed or not. – Terrance Dec 14 '18 at 22:46

0 Answers0