导航:首页 > 编程系统 > linux创建分区表

linux创建分区表

发布时间:2023-06-04 11:47:46

linux 分区新建,格式化、挂载

Linux系统有一个理念:“一切皆文件”,所以计算机的硬件在linux中也是以“文件”的形式存在于/dev目录中。

比如,光驱对应的文件是/dev/cdrom,CPU对应的文件是/dev/cpu。而硬盘对应的是/dev/sd*。第一块硬盘是/dev/sda,第二块磁盘是/dev/sdb。

IDE磁盘的设备文件采用/dev/hdx 来命名,分区则采用/dev/hdxy来命名,其中想表示磁盘(a是第一块磁盘,b是第二块磁盘,以此类推),与代表分区的号码(由1开始,1,2,3,以此类推)

SCSI设备和分区采用/dev/sdx和/dev/sdxy来命名(x和y的命名规则与IED磁盘命名规则一样)。

A、对IED接口

第一主盘:hda第一从盘:hdb 第一从盘第一分区:hdb1

B、对SCSI接口

第一主盘:sda 第一从盘:sdb 第一从盘第一分区:sdb1

但是一个磁盘通常又被分成多个分区,所以在磁盘文件的后面加上分区的序号来对应这个分区。参考下面的表格中的例子。

Linux磁盘分区与文件系统类常用命令

介绍2种分区表:

所支持的最大卷:2T (T; terabytes,1TB=1024GB)
对分区的设限:最多4个主分区或3个主分区加一个扩展分区。

MBR分区的原理:

MBR:主引导扇区

主分区表:64bytes,最多只能分四个主分区,每个主分区的记录(相关信息,比如分区大小,位置)在主分区表里占14bytes。

如 果要建多于四个的分区,就要拿出一个主分区做为扩展分区,再在扩展分区里面进行其它的分区操作。在 建扩展分区的时候会建立一张对应的扩展分区表,它记录了在这个扩展分区里的分区的相关信息;理论上它没有分区数量的限制,在扩展分区内部的分区叫做逻辑分 区,如上图中的 /dev/hda5,/dev/hda6/,/dev/hda7

格式化原理:

在 分好区后,分区里面是空的,没有任何东西。为了能让OS识别,就必须要向分区里写入相应格式的数据。

比如windows的 FAT32,NTFS,Linux的ext2,ext3,ext4

Windows/dos常用的分区工具:fdisk/partition magic/diskpart

Linux下常用的分区工具:

fdisk/sfdisk:命令行工具,各种版本和环境都能使用,包含在软件包util-linux中

diskdruid:图形化分区工具,只能在安装REDHAT系统时使用。

支持最大卷:18EB,(E:exabytes,1EB=1024TB)
每个磁盘最多支持128个分区

所以如果要大于2TB的卷或分区就必须得用GPT分区表。

Linux下fdisk工具不支持GPT,得使用另一个GNU发布的强大分区工具parted。

fdisk工具用的话,会有下面的警告信息:

下面是用parted工具对/dev/sda做GPT分区的过程:

如果我们的磁盘是2T以下的,但是分区表示GPT格式,我们也可以使用parted 命令将该分区表删除, mklabel msdos 这条命令就是用来删除 part分区 ,将GPT分区表删除后,再来使用 fdisk 建立MBR分区表,可以参考 https://www.xiaohuai.com/4870

mkfs - 支持ext2、ext3(日志)、ext4、vfat、msdos、jfs、reiserfs等

用法1:mkfs -t <fstype> <partition>

用法2:mkfs.<fstype> <partition>

ps:格式化分区之后,可以使用e2label命令给分区添加卷标

e2label 分区路径 卷标名

查看已经挂载的分区

或者

使用 mount 命令挂载

使用umount卸载分区时,可以指定挂载点,也可以指定挂载的路径, 卸载分区umount命令格式:

umount [option] special | node

或者

PS: 处理umount的时候显示 device busy?

这是因为有程序正在访问这个设备,最简单的办法就是让访问该设备的程序退出以后再umount。可能有时候用户搞不清除究竟是什么程序在访问设备,如果用户不急着umount,则可以用:

CODE:

选项 –l 并不是马上umount,而是在该目录空闲后再umount。还可以先用命令ps aux 来查看占用设备的程序PID,然后用命令kill来杀死占用设备的进程,这样就umount的非常放心了。

linux系统在启动时,会从/etc/fstab文件自动挂载分区。

如下是一个fstab文件的示例。

fstab中,每条配置信息都分为固定的6个部分

[1]: 分区路径,或者UUID

[2]: fs_file - 该字段描述希望的文件系统加载的目录点,对于swap设备,该字段为none;对于加载目录名包含空格的情况,用40来表示空格。

[3]: fs_type - 定义了该设备上的文件系统,一般常见的文件类型为ext4 (Linux设备的常用文件类型)、vfat(Windows系统的fat32格式)、NTFS、isoArray600等。在不确定的情况下可以使用auto。

[4]: fs_options - 指定加载该设备的文件系统是需要使用的特定参数选项,多个参数是由逗号分隔开来。

对于大多数系统使用"defaults"就可以满足需要。不多说。

[5]: fs_mp - 该选项被"mp"命令使用来检查一个文件系统应该以多快频率进行转储,若不需要转储就设

置该字段为0

[6]: fs_pass - 该字段被fsck命令用来决定在启动时需要被扫描的文件系统的顺序,根文件系统"/"对应该字

段的值应该为1,其他文件系统应该为2。若该文件系统无需在启动时扫描则设置该字段为0

参考

⑵ 关于linux系统分区的问题

Linux操作系统是基于UNIX操作系统发展而来的一种克隆系统,它诞生于1991 年的 [Linux桌面] 10 月5 日(这是第一次正式向外公布的时间)。
以后借助于Internet网络,并通过全世界各地计算机爱好者的共同努力,已成为今天世界上使用最多的一种UNIX 类操作系统,并且使用人数还在迅猛增长。

⑶ Linux新建分区。 创建1个80m的分区。修改其分区ID号为LVM(8e),将分区信息写入内核,让其生效,在线等。

[root@station7 ~]# fdisk /dev/sda
The number of cylinders for this disk is set to 9726.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): p #查看分区

Disk /dev/sda: 80.0 GB, 80000000000 bytes
255 heads, 63 sectors/track, 9726 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 3837 30716280 8e Linux LVM
/dev/sda3 3838 4098 2096482+ 82 Linux swap / Solaris
/dev/sda4 4099 9726 45206910 5 Extended
/dev/sda5 4099 4160 497983+ 83 Linux
/dev/sda6 4161 4285 1004031 8e Linux LVM
/dev/sda7 4286 4287 16033+ 83 Linux
/dev/sda8 4288 4350 506016 fd Linux raid autodetect
/dev/sda9 4351 4413 506016 fd Linux raid autodetect

Command (m for help): n #创建分区
First cylinder (4414-9726, default 4414):
Using default value 4414
Last cylinder or +size or +sizeM or +sizeK (4414-9726, default 9726): +80M #指定大小

Command (m for help): t #修改分区类型
Partition number (1-10): 10 #选择分区
Hex code (type L to list codes): 8e #分区类型名称
Changed system type of partition 10 to 8e (Linux LVM)

Command (m for help): w #保存退出
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
[root@station7 ~]# partprobe #同步分区表

⑷ linux系统格式化分区用哪个命令

linux系统格式化分区用fdisk命令。

Linux fdisk是一个创建和维护分区表的程序,它兼容DOS类型的分区表、BSD或者SUN类型的磁盘列表。

语法

fdisk [必要参数][选择参数]
必要参数:

-l 列出素所有分区表

-u 与"-l"搭配使用,显示分区数目

选择参数:

-s<分区编号> 指定分区

-v 版本信息

菜单操作说明

m :显示菜单和帮助信息

a :活动分区标记/引导分区

d :删除分区

l :显示分区类型

n :新建分区

p :显示分区信息

q :退出不保存

t :设置分区号

v :进行分区检查

w :保存修改

x :扩展应用,高级功能
常用:
fdisk -l 查看分区
fdisk -lu

当提示权限不够时,前面加上sudo

⑸ Linux中如何创建新分区啊

Linux下可以用fdisk命令新建分区,方法如下:
1、首先查看硬盘信息,用fdisk -l命令,如果有硬盘有剩余空间就可以对其进行分区。
2、下面对/dev/sdb 进行分区
3、有扩展分区和主分区,逻辑分区在扩展分区中建立。注意到括号中的1-4,最多只能建四个主分区(包括扩展分区)。先建一个主分区:
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p #建主分区
Partition number (1-4): 1 #分区号为1
First cylinder (1-2610, default 1): #直接回车默认从第一个柱面开始划分
Using default value 1
Last
cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610): +2G
#加空间大小,这里有很多种选择:+后面单位可以接M,G,K(记得要大写)表示划分你所加的空间,也可以是柱面数。不管怎样都不能超过该磁盘剩余的空间否则无效。
Command (m for help): p #分好后查看分区信息,刚所做的所有一目了然。
Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xfaa2aa49

Device Boot Start End Blocks Id System
/dev/sdb1 1 262 2104483+ 83 Linux
4、同上所述建立扩展分区:
Command (m for help): n
Command action
e extended
p primary partition (1-4)
e #建立扩展分区
Partition number (1-4): 4
First cylinder (263-2610, default 263):
Using default value 263
Last cylinder, +cylinders or +size{K,M,G} (263-2610, default 2610): +4G

Command (m for help): p

Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xfaa2aa49

Device Boot Start End Blocks Id System
/dev/sdb1 1 262 2104483+ 83 Linux
/dev/sdb4 263 785 4200997+ 5 Extended
5、扩展分区建好就可以在扩展分区建立逻辑分区了
Command (m for help): n
Command action
l logical (5 or over)
p primary partition (1-4)
l #建逻辑分区
First cylinder (263-785, default 263):
Using default value 263
Last cylinder, +cylinders or +size{K,M,G} (263-785, default 785): +2G

Command (m for help): p

Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xfaa2aa49

Device Boot Start End Blocks Id System
/dev/sdb1 1 262 2104483+ 83 Linux
/dev/sdb4 263 785 4200997+ 5 Extended
/dev/sdb5 263 524 2104483+ 83 Linux
6、上面显示已经建好一个主分区,一个逻辑分区,但是这些现在还没有生效,需要保存退出。
Command (m for help): w #保存退出
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks. 《Linux就该这么学》这本书上有详细的介绍

⑹ 在linux中怎么分区

Linux 的分区规定

1. 设备管理

在 Linux 中,每一个硬件设备都映射到一个系统的文件,对于硬盘、光驱等 IDE 或 SCSI 设备也不例外。

Linux 把各种 IDE 设备分配了一个由 hd 前缀组成的文件;而对于各种 SCSI 设备,则分配了一个由 sd 前缀组成的文件。例如,第一个 IDE 设备,Linux 就定义为 hda;第二个 IDE 设备就定义为 hdb;下面以此类推。而 SCSI 设备就应该是 sda、sdb、sdc 等。

2. 分区数量

要进行分区就必须针对每一个硬件设备进行操作,这就有可能是一块IDE硬盘或是一块SCSI硬盘。对于每一个硬盘(IDE 或 SCSI)设备,Linux 分配了一个 1 到 16 的序列号码,这就代表了这块硬盘上面的分区号码。例如,第一个 IDE 硬盘的第一个分区,在 Linux 下面映射的就是 hda1,第二个分区就称作是 hda2。对于 SCSI 硬盘则是 sda1、sdb1 等。

3. 各分区的作用

在 Linux 中规定,每一个硬盘设备最多能有 4 个主分区(其中包含扩展分区)构成,任何一个扩展分区都要占用一个主分区号码,也就是在一个硬盘中,主分区和扩展分区一共最多是 4 个。对于早期的 DOS 和 Windows(Windows 2000 以前的版本),系统只承认一个主分区,可以通过在扩展分区上增加逻辑盘符(逻辑分区)的方法,进一步地细化分区。

主分区的作用就是计算机用来进行启动操作系统的,因此每一个操作系统的启动,或者称作是引导程序,都应该存放在主分区上。这就是主分区和扩展分区及逻辑分区的最大区别。我们在指定安装引导 Linux 的 bootloader 的时候,都要指定在主分区上,就是最好的例证。

Linux 规定了主分区(或者扩展分区)占用 1 至 16 号码中的前 4 个号码。以第一个 IDE 硬盘为例说明,主分区(或者扩展分区)占用了 hda1、hda2、hda3、hda4,而逻辑分区占用了 hda5 到 hda16 等 12 个号码。因此,Linux 下面每一个硬盘总共最多有 16 个分区。

对于逻辑分区,Linux 规定它们必须建立在扩展分区上(在 DOS 和 Windows 系统上也是如此规定),而不是主分区上。因此,我们可以看到扩展分区能够提供更加灵活的分区模式,但不能用来作为操作系统的引导。

除去上面这些各种分区的差别,我们就可以简单地把它们一视同仁了。

5. 分区指标

对于每一个 Linux 分区来讲,分区的大小和分区的类型是最主要的指标。容量的大小读者很容易理解,但是分区的类型就不是那么容易接受了。分区的类型规定了这个分区上面的文件系统的格式。 Linux 支持多种的文件系统格式,其中包含了我们熟悉的FAT32、FAT16、NTFS、HP-UX,以及各种 Linux 特有的 Linux Native和 Linux Swap分区类型。在 Linux 系统中,可以通过分区类型号码来区别这些不同类型的分区。各种类型号码在介绍Fdisk的使用方式的时候将会介绍。

Fdisk 使用详解

下面通过介绍 Fdisk 的使用方法,来巩固上面所学到的各种关于 Linux 分区的知识。

Fdisk 是各种 Linux 发行版本中最常用的分区工具,是被定义为 Expert 级别的分区工具,它让初学者有点望而却步。

1. Fdisk 参数说明

运行Fdisk的时候,首先映入眼帘的如图 1 所示的欢迎界面,用户通过在这个界面中输入命令参数来操作Fdisk。

图 1 Fdisk 欢迎界面

用户通过提示键入 “m”,可以显示 Fdisk 命令各个参数的说明。

读者可以看到 Fdisk 有很多参数,可是经常使用的就是几个,如果读者熟练掌握这几个参数就可以流畅地运用 Fdisk,对 Linux 的硬盘进行分区。我们先简单介绍各个参数的意义,然后详细说明几个重点参数,见表 1。

表 1 Fdisk 参数说明

用户在 Linux 中进行分区的时候,最常用的参数分别是 d、l、m、n、p、q、t、w 等。

2.用 Fdisk 进行分区

在 Linux 分区过程,一般是先通过 p 参数来显示出硬盘分区表信息,然后根据信息确定将来的分区。如图2所示。

图 2 显示已有分区的

图 2 显示了分区的大小和分区的类型。如果想完全改变硬盘的分区格式,就可以通过 d 参数一个个删除存在的硬盘分区。例如 d1,d2。

删除完毕,就可以通过 n 参数来增加新的分区。当按下 “n” 后,我们就可以看到图 3 所示的新增分区。

图 3 新增分区

这里要选择新建的分区类型,是主分区还是扩展分区;然后选择 p 或是 e。它们的区别在上文中已经说明。然后就是设置分区的大小。需要提醒注意的是,如果硬盘上有扩展分区,就只能增加逻辑分区,不能增加扩展分区了,如图 4 所示。

图 4 新增逻辑分区

在增加分区的时候,其类型都是默认的 Linux Native,如果需要把其中的某些分区改变为其它类型,例如 Linux Swap 或 FAT32 等,可以通过命令 t 来改变,如图 5。

图 5 转换分区类型

当按下 “t” 改变分区类型的时候,系统会提示要改变哪个分区,并且改变为什么类型(如果想知道系统所支持的分区类型,键入 l)。图 5 表示把分区5的类型改变为 82 号 Linux 的 Swap 类型。

Linux 所支持的分区类型号码和其对应的分区类型,可以参考表 2(这些信息可以用 l 命令得到)。

表 2 分区类型对应表

改变完了分区类型,就可以按下 “w”,保存并且退出。如果不想保存,那么可以选择 “q” 直接退出。

通过以上两个方面的学习,相信对于初学者来说,分区已经不再是 Linux 进阶中的绊脚石了。

⑺ Linux下怎样用fdisk命令分区

body{
line-height:200%;
}
Linux下怎样用fdisk命令分区
1、添加新硬盘
因为在现有的硬盘当中,所有的空间以及被分配完了;这个时候就需要拿一块新的硬盘,然后在新硬盘进行分区。

虚拟机的好处是:只要你的真实机硬件空间足够,那你想添加多少块硬盘都可以;但是虚拟机必须先关闭,否则是不能添加新硬盘的
2、查看新硬盘
[root@localhost~]#
fdisk
-l
查询新添加的硬盘是否被识别。
3、使用fdisk命令分区
[root@localhost~]#
fdisk
/dev/sbd
fdisk交互指令说明
a:设置可引导标记
b:编辑bsd磁盘标签
c:设置DOS操作系统兼容标记
d:删除一个分区
l:显示已知的文件系统类型,82为Linux
swqp分区,83为Linux分区
m:显示帮助带单
n:新建分区
o:建立空白DOS分区表
p:显示分区列表
q:不保存退出
t:改变一个分区的系统ID
w:保存退出
4、重新读取分区表信息
[root@localhost~]#
partprobe
5、格式化分区
[root@localhost~]#
mkfs
-t
ext4
/dev/sdb1
6、建立挂载点并挂载
[root@localhost~]#
mkdir
/disk1
[root@localhost~]#
mount
/dev/sdb1/disk1/

⑻ Linux如何利用fdisk工具建立分区

fdisk磁盘分区工具

1.首先查看硬盘信息

fdisk -l 如果有硬盘有剩余空间就可以对其进行分区

[root@bogon 桌面]# fdisk -l

Disk /dev/sda: 85.9 GB, 85899345920 bytes
255 heads, 63 sectors/track, 10443 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000471ad

Device Boot Start End Blocks Id System
/dev/sda1 * 1 26 204800 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 26 3851 30720000 83 Linux
/dev/sda3 3851 4106 2048000 82 Linux swap / Solaris
/dev/sda4 4106 10444 50912256 5 Extended
/dev/sda5 4106 10444 50911232 83 Linux

Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
#从上面看出/dev/sda空间已经用完了,/dev/sdb没有使用。

下面我们对/dev/sdb 进行分区

[root@bogon 桌面]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xfaa2aa49.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').

Command (m for help): 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/sdb 输入m所有基本选项都出现,输入n新建分区

Command (m for help): n
Command action
e extended
p primary partition (1-4)
有扩展分区和主分区,逻辑分区在扩展分区中建立。注意到括号中的1-4,最多只能建四个主分区(包括扩展分区)。先建一个主分区:

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p #建主分区
Partition number (1-4): 1 #分区号为1
First cylinder (1-2610, default 1): #直接回车默认从第一个柱面开始划分
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610): +2G #加空间大小,这里有很多种选择:+后面单位可以接M,G,K(记得要大写)表示划分你所加的空间,也可以是柱面数。不管怎样都不能超过该磁盘剩余的空间否则无效。

Command (m for help): p #分好后查看分区信息,刚所做的所有一目了然。

Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xfaa2aa49

Device Boot Start End Blocks Id System
/dev/sdb1 1 262 2104483+ 83 Linux

同上所述建立扩展分区:

Command (m for help): n
Command action
e extended
p primary partition (1-4)
e #建立扩展分区
Partition number (1-4): 4
First cylinder (263-2610, default 263):
Using default value 263
Last cylinder, +cylinders or +size{K,M,G} (263-2610, default 2610): +4G

Command (m for help): p

Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xfaa2aa49

Device Boot Start End Blocks Id System
/dev/sdb1 1 262 2104483+ 83 Linux
/dev/sdb4 263 785 4200997+ 5 Extended

扩展分区建好我们就可以在扩展分区建立逻辑分区了

Command (m for help): n
Command action
l logical (5 or over)
p primary partition (1-4)
l #建逻辑分区
First cylinder (263-785, default 263):
Using default value 263
Last cylinder, +cylinders or +size{K,M,G} (263-785, default 785): +2G

Command (m for help): p

Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xfaa2aa49

Device Boot Start End Blocks Id System
/dev/sdb1 1 262 2104483+ 83 Linux
/dev/sdb4 263 785 4200997+ 5 Extended
/dev/sdb5 263 524 2104483+ 83 Linux
上面显示已经建好一个主分区,一个逻辑分区,但是这些现在还没有生效我们需要保存退出。

Command (m for help): w #保存退出
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

[root@bogon 桌面]# fdisk -l

Disk /dev/sda: 85.9 GB, 85899345920 bytes
255 heads, 63 sectors/track, 10443 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000471ad

Device Boot Start End Blocks Id System
/dev/sda1 * 1 26 204800 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 26 3851 30720000 83 Linux
/dev/sda3 3851 4106 2048000 82 Linux swap / Solaris
/dev/sda4 4106 10444 50912256 5 Extended
/dev/sda5 4106 10444 50911232 83 Linux

Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xfaa2aa49

Device Boot Start End Blocks Id System
/dev/sdb1 1 262 2104483+ 83 Linux
/dev/sdb4 263 785 4200997+ 5 Extended
/dev/sdb5 263 524 2104483+ 83 Linux

再次查看就看到了/dev/sdb的分区信息,虽然现在我们看到进行分区了,但是内核kenel还没有识别为了不要重启将分区表写入kenel我们要用到partprobe工具:使kenel重新读取分区表。
[root@bogon 桌面]# partprobe
Warning: WARNING: the kernel failed to re-read the partition table on /dev/sda (设备或资源忙). As a result, it may not reflect all of your changes until after reboot.

kenel识别分区表后,我们还不能使用它要对其进行格式化。mkfs.加文件系统格式,扩展分区是不能格式化的。

[root@bogon 桌面]# mkfs.ext4 /dev/sdb1 #格式化成ext4文件格式(要分区格式化,不能将整个硬盘格式化)
mke2fs 1.41.12 (17-May-2010)
文件系统标签=
操作系统:Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
131648 inodes, 20 blocks
26306 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=541065216
17 block groups
32768 blocks per group, 32768 fragments per group
7744 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912

正在写入inode表: 完成
Creating journal (16384 blocks): 完成
Writing superblocks and filesystem accounting information: 完成

This filesystem will be automatically checked every 30 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@bogon 桌面]# mkfs.ext4 /dev/sdb5 #格式化逻辑分区
mke2fs 1.41.12 (17-May-2010)
文件系统标签=
操作系统:Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
131648 inodes, 20 blocks
26306 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=541065216
17 block groups
32768 blocks per group, 32768 fragments per group
7744 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912

正在写入inode表: 完成
Creating journal (16384 blocks): 完成
Writing superblocks and filesystem accounting information: 完成

This filesystem will be automatically checked every 39 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.

格式化后就可以使用了

[root@bogon 桌面]# mkdir /bak
[root@bogon 桌面]# mount -o loop /dev/sdb1 /bak #挂载该分区到/bak
[root@bogon 桌面]# df -TH #查看当前硬盘挂载信息
文件系统 类型 容量 已用 可用 已用%% 挂载点
/dev/sda5 ext4 52G 3.9G 45G 8% /
tmpfs tmpfs 528M 279k 528M 1% /dev/shm
/dev/sda1 ext4 204M 28M 166M 15% /boot
/dev/sda2 ext4 31G 2.9G 27G 10% /usr
.host:/ vmhgfs 144G 41G 104G 29% /mnt/hgfs
/ios/RHEL6.3.iso
iso9660 3.2G 3.2G 0 100% /guazai
/dev/sdb1 ext4 2.2G 71M 2.0G 4% /bak

阅读全文

与linux创建分区表相关的资料

热点内容
编程怎么做3d生存游戏 浏览:955
word使用教程下载 浏览:295
电脑文件平铺图片默认大小 浏览:115
文件查看设置信息失败 浏览:668
编程如何编出乌鸦喝水的课文 浏览:20
国家反诈app报案助手怎么使用 浏览:439
秘密文件丢失多少天 浏览:237
js中csstext 浏览:382
目标文件名过长复制 浏览:892
乐动力计步器老版本 浏览:933
压缩文件链接怎么编辑 浏览:808
如何锁定PDF文件里的图章 浏览:89
数据库超时是什么 浏览:649
文件怎么改整列内容 浏览:764
360压缩文件发邮件空白 浏览:813
上哪里查自己大数据 浏览:907
编程语言怎么学车 浏览:189
编程该怎么学才能先找工作 浏览:524
文件刻制光盘多少钱 浏览:861
校园网的网络组成结构 浏览:862

友情链接