天天看点

diskutil命令diskutil命令

diskutil命令

目录

diskutil命令

主要命令:

mountDisk挂载盘

eject弹出

查看支持的文件系统

查看挂载设备信息

格式化

APFS格式(GPT分区 )

FAT32格式(MBR分区)

卷重命名 

主要命令:

  1. mountDisk:挂载盘
  2. eject:弹出
  3. list:查看挂载设备信息
  4. listFileSystems:查看支持的文件系统
  5. eraseDisk:擦除盘
  6. eraseVolume:擦除卷

mountDisk挂载盘

命令:

diskutil mountDisk disk3
           

运行结果:

Volume(s) mounted successfully
           

eject弹出

命令:

diskutil eject disk3
           

运行结果:

Disk disk3 ejected
           

查看支持的文件系统

命令:

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/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         799.0 GB   disk0s2
   3:       Microsoft Basic Data BOOTCAMP                201.0 GB   disk0s3

/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.7 GB    disk1s2

/dev/disk2 (synthesized):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      APFS Container Scheme -                      +826.7 GB   disk2
                                 Physical Stores disk1s2, disk0s2
   1:                APFS Volume Macintosh HD - 数据     314.6 GB   disk2s1
   2:                APFS Volume Preboot                 83.0 MB    disk2s2
   3:                APFS Volume Recovery                528.9 MB   disk2s3
   4:                APFS Volume VM                      2.1 GB     disk2s4
   5:                APFS Volume Macintosh HD            11.1 GB    disk2s5

/dev/disk3 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *1.0 TB     disk3
   1:                 DOS_FAT_32 USB1T                   1.0 TB     disk3s1
           

格式化

APFS格式(GPT分区 )

命令:

diskutil eraseDisk APFSX USB1T GPT disk3
           

说明:

APFSX:文件系统(APFS Case-sensitive:APFS大小写敏感的文件系统)

USB1T:分区命名

GPT:分区格式(苹果分区格式) 

运行结果:

Started erase on disk3
Unmounting disk
Creating the partition map
Waiting for partitions to activate
Formatting disk3s2 as APFS (Case-sensitive) with name USB1T
Mounting disk
Finished erase on disk3
           

查看分区信息:

diskutil list
           
/dev/disk3 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *1.0 TB     disk3
   1:                        EFI EFI                     209.7 MB   disk3s1
   2:                 Apple_APFS Container disk4         1000.0 GB  disk3s2

/dev/disk4 (synthesized):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      APFS Container Scheme -                      +1000.0 GB  disk4
                                 Physical Store disk3s2
   1:                APFS Volume USB1T                   1.1 MB     disk4s1
           

GPT分区格式将disk3分为2个卷:

1: EFI

2:Apple_APFS容器(名称:disk4)

FAT32格式(MBR分区)

命令:

diskutil eraseDisk FAT32 USB1T MBR disk3
           

说明:

FAT32:文件系统

USB1T:分区命名

MBR:分区格式(主引导记录格式) 

 运行结果:

Started erase on disk3
Unmounting disk
Creating the partition map
Waiting for partitions to activate
Formatting disk3s1 as MS-DOS (FAT32) with name USB1T
512 bytes per physical sector
/dev/rdisk3s1: 1953044800 sectors in 30516325 FAT32 clusters (32768 bytes/cluster)
bps=512 spc=64 res=32 nft=2 mid=0xf8 spt=32 hds=255 hid=2048 drv=0x80 bsec=1953521664 bspf=238409 rdcl=2 infs=1 bkbs=6
Mounting disk
Finished erase on disk3
           

查看分区信息:

diskutil list
           
...

/dev/disk3 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *1.0 TB     disk3
   1:                 DOS_FAT_32 USB1T                   1.0 TB     disk3s1
           

卷重命名 

命令:

diskutil rename USB1T USBDATA
           

运行结果:

Volume on disk3s1 renamed to USBDATA
           

查看分区信息:

/dev/disk3 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *1.0 TB     disk3
   1:                 DOS_FAT_32 USBDATA                 1.0 TB     disk3s1
           

继续阅读