「记录」在 Deepin 下使用命令行将 U盘 格式化为 exFAT 格式

原创

本文最后更新于 <span id="expire-date"></span> 天前,文中部分描述可能已经过时。

之前装系统的时候U盘被格式化成 ext4 系统,为方便兼容大部分操作系统上读取使用,需要重新格回去。

安装 exFAT 支持

sudo apt-get install exfat-utils exfat-fuse

找到设备路径

sudo fdisk -l

Disk /dev/sda: 28.7 GiB, 30765219840 bytes, 60088320 sectors
Disk model: SanDisk 3.2Gen1
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
略...

确认这块 U盘 对应的路径是 /dev/sda

进行分区

sudo gdisk /dev/sda

o 命令表示创建 GPT 分区表。

n 命令表示新建一个分区。
文件系统的类型要设成0700,代表 exFAT。

w 命令表示写入所有变更。

GPT fdisk (gdisk) version 1.0.3

Partition table scan:
MBR: not present
BSD: not present
APM: not present
GPT: not present

Creating new GPT entries.

Command (? for help): o
This option deletes all partitions and creates a new protective MBR.
Proceed? (Y/N): y

Command (? for help): n
Partition number (1-128, default 1):
First sector (34-60088286, default = 2048) or {+-}size{KMGTP}:
Last sector (2048-60088286, default = 60088286) or {+-}size{KMGTP}:
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): 0700
Changed type of partition to 'Microsoft basic data'

Command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to /dev/sda.
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot or after you
run partprobe(8) or kpartx(8)
The operation has completed successfully.

重新查看设备路径

sudo fdisk -l

The primary GPT table is corrupt, but the backup appears OK, so that will be used.
Disk /dev/sda: 28.7 GiB, 30765219840 bytes, 60088320 sectors
Disk model: SanDisk 3.2Gen1
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 一串序列号

Device Start End Sectors Size Type
/dev/sda1 2048 60088286 60086239 28.7G Microsoft basic data

可以看到多出一个 /dev/sda1 分区。

确认进行格式化

sudo mkfs.exfat /dev/sda1

出现报错:

mkexfatfs 1.3.0
ERROR: failed to open '/dev/sda1' in read-write mode: No such file or directory.

经查,需要先卸载。

sudo umount /dev/sda1

又报错:

umount: /dev/sda1: no mount point specified.

去掉 1 试试

sudo umount /dev/sda

行,没报错,看样子可以进行下一步了。

以防万一再做一步确认。

sudo fdisk -l

The primary GPT table is corrupt, but the backup appears OK, so that will be used.
Disk /dev/sda: 28.7 GiB, 30765219840 bytes, 60088320 sectors
Disk model: SanDisk 3.2Gen1
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 一串序列号

Device Start End Sectors Size Type
/dev/sda1 2048 60088286 60086239 28.7G Microsoft basic data

确认建立 exFAT 文件系统。

sudo mkfs.exfat /dev/sda1

还是报错 ERROR: failed to open '/dev/sda1' in read-write mode: No such file or directory.

那就去掉 1

$ sudo mkfs.exfat /dev/sda 
mkexfatfs 1.3.0
Creating... done.
Flushing... done.
File system created successfully.

参考

  1. exFAT 文件系统指南 - 阮一峰的网络日志
  2. How to force format a USB device? - Ubuntu Forums

本文作者:青菜芋子

本文链接: https://loafing.cn/posts/Format-the-U-disk-to-exFAT-format-in-Deepin.html

文章默认采用 CC BY-NC-SA 4.0 许可协议,如有转载请注意遵循。

评论

您所在的地区可能无法访问 Disqus 评论系统,请切换网络环境再尝试。