steam 蒸汽平台-360杀毒软件免费下

c盘格式化会怎么样
2023年4月4日发(作者:天正建筑t20注册机)

26.分区格式化,硬盘分区,fdisk详解,mkfs格式化,4,mkfs.。。。

本章详细讲解分区格式化,硬盘分区,fdisk使⽤,mkfs格式化,4,详细使⽤⽅法和⽰例

⽂章⽬录

fdisk分区操作

格式化作⽤

Linuxfdisk是⼀个创建和维护分区表的程序,实质上是对硬盘的格式化。当创建分区时,设置好硬盘的各项参数,指定硬盘主引导记录

(MBR)。

对于⽂件系统需要的信息则是通过格式化产⽣,例如windows安装系统时,会将硬盘格式化成C,D,E逻辑盘,并指定⽂件系统类型是

NTFS(主流)。

查看分区信息

fdisk查看分区,命令如下:

[root@zaishu~]#fdisk~l//列出所有分区

[root@prometheus~]#fdisk-l

Disk/dev/sda:53.7GB,53687091200bytes,104857600sectors

Units=sectorsof1*512=512bytes

Sectorsize(logical/physical):512bytes/512bytes

I/Osize(minimum/optimal):512bytes/512bytes

Disklabeltype:dos

Diskidentifier:0x000c43e1

DeviceBootStartEndBlocksIdSystem

/dev/sda1*280083Linux

/dev/sda24116484682Linuxswap/Solaris

/dev/sda346995012582483Linux

含义如下:硬盘⼤⼩53.7G,53687091200bytes;⼀共包含104857600个扇区,每个扇区的⼤⼩512bytes。

信息的下半部分是分区的信息,共7列,含义如下:

列名含义

Device分区的设备名。类似Windows中的C盘,d盘

Boot是否为启动引导分区,在这⾥/dev/sda1为启动引导分区。MBR的信息存储在这。

Start起始柱⾯,代表分区从哪⾥开始。

End终⽌柱⾯,代表分区到哪⾥结束。

Blocks分区的⼤⼩,单位是KB。

id分区内⽂件系统的ID。在fdisk命令中,可以使⽤“i”查看。

System分区内安装的系统是什么。

选项含义

特定硬盘分区

fdis/dev/sdb

[root@prometheus~]#fdisk/dev/sdb

Welcometofdisk(util-linux2.23.2).

Changeswillremaininmemoryonly,untilyoudecidetowritethem.

Becarefulbeforeusingthewritecommand.

输⼊m查看帮助

Command(mforhelp):m

Commandaction

atoggleabootableflag

beditbsddisklabel

ctogglethedoscompatibilityflag

ddeleteapartition

gcreateanewemptyGPTpartitiontable

GcreateanIRIX(SGI)partitiontable

llistknownpartitiontypes

mprintthismenu

naddanewpartition

ocreateanewemptyDOSpartitiontable

pprintthepartitiontable

qquitwithoutsavingchanges

screateanewemptySundisklabel

tchangeapartition'ssystemid

uchangedisplay/entryunits

vverifythepartitiontable

wwritetabletodiskandexit

xextrafunctionality(expertsonly)

命令说明

a设置可引导标记

b编辑bsd磁盘标签

c设置DOS操作系统兼容标记

d删除⼀个分区

l显⽰所有⽂件系统类型

m显⽰帮助菜单

n新建分区

0建⽴空⽩DOS分区表

P显⽰分区列表

q不保存退出

s新建空⽩SUN磁盘标签

t改变分区的系统ID

u改变显⽰记录单位

V验证分区表

w保存退出

X附加功能(仅专家)

创建分区

1.添加硬盘

关闭虚拟机进⾏操作,添加硬盘

2.查看硬盘

[root@zaishu~]#fdisk-l

Disk/dev/sda:53.7GB,53687091200bytes,104857600sectors

Units=sectorsof1*512=512bytes

Sectorsize(logical/physical):512bytes/512bytes

I/Osize(minimum/optimal):512bytes/512bytes

Disklabeltype:dos

Diskidentifier:0x000caa7c

DeviceBootStartEndBlocksIdSystem

/dev/sda1*280083Linux

/dev/sda24116484682Linuxswap/Solaris

/dev/sda346995012582483Linux

Disk/dev/sdb:5368MB,5368709120bytes,10485760sectors//操作系统已识别到这块硬盘

Units=sectorsof1*512=512bytes

Sectorsize(logical/physical):512bytes/512bytes

I/Osize(minimum/optimal):512bytes/512bytes

3.查看分区列表

[root@zaishu~]#fdisk/dev/sdb

Welcometofdisk(util-linux2.23.2).

Changeswillremaininmemoryonly,untilyoudecidetowritethem.

Becarefulbeforeusingthewritecommand.

Devicedoesnotcontainarecognizedpartitiontable

BuildinganewDOSdisklabelwithdiskidentifier0x8f2b14b3.

Command(mforhelp):p//⽬前⼀个分区都没有

Disk/dev/sdb:5368MB,5368709120bytes,10485760sectors

Units=sectorsof1*512=512bytes

Sectorsize(logical/physical):512bytes/512bytes

I/Osize(minimum/optimal):512bytes/512bytes

Disklabeltype:dos

Diskidentifier:0x8f2b14b3

DeviceBootStartEndBlocksIdSystem

4.创建主分区

Command(mforhelp):n//新建分区

Partitiontype:

pprimary(0primary,0extended,4free)

eextended

Select(defaultp):p//分区类型是主分区

Partitionnumber(1-4,default1):1//分区号

Firstsector(2,default2048)://默认会选择扇区的可⽤起始位置。

Lastsector,+sectorsor+size{K,M,G}(2,default10485759):+200M

//可以使⽤size{K,M,G}的⽅式指定硬盘⼤⼩。也可以指定扇区数量指定⼤⼩。/dev/sdb1的⼤⼩是200M

Partition1oftypeLinuxandofsize200MiBisset

Command(mforhelp):

#主分区建⽴好后,输⼊p,查看分区信息

Command(mforhelp):p

Disk/dev/sdb:5368MB,5368709120bytes,10485760sectors

Units=sectorsof1*512=512bytes

Sectorsize(logical/physical):512bytes/512bytes

I/Osize(minimum/optimal):512bytes/512bytes

Disklabeltype:dos

Diskidentifier:0xdd762bbe

DeviceBootStartEndBlocksIdSystem

/dev/sdb1280083Linux

Command(mforhelp):w//输⼊w,信息写⼊分区表,保存

Thepartitiontablehasbeenaltered!

Callingioctl()tore-readpartitiontable.

Syncingdisks.

主分区和扩展分区加起来最多只能建⽴4个,⽽扩展分区最多只能建⽴1个,可以在扩展分区当中建⽴N个逻辑分区。

5.创建扩展分区

扩展分区最⼤作⽤是,后续可以再扩展分区当中建⽴N个逻辑分区

[root@zaishu~]#fdisk/dev/sdb

Welcometofdisk(util-linux2.23.2).

Changeswillremaininmemoryonly,untilyoudecidetowritethem.

Becarefulbeforeusingthewritecommand.

Command(mforhelp):n

Partitiontype:

pprimary(1primary,0extended,3free)

eextended

Select(defaultp):e//选择e,扩展分区,

Partitionnumber(2-4,default2):

Firstsector(411648-10485759,default411648):

Usingdefaultvalue411648

Lastsector,+sectorsor+size{K,M,G}(411648-10485759,default10485759):+2G

Partition2oftypeExtendedandofsize2GiBisset

Command(mforhelp):p

Disk/dev/sdb:5368MB,5368709120bytes,10485760sectors

Units=sectorsof1*512=512bytes

Sectorsize(logical/physical):512bytes/512bytes

I/Osize(minimum/optimal):512bytes/512bytes

Disklabeltype:dos

Diskidentifier:0xdd762bbe

DeviceBootStartEndBlocksIdSystem

/dev/sdb1280083Linux

/dev/sdb2411648465Extended

Command(mforhelp):w

Thepartitiontablehasbeenaltered!

Callingioctl()tore-readpartitiontable.

Syncingdisks.

6.创建逻辑分区

[root@zaishu~]#fdisk/dev/sdb

Welcometofdisk(util-linux2.23.2).

Changeswillremaininmemoryonly,untilyoudecidetowritethem.

Becarefulbeforeusingthewritecommand.

Command(mforhelp):p

Disk/dev/sdb:5368MB,5368709120bytes,10485760sectors

Units=sectorsof1*512=512bytes

Sectorsize(logical/physical):512bytes/512bytes

I/Osize(minimum/optimal):512bytes/512bytes

Disklabeltype:dos

Diskidentifier:0xdd762bbe

DeviceBootStartEndBlocksIdSystem

/dev/sdb1280083Linux

/dev/sdb2411648465Extended//扩展分区

Command(mforhelp):n

Partitiontype:

pprimary(1primary,1extended,2free)

llogical(numberedfrom5)//表⽰现在可以创建逻辑分区

Select(defaultp):l

Addinglogicalpartition5

Firstsector(413696-4605951,default413696):

Usingdefaultvalue413696

Lastsector,+sectorsor+size{K,M,G}(413696-4605951,default4605951):+500M

Partition5oftypeLinuxandofsize500MiBisset

Command(mforhelp):p

Disk/dev/sdb:5368MB,5368709120bytes,10485760sectors

Units=sectorsof1*512=512bytes

Sectorsize(logical/physical):512bytes/512bytes

I/Osize(minimum/optimal):512bytes/512bytes

Disklabeltype:dos

Diskidentifier:0xdd762bbe

DeviceBootStartEndBlocksIdSystem

/dev/sdb1280083Linux

/dev/sdb2411648465Extended

/dev/sdb54551200083Linux//创建的逻辑分区

Command(mforhelp):w

Thepartitiontablehasbeenaltered!

Callingioctl()tore-readpartitiontable.

Syncingdisks.

7.保存和退出

所有的分区⽴过程中不保存退出是不会⽣效的,q命令不保存退出;w命令,保存退出。

mkfs格式化分区

格式化其实就是创建⽂件系统。分区完成后,通常需要对分区进⾏格式化,指定分区类型,例如windows当中指定类型是ntfs,centos中指

定类型是xfs/ext4。格式化后再指定挂载点。

[root@zaishu~]#df-hT

FilesystemTypeSizeUsedAvailUse%Mountedon

devtmpfsdevtmpfs476M0476M0%/dev

tmpfstmpfs487M0487M0%/dev/shm

tmpfstmpfs487M14M473M3%/run

tmpfstmpfs487M0487M0%/sys/fs/cgroup

/dev/sda3xfs48G3.1G45G7%/

/dev/sda1xfs197M138M60M70%/boot

tmpfstmpfs98M098M0%/run/user/0

⽤法

mkfs[tab][tab]:按下两下tab键查看系统⽀持哪些⽂件系统的格式化功能

mkfs-t[⽂件系统格式名]===>等同于mkfs.⽂件系统格式名

mkfs-txfs与相同

mkfs-text4与4

格式化xfs

[-b参数][-d参数][-i参数][-l参数][-L参数][-f][-r参数]设备名称

参数

Listitem

-b

后⾯接的是区块容量,范围(512B-64KB),Linux限制最⼤4K

-d

datap相关参数

agcount=设置需要⼏个存储群组的意思(AG),通常与CPU有关

agsize=每个AG设置为多少容量的意思。通常agcount/agsize只选⼀个设置

file指的是格式化的设备是个⽂件⽽不是个设备的意思(例如虚拟磁盘)

size=datap的容量。你可以设置⼤⼩

su=当有RAID(磁盘列阵)时,代表stripe的数值⼤⼩,与下⾯的sw搭配使⽤

sw=当有RAID时,⽤于保存数据的磁盘数量(需扣除备份盘与备⽤盘)

sunit=与su意思相同。不过单位使⽤的是⼏个sector(512B)的意思(⼀个stripe由多少个扇区组成)

swidth=就是su*sw的数值,但是以⼏个sector(512B)来设置

-f

如果设备内已经有了⽂件系统,则需要使⽤-f强制格式化

-i

与inode有关的设置

size=最⼩的是256B,最⼤是2K。⼀般使⽤256B就⾜够了

internal=[01]

logdev=devicelog设备为后⾯接的那个设备上⾯的意思,需设置internal=0才可以

size=指定这块登录区的容量,通常最⼩得要512个区块,⼤约2M=以上才⾏

-L

Lablename

-r

指定realtimep的相关设置

extsize=extent数据设置,当使⽤RAID时,最好设置与swidth数据相同较佳。范围(4K-1G)

⽰范

通常格式化分区,不需要加任何选项

[root@zaishu~]#/dev/sdb5

meta-data=/dev/sdb5isize=512agcount=4,agsize=32000blks

=sectsz=512attr=2,projid32bit=1

=crc=1finobt=0,sparse=0

data=bsize=4096blocks=128000,imaxpct=25

=sunit=0swidth=0blks

naming=version2bsize=4096ascii-ci=0ftype=1

log=internallogbsize=4096blocks=855,version=2

=sectsz=512sunit=0blks,lazy-count=1

realtime=noneextsz=4096blocks=0,rtextents=0

格式化ext4

创建ext4⽂件系统.centos6默认⽂件系统类型

4[-b参数][-L参数]设备名称

-b:后⾯设置区块的⼤⼩,有1K、2K、4K

-L:后⾯接这个设备的标头名称Labelname

默认值已写⼊⾄/etc/这个⽂件中,通常不需要加任何选项。

⽰范

[root@zaishu~]#4/dev/sdb5

mke2fs1.42.9(28-Dec-2013)

Filesystemlabel=

OStype:Linux

Blocksize=1024(log=0)

Fragmentsize=1024(log=0)

Stride=0blocks,Stripewidth=0blocks

128016inodes,512000blocks

25600blocks(5.00%)reservedforthesuperuser

Firstdatablock=1

Maximumfilesystemblocks=34078720

63blockgroups

8192blockspergroup,8192fragmentspergroup

2032inodespergroup

Superblockbackupsstoredonblocks:

8193,24577,40961,57345,73729,204801,221185,401409

Allocatinggrouptables:done

Writinginodetables:done

Creatingjournal(8192blocks):done

Writingsuperblocksandfilesystemaccountinginformation:done

总结

本章详细讲解分区格式化,硬盘分区,fdisk使⽤,mkfs格式化,4,详细使⽤⽅法和⽰例

更多推荐

c盘格式化会怎么样