[英]How to Unmount all usb pen drive from ubuntu with bash script or terminal?
I want to unmount all pen drive from ubuntu os through a bash script or from a terminal. 我想通过bash脚本或终端从ubuntu操作系统卸载所有笔式驱动器。 I knew the command umount /media/MEDIA_NAME, but here we need to specify each MEDIA_NAME.
我知道命令umount / media / MEDIA_NAME,但在这里我们需要指定每个MEDIA_NAME。 Can I use a single command to unmount from terminal or bash script.
我可以使用单个命令从终端或bash脚本中卸载。 Please help me.
请帮我。
Browsing entries in /dev/disk/by-id/ allows you to select USB disks: 浏览/ dev / disk / by-id /中的条目允许您选择USB磁盘:
for usb_dev in /dev/disk/by-id/usb-*; do
dev=$(readlink -f $usb_dev)
grep -q ^$dev /proc/mounts && umount $dev
done
Loop for each device in the /media directory. 循环访问/ media目录中的每个设备。
for device in /media/*
do
umount $device
done
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.