首页 > 代码库 > Linux: How to delete a disk or LUN reference from /dev
Linux: How to delete a disk or LUN reference from /dev
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
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。