Opengist

Explore

  • All gists
  • Topics
  • Users
Give feedback on the new UI Powered by Opengist ⋅ 15ms

user:thomas gists created by user

title:mygist gists with given title

description:sync gists with given description

filename:myfile.txt gists having files with given name

extension:yml gists having files with given extension

language:go gists having files with given language

topic:homelab gists with given topic

all:systemctl search all fields

Login
u

unmount

Recently created Least recently created Recently updated Least recently updated

timmy / 卸載與彈出外接 USB 裝置腳本

Last active 7 hours ago ShellScript USB diskutil eject unmount

此腳本可自動尋找、卸載並彈出所有外接 USB 裝置,確保安全移除磁碟並避免資料損毀。

0 0 0 1
1 #!/bin/bash
2 # Script to unmount and eject all external USB drives
3
4 # 找到所有外接裝置並處理
5 diskutil list | grep "external, physical" | awk '{print $1}' | while read -r disk; do
6 echo "Unmounting all volumes on $disk..."
7 diskutil unmountDisk "$disk"
8 echo "Ejecting $disk..."
9 diskutil eject "$disk"
10 done