微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > 学习 Linux,101: 建设分区和文件系统

学习 Linux,101: 建设分区和文件系统

时间:09-12 来源:互联网 点击:

on

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)

Command (m for help):

运用 p 命令来显示这个特定硬盘上的现有分区,清单 5 显示输出。

清单 5. 显示现有分区表

Command (m for help): p

Disk /dev/sda: 1000.2 GB, 1000204886016 bytes

255 heads, 63 sectors/track, 121601 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Disk identifier: 0x000de20f

Device Boot   Start     End   Blocks  Id System

/dev/sda1  *      1    9111  73184076  7 HPFS/NTFS

/dev/sda2      9634    9730   779152+ 83 Linux

/dev/sda3      9731   116679  859067842+  5 Extended

/dev/sda5      9731    20917  89859546  83 Linux

/dev/sda6      20918    39644  150424596  83 Linux

/dev/sda7      39645    53905  114551451  83 Linux

Command (m for help):

这个特殊硬盘是一个 1TB 硬盘,包含一个略低于 80GB 的 Windows/xp 分区。它是一个主分区,标志为 bootable,这是 Windows 系统的典型特征。

添加分区

如今我们运用局部闲置空间来添加一些分区。

我们将创立一个交流分区:/dev/sda4。这将是一个主分区,填充 /dev/sda1 的完毕柱面和 /dev/sda2 的起始柱面之间的 521 个柱面空隙。您不用对招致这个空隙的奇异原由感到猎奇;我只是为了撰写本文而创立这个空隙。

我们将创立一个 40GB 的逻辑分区:/dev/sda8。

结尾,我们将创立一个 2000MB 的小型逻辑分区,以便在 Linux 和 Windows 系统之间共享数据。这个分区结尾将格式化为 FAT32(或 vfat)。这个分区将命名为 /dev/sda9。

创立我们的分区

我们最先运用 n 命令来创立一个新分区,如清单 6 所示。

清单 6. 创立第一个分区

Command (m for help): n

Command action

l  logical (5 or over)

p  primary partition (1-4)

p

Selected partition 4

First cylinder (9112-121601, default 9112):

Using default value 9112

Last cylinder, +cylinders or +size{K,M,G} (9112-9633, default 9633): +521

Command (m for help): p

Disk /dev/sda: 1000.2 GB, 1000204886016 bytes

255 heads, 63 sectors/track, 121601 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Disk identifier: 0x000de20f

Device Boot   Start     End   Blocks  Id System

/dev/sda1  *      1    9111  73184076  7 HPFS/NTFS

/dev/sda2      9634    9730   779152+ 83 Linux

/dev/sda3      9731   116679  859067842+  5 Extended

/dev/sda4      9112    9633   4192965  83 Linux

/dev/sda5      9731    20917  89859546  83 Linux

/dev/sda6      20918    39644  150424596  83 Linux

/dev/sda7      39645    53905  114551451  83 Linux

Partition table entries are not in disk order

Command (m for help):

我们采用默许值作为第一个柱面并指定值 +521 作为柱面的数目。清单 6 显示,我们的分区大小约为 4GB。由于它是一个主分区,因而它的编号必需为 1 至 4。顺序指定分区编号是个好主意;否则一些工具会报告错误,fdisk 将劝诫我们:我们的分区表条目不再按硬盘顺序陈列。

还要留意一点:我们的新分区类型被指定为 83,标明这是一个 Linux 数据分区。能够将这个数字视为分区预定用途的操作系统的指示符。分区的结尾用途应该婚配这个配置,但这时我们的分区甚至还没有格式化,更谈不上有限据了。我们将最先创立其他分区,然后引见如何修改分区类型。

您能够曾经留意到,当我们输进 n 子命令创立一个新分区时,唯一的挑选是 “l”(示意逻辑分区)和 “p”(示意主分区)。您只好看到剩余的能够分区类型的选项。假设驱动器还没有扩展分区,您将看到选项 “e”(示意扩展分区)。还要留意,我们的扩展分区(/dev/sda3)为类型 5。

如今我们来定义 40GB Linux 分区和 2000MB FAT32 分区。这次我们只需指定大小 +40G 和 +2000M,辨别示意 40GB 和 2000MB。后果如清单 7 所示。

清单 7. 创立数据分区

Command (m for help): n

First cylinder (53906-116679, default 53906):

Using default value 53906

Last cylinder, +cylinders or +size{K,M,G} (53906-116679, default 116679): +40G

Command (m for help): n

First cylinder (59129-116679, default 59129):

Using default value 59129

Last cylinder, +cylinders or +size{K,M,G} (59129-116679, default 116679): +2000M

Command (m for help): p

Disk /dev/sda: 1000.2 GB, 1000204886016 bytes

255 heads, 63 sectors/track, 121601 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Diskid

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top