在终端使用Mac diskutil 命令格式化顽固U盘

经常遇到某些U盘合并不了分区、格式化不了、windows 下识别不了、空间“丢失”等情况,使用Mac 系统自带的图形化磁盘工具也解决不了问题,在终端下能轻松搞定,这里记录一下过程。

Mac diskutil

diskutil list 查看硬盘:

$diskutil list
/dev/disk2 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *3.9 GB     disk2
   1:             Windows_FAT_16                         3.1 GB     disk2s1

格式化为 FAT32 格式

$ sudo diskutil eraseDisk FAT32 MYUSB MBRFormat /dev/disk2
Started erase on disk2
Unmounting disk
Creating the partition map
Waiting for partitions to activate
Formatting disk2s1 as MS-DOS (FAT32) with name MYUSB
512 bytes per physical sector
/dev/rdisk2s1: 7634336 sectors in 954292 FAT32 clusters (4096 bytes/cluster)
bps=512 spc=8 res=32 nft=2 mid=0xf8 spt=32 hds=255 hid=2048 drv=0x80 bsec=7649280 bspf=7456 rdcl=2 infs=1 bkbs=6
Mounting disk
Finished erase on disk2


diskutil partitionDisk /dev/disk2 1 MBRFormat "MS-DOS FAT32" MYUSB 3.9G

其中 MYUSB 是自定义的U盘名,不能包含小写字母,否则会出错:

myUsb does not appear to be a valid volume name for its file system

可以通过 diskutil listFilesystems 查看支持的格式

$ diskutil listFilesystems
Formattable file systems

These file system personalities can be used for erasing and partitioning.
When specifying a personality as a parameter to a verb, case is not considered.
Certain common aliases (also case-insensitive) are listed below as well.

PERSONALITY                     USER VISIBLE NAME                               
Case-sensitive APFS             APFS (Case-sensitive)                           
  (or) APFSX
APFS                            APFS                                            
  (or) APFSI
ExFAT                           ExFAT                                           
MS-DOS                          MS-DOS (FAT)                                    
MS-DOS FAT12                    MS-DOS (FAT12)                                  
MS-DOS FAT16                    MS-DOS (FAT16)                                  
MS-DOS FAT32                    MS-DOS (FAT32)                                  
  (or) FAT32
HFS+                            Mac OS Extended                                 
Case-sensitive HFS+             Mac OS Extended (Case-sensitive)                
  (or) HFSX
Case-sensitive Journaled HFS+   Mac OS Extended (Case-sensitive, Journaled)     
  (or) JHFSX
Journaled HFS+                  Mac OS Extended (Journaled)                     
  (or) JHFS+
Free Space                      可用空间                                    
  (or) FREE


$ diskutil list
/dev/disk2 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *3.9 GB     disk2
   1:                 DOS_FAT_32 MYUSB                   3.9 GB     disk2s1


$ diskutil eject /dev/disk2


diskutil eraseDisk JHFS+ iDisk disk2


  • JHFS+为格式名称,代表Mac OS X扩展(日志式)
  • iDisk 为格式化U盘后分区的名称,可以修改
  • disk2 为U盘名称,这里请替换直接的U盘代号



本文标签: U盘 Mac diskutil 格式化 顽固
本文网址: (转载注明出处)
如果你有任何建议或疑问可以在下面 留言