码迷,mamicode.com
首页 > 系统相关 > 详细

Linux: How to delete a disk or LUN reference from /dev

时间:2014-10-27 09:18:30      阅读:188      评论:0      收藏:0      [点我收藏+]

标签:io   os   for   sp   div   on   cti   amp   bs   

In AIX, there is rmdev command to remove a disk/LUN from /dev directory i.e to make the disk/LUN unavailable to the whole OS before physically removing it.
 
But in Linux, there‘s no specific command to the same. Here‘s how you will actually do it:
 
 
Make sure that the disk is not being used by the application, does not contain a mounted file system or an active volume group.
 
1. Take the disk offline:
 
cd /sys/block/sdb/device
echo “offline” >state
 
2. Delete from /dev
 
echo 1 >delete
 
You can make your own script with the name rmdev ;)
 
#!/bin/ksh
 
dev=$1
 
[[ ! -d "$dev" ]] && echo "$dev does not exist" && exit 1
 
echo "offline" >/sys/block/"$dev"/device/state
echo 1 >/sys/block/"$dev"/device/delete

Linux: How to delete a disk or LUN reference from /dev

标签:io   os   for   sp   div   on   cti   amp   bs   

原文地址:http://www.cnblogs.com/jackydalong/p/4053411.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!