/dev/disk/by-id cleanup

The place to post if you need help or advice

Moderators: ChriThor, LXF moderators

/dev/disk/by-id cleanup

Postby indijanc » Wed Apr 04, 2012 3:03 pm

Is there any way to clean up stale devices/symlinks in the /dev/disk/by-id folder?

I have a SLES 11.1 with a SAN connected disk array. I'm using a program for disk replication and presenting the disks to the server. The program also enables the disks and creates a volume group on top. When it finishes it cleans up after itself (remove vg, unpresent etc.). After a few days of running it, the /dev/disk/by-id folder holds a large number of files (mostly softlinks to lvm devices). Is there any way to clean/remove these? So far only reboot helps :)
Posts: 2
Joined: Wed Apr 04, 2012 2:49 pm

Postby nelz » Thu Apr 05, 2012 12:54 am

Do you mean that the directory is full of links that point nowhere? If so, this command will remove them.

Code: Select all
find -L /dev/disk/by-id -type l -exec rm "{}" +

The -L options makes find follow symbolic links and use information fro the file linked to rather than the link itself, so the only links it sees as links (-type l) are broken ones (or links that point to an unreadable file, but that won't happen if you run this as root).
"Insanity: doing the same thing over and over again and expecting different results." (Albert Einstein)
User avatar
Site admin
Posts: 8999
Joined: Mon Apr 04, 2005 11:52 am
Location: Warrington, UK

Postby indijanc » Thu Apr 05, 2012 7:42 am

Thank you nelz, that does clean up the stale links.

I'd rather use a udev cleanup command or something similar though, since udev creates these links and takes care of them if I'm not mistaken. Is there any udev (or something similar) cleanup mode/command to take care of this? So far I haven't found any clues on "proper" removal of these stale softlinks.

Thanks for the help :)
Posts: 2
Joined: Wed Apr 04, 2012 2:49 pm

Postby ferrari » Tue Apr 10, 2012 3:41 am

I'm surprised you had stale links, because AFAIU, udev creates/deletes these dynamically (via kernel uevents) as any disks are detected or removed, but maybe your disk replication app is responsible for this behaviour?
LXF regular
Posts: 174
Joined: Tue May 03, 2005 11:09 am

Return to Help!

Who is online

Users browsing this forum: No registered users and 1 guest