linux格式化全盘命令 linux格式化所有硬盘

linux系统硬盘怎么格式化LVM将一个或多个硬盘的分区在逻辑上集合,相当于一个大硬盘来使用,当硬盘的空间不够使用的时候 , 可以继续将其它的硬盘的分区加入其中,这样可以实现磁盘空间的动态管理,相对于普通的磁盘分区有很大的灵活性 。那么你知道linux系统硬盘怎么格式化吗?我带来了linux系统硬盘格式化的具体操作过程,下面大家跟着我一起来学习一下吧 。
linux系统硬盘怎么格式化
分区与格式化
先用fdisk分区 , 分区完成后再用mkfs格式化并创建文件系统,挂载 , 磁盘就能使用啦 。
分区的原理:
MBR:主引导扇区
主分区表:64bytes,最多只能分四个主分区,每个主分区的记录(相关信息,比如分区大小,位置)在主分区表里占14bytes 。
如果要建多于四个的分区,就要拿出一个主分区做为扩展分区 , 再在扩展分区里面进行其它的分区操作 。在 建扩展分区的时候会建立一张对应的扩展分区表,它记录了在这个扩展分区里的分区的相关信息;理论上它没有分区数量的限制,在扩展分区内部的分区叫做逻辑分区,如上图中的 /dev/hda5,/dev/hda6/,/dev/hda7
格式化原理:
在分好区后,分区里面是空的,没有任何东西 。为了能让OS识别 , 就必须要向分区里写入相应格式的数据 。比如windows的FAT32,NTFS;Linux的ext2,ext3 , ext4(目前ext3格式的用的比较多,ext4还在实验之中,在新的Fedora上使用的就是ext4的文件系统) 。
Windows/dos常用的分区工具:fdisk/partition magic/diskpart
Linux下常用的分区工具:
fdisk/sfdisk:命令行工具,各种版本和环境都能使用,包含在软件包util-linux中
diskdruid:图形化分区工具,只能在安装REDHAT系统时使用 。
下面我们开始实验:
环境/工具:Fedora 14/256M内存卡;fdisk
第一步:fdisk
[root@novice ~]# fdisk -l /dev/sdb
Disk /dev/sdb: 254 MB, 254017536 bytes
8 heads, 61 sectors/track, 1016 cylinders, total 496128 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Device Boot Start End Blocks Id System
[root@novice ~]# fdisk /dev/sdb
Command (m for help): #在输入上面的命令后会出现左边的提示,输入m就会得到一个帮助菜单 , 如下:
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)
#help虽然是英文的,可都很简单,在这里不再解释 。
#现在,我们正式开始分区的操作:
Command (m for help): n #新建分区
Command action
e extended
p primary partition (1-4)
#e/p分别对应扩展分区 /主分区;我们先分四个主分区 , 每个50M;然后再来增加主分区或扩展分区,看会出现怎样的状况,嘿嘿 。
p #分区类型为主分区
Partition number (1-4, default 1): 1 #分区号,在这里我们依次选择1、2、3、4
First sector (2048-496127, default 2048): #指定分区的起始扇区,一般默认,按enter键即可 。
Last sector, +sectors or +size{K,M,G} (2048-496127, default 496127): +50M #指定分区的终止扇区,根据前面的提示我们可以做出相应的选择+sectors 或 +size{K,M,G}

推荐阅读