此处描述的步骤将为整个闪存设备提供一个配备 ext2 文件系统的分区。这将使该设备更适合在 Linux 机器之间使用。如果该设备需要在 Linux 和 Windows 机器之间使用,请不要这样做。
![]() | 与以下设备关联的/dev/sda将被重新格式化。其上的任何数据都将被销毁。为了确保您操作的设备是预期的设备,请在开始这些步骤之前从 USB 总线上移除类似的设备。 |
假设闪存被映射到/dev/sda。
在本节中,我们讨论整个闪存设备将专用于单个 ext2 分区的情况。在下面显示的示例步骤中,一个 128MB 的闪存被格式化为 ext2。这就是为什么会出现像 131MB 和 888 柱面这样的数字。所使用的 fdisk 工具只是从设备中读取这些信息。
所有操作均由 root 用户完成。单个分区将在以下位置创建/dev/sda(请注意:不是/dev/sda1)该步骤在一系列带有注释的步骤中描述。fdisk 的标准提示符是命令 (输入 m 获取帮助)并且您可以在任何阶段输入m以查看可用命令。如果您这样做,结果将是
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
|
您的记忆棒必须已插入,但未挂载。请注意写保护已关闭。
开始操作
# fdisk /dev/sda
Command (m for help):d {enter }
Selected partition 1
Command (m for help):n {enter}
Command action
e extended
p primary partition (1-4)
p {enter}
Partition number (1-4):1 {enter}
First cylinder (1-888, default 1): {press enter}
Using default value 1
Last cylinder ... (1-888, default 888): {press enter}
Using default value 888
|
现在是通过打印分区详细信息和表来验证一切是否顺利的好时机。
Command (m for help): p
Disk /dev/sda: 131 MB, 131072000 bytes
9 heads, 32 sectors/track, 888 cylinders
Units = cylinders of 288 * 512 = 147456 bytes
Device Boot Start End Blocks Id System
/dev/sda1 1 888 127856 83 Linux
|
确保分区未设置为可引导。分区表的“Boot”标题下不应有星号。此外,“Id”和“System”标题应与上面打印输出中显示的相同。这表明您可以将设备格式化为 ext2(下一节)。这些是默认设置。如果不是,可以通过以下方式更改
Command (m for help): a [toggle a bootable flag]
Command (m for help): t [change a partition's system id]
|
如果(或当)分区表正确时,您可以使用以下命令结束该步骤
Command (m for help): w [write table to disk and exit]
|
就是这样!