我正在尝试自动格式化 USB 驱动器。我所做的是:
- 卸载 USB 驱动器
- 终端:sudo parted /dev/sdb1 mktable msdos
这时我收到以下错误:
Error: Partition(s) 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, 30, 31, 32, 33, 34, 35, 36, 37,
38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
58, 59, 60, 61, 62, 63, 64 on /dev/sdb1 have been written, but we have been
unable to inform the kernel of the change, probably because it/they are in use.
As a result, the old partition(s) will remain in use. You should reboot now
before making further changes.
当我在 GParted 中的同一个 USB 记忆棒上创建分区表时,我无需重新启动!
我需要在终端中输入什么才能不用重启?我的意思是 GParted 只是 parted 的 GUI,对吧?
答案1
首先,您似乎正在尝试在分区上
/dev/sdb1
而不是在磁盘本身上创建分区表
/dev/sdb
我猜测这可能会导致一些奇怪的错误...您真的想在 USB 驱动器上创建 64 个分区吗,或者这可能是一个奇怪的错误。
整理分区表后,我认为这些命令应该有效:
创建 MBR(msdos)分区表
sudo parted /dev/sdb mktable msdos
创建一个分区(主分区,FS ID 为 ext3,从 1MB 开始并使用 100% 的空间)(如果从 0% 或 0MB 开始,则它与 MB 不对齐并且会发出抱怨):
sudo parted /dev/sdb mkpart primary ext3 1 100%
显然,在格式化新分区或现有分区时
gparted
会执行此操作,以避免旧文件系统签名出现问题。因此也可以这样做:wipefs
sudo wipefs -a /dev/sdb1
然后在刚刚创建的第一个分区(sdb1)上创建文件系统(
-L
标签是可选的,请参阅 mkfs.ext3/mke2fs 手册页以了解许多选项):sudo mkfs.ext3 -L "NewLabel" /dev/sdb1
这是内置的帮助parted <dummydevicefile> help mkpart
(似乎比 man/info 页面更详细):
mkpart PART-TYPE [FS-TYPE] START END make a partition
PART-TYPE is one of: primary, logical, extended
FS-TYPE is one of: zfs, btrfs, ext4, ext3, ext2, fat32, fat16, hfsx,
hfs+, hfs, jfs, swsusp, linux-swap(v1), linux-swap(v0), ntfs, reiserfs,
freebsd-ufs, hp-ufs, sun-ufs, xfs, apfs2, apfs1, asfs, amufs5, amufs4,
amufs3, amufs2, amufs1, amufs0, amufs, affs7, affs6, affs5, affs4,
affs3, affs2, affs1, affs0, linux-swap, linux-swap(new),
linux-swap(old)
START and END are disk locations, such as 4GB or 10%. Negative values
count from the end of the disk. For example, -1s specifies exactly the
last sector.
'mkpart' makes a partition without creating a new file system on the
partition. FS-TYPE may be specified to set an appropriate partition
ID.