经常遇到某些U盘合并不了分区、格式化不了、windows 下识别不了、空间“丢失”等情况,使用Mac 系统自带的图形化磁盘工具也解决不了问题,在终端下能轻松搞定,这里记录一下过程。
用 diskutil list
查看硬盘:
1
2
3
4
5
$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
格式
1
2
3
4
5
6
7
8
9
10
11
12
$ sudo diskutil eraseDisk FAT32 MYUSB MBRFormat /dev/disk2
Password:
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
如果上面的命令失败,可尝试下面的命令,需要指定大小
1
diskutil partitionDisk /dev/disk2 1 MBRFormat "MS-DOS FAT32" MYUSB 3.9G
其中 MYUSB
是自定义的U盘名,不能包含小写字母,否则会出错:
1
myUsb does not appear to be a valid volume name for its file system
可以通过 diskutil listFilesystems
查看支持的格式
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
$ 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
格式化后再查看磁盘情况
1
2
3
4
5
$ 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
推出U盘
1
$ diskutil eject /dev/disk2
把U盘分区
1
diskutil eraseDisk JHFS+ iDisk disk2
解释
- JHFS+为格式名称,代表Mac OS X扩展(日志式)
- iDisk 为格式化U盘后分区的名称,可以修改
- disk2 为U盘名称,这里请替换直接的U盘代号
然后到图形界面点分区
-+
,然后拖动,如
本文网址: https://pylist.com/topic/197.html 转摘请注明来源