Linux Format forums Forum Index Linux Format forums
Help, discussion, magazine feedback and more
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

/dev/disk/by-id cleanup

 
Post new topic   Reply to topic    Linux Format forums Forum Index -> Help!
View previous topic :: View next topic  
Author Message
indijanc



Joined: Wed Apr 04, 2012 3:49 pm
Posts: 2

PostPosted: Wed Apr 04, 2012 4:03 pm    Post subject: /dev/disk/by-id cleanup Reply with quote

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 Smile
Back to top
View user's profile Send private message
nelz
Site admin


Joined: Mon Apr 04, 2005 12:52 pm
Posts: 8439
Location: Warrington, UK

PostPosted: Thu Apr 05, 2012 1:54 am    Post subject: Reply with quote

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

Code:
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)
Back to top
View user's profile Send private message
indijanc



Joined: Wed Apr 04, 2012 3:49 pm
Posts: 2

PostPosted: Thu Apr 05, 2012 8:42 am    Post subject: Reply with quote

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 Smile
Back to top
View user's profile Send private message
ferrari
LXF regular


Joined: Tue May 03, 2005 12:09 pm
Posts: 127

PostPosted: Tue Apr 10, 2012 4:41 am    Post subject: Reply with quote

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?
Back to top
View user's profile Send private message
View previous topic :: View next topic  
Display posts from previous:   
Post new topic   Reply to topic    Linux Format forums Forum Index -> Help! All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Linux Format forums topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group


Copyright 2011 Future Publishing, all rights reserved.


Web hosting by UKFast