您的位置:首页 > 运维架构 > Shell

shell safely remove USB flash disk

2013-10-16 17:21 375 查看
Linux (Ubuntu): safely remove USB flash disk via command line
http://stackoverflow.com/questions/13224509/linux-ubuntu-safely-remove-usb-flash-disk-via-command-line
You can do this using udisks. it is not installed by default but easy enough to install (the package is like a meg in size once installed)...

sudo apt-get install udisks
Once installed you can detach a USB drive with the following commands...

sudo udisks --unmount /dev/sdb1
sudo udisks --detach /dev/sdb
The first line unmounts it. Just like any other partition you can still remount it at this point. The second line detaches it. After this it is powered down and you have to remove/reinsert it to remount.

To clarify sdb is the device and sdb1/2/3/etc are partitions on the device. Also, you will need to unmount all mount points before you attempt to detach the device. Usually with a USB stick/drive there is only one but it is a warning you should know about none the less.

Getting the device name from the mount point would require you pull it from mount or something.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: