Macで日常的にお仕事しているのは、ChromeブラウザとiTermとVSCodeが多いので、USBメモリを取り出すためにFinderを起動するのもめんどくさい。
iTermでコマンド入力してUSBメモリを取り出せると嬉しいのです。
で、「mac usb 取り出し コマンド」みたいな感じでぐぐってみると
MacではUSBメモリのアイコンを選択した状態で「Commandキー+E」を押下すると、USBメモリを安全に取り外すことができます。
と教えてくれます。
そのアイコンをマウスで選択するのがめんどくさいんですけど。
「mac usb eject cli」でぐぐると見つかりました。
diskutilコマンドを使えばいいみたいです。
コマンドがわかったら、とりあえずそこのコマンドを動かしてみます。
% diskutil Disk Utility Tool Utility to manage local disks and volumes Most commands require an administrator or root user WARNING: Most destructive operations are not prompted Usage: diskutil [quiet] <verb> <options>, where <verb> is as follows: list (List the partitions of a disk) info[rmation] (Get information on a specific disk or partition) listFilesystems (List file systems available for formatting) listClients (List all current disk management clients) activity (Continuous log of system-wide disk arbitration) u[n]mount (Unmount a single volume) unmountDisk (Unmount an entire disk (all volumes)) eject (Eject a disk) mount (Mount a single volume) mountDisk (Mount an entire disk (all mountable volumes)) enableJournal (Enable HFS+ journaling on a mounted HFS+ volume) disableJournal (Disable HFS+ journaling on a mounted HFS+ volume) moveJournal (Move the HFS+ journal onto another volume) enableOwnership (Exact on-disk User/Group IDs on a mounted volume) disableOwnership (Ignore on-disk User/Group IDs on a mounted volume) rename[Volume] (Rename a volume) verifyVolume (Verify the file system data structures of a volume) repairVolume (Repair the file system data structures of a volume) verifyDisk (Verify the components of a partition map of a disk) repairDisk (Repair the components of a partition map of a disk) resetFusion (Reset the components of a machine's Fusion Drive) eraseDisk (Erase an existing disk, removing all volumes) eraseVolume (Erase an existing volume) reformat (Erase an existing volume with same name and type) eraseOptical (Erase optical media (CD/RW, DVD/RW, etc.)) zeroDisk (Erase a disk, writing zeros to the media) randomDisk (Erase a disk, writing random data to the media) secureErase (Securely erase a disk or freespace on a volume) partitionDisk ((re)Partition a disk, removing all volumes) addPartition (Create a new partition to occupy free space) splitPartition (Split an existing partition into two or more) mergePartitions (Combine two or more existing partitions into one) resizeVolume (Resize a volume, increasing or decreasing its size) appleRAID <verb> (Perform additional verbs related to AppleRAID) coreStorage <verb> (Perform additional verbs related to CoreStorage) apfs <verb> (Perform additional verbs related to APFS) image <verb> (Perform additional verbs related to DiskImage) diskutil <verb> with no options will provide help on that verb
いろんなことができるみたいですね!
とりあえず list を使ってみます。
% diskutil list /dev/disk0 (internal, physical): #: TYPE NAME SIZE IDENTIFIER 0: GUID_partition_scheme *1.0 TB disk0 1: EFI EFI 209.7 MB disk0s1 2: Apple_APFS Container disk2 1000.0 GB disk0s2 /dev/disk1 (internal, physical): #: TYPE NAME SIZE IDENTIFIER 0: GUID_partition_scheme *28.0 GB disk1 1: EFI EFI 314.6 MB disk1s1 2: Apple_APFS Container disk2 27.6 GB disk1s2 /dev/disk2 (synthesized): #: TYPE NAME SIZE IDENTIFIER 0: APFS Container Scheme - +1.0 TB disk2 Physical Stores disk0s2, disk1s2 1: APFS Volume MacintoshHD2 1.1 MB disk2s1 2: APFS Volume Preboot 2.1 GB disk2s2 3: APFS Volume Recovery 1.2 GB disk2s3 4: APFS Volume VM 13.0 GB disk2s4 5: APFS Volume Macintosh HD - Data 754.2 GB disk2s5 6: APFS Volume Macintosh HD 10.1 GB disk2s6 7: APFS Snapshot com.apple.os.update-... 10.1 GB disk2s6s1 /dev/disk3 (external, physical): #: TYPE NAME SIZE IDENTIFIER 0: GUID_partition_scheme *3.0 TB disk3 1: EFI EFI 209.7 MB disk3s1 2: Apple_APFS Container disk4 3.0 TB disk3s2 /dev/disk4 (synthesized): #: TYPE NAME SIZE IDENTIFIER 0: APFS Container Scheme - +3.0 TB disk4 Physical Store disk3s2 1: APFS Volume TimeMachine 2.8 TB disk4s2 /dev/disk5 (disk image): #: TYPE NAME SIZE IDENTIFIER 0: GUID_partition_scheme +172.9 MB disk5 1: Apple_APFS Container disk6 172.8 MB disk5s1 /dev/disk6 (synthesized): #: TYPE NAME SIZE IDENTIFIER 0: APFS Container Scheme - +172.8 MB disk6 Physical Store disk5s1 1: APFS Volume VirtualBox 139.5 MB disk6s1 /dev/disk7 (external, physical): #: TYPE NAME SIZE IDENTIFIER 0: FDisk_partition_scheme *123.7 GB disk7 1: DOS_FAT_32 123.7 GB disk7s1
disk7がUSBメモリですね。
% diskutil eject /dev/disk7 Disk /dev/disk7 ejected
iTermからのコマンドでUSBメモリを取り出せました。