|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
如果您觉得本篇CentOSLinux教程讲得好,请记得点击右边漂浮的分享程序,把好文章分享给你的小伙伴们!磁盘分区,格局化与查验
磁盘分区:fdisk
磁盘格局化:mkfs,mke2fs
磁盘检测:fsck
年夜容量磁盘分区:parted
磁盘分区
语法:fdisk[-l]装备称号
-l:输入体系内一切分区
举例:- [root@localhost~]#fdisk-lDisk/dev/sda:21.4GB,21474836480bytes255heads,63sectors/track,2610cylindersUnits=cylindersof16065*512=8225280bytesDeviceBootStartEndBlocksIdSystem/dev/sda1*11310439183Linux/dev/sda214128810241437+83Linux/dev/sda3128919255116702+83Linux/dev/sda4192626105502262+5Extended/dev/sda519262052102009682Linuxswap/Solaris/dev/sda6205323022008093+83Linux
复制代码 1.检察磁盘文件名
[root@localhost~]#df/
文件体系1K-块已用可用已用%挂载点
/dev/sda299206244329108507944847%/
2.检察磁盘分区功效- [root@localhost~]#fdisk/dev/sda//这里不带数字Thenumberofcylindersforthisdiskissetto2610.Thereisnothingwrongwiththat,butthisislargerthan1024,andcouldincertainsetupscauseproblemswith:1)softwarethatrunsatboottime(e.g.,oldversionsofLILO)2)bootingandpartitioningsoftwarefromotherOSs(e.g.,DOSFDISK,OS/2FDISK)Command(mforhelp):mCommandactionatoggleabootableflagbeditbsddisklabelctogglethedoscompatibilityflagddeleteapartition//删除磁盘分区llistknownpartitiontypesmprintthismenu//检察磁盘分区功效naddanewpartition//增添一个磁盘分区ocreateanewemptyDOSpartitiontablepprintthepartitiontable//检察磁盘分区qquitwithoutsavingchangesscreateanewemptySundisklabeltchangeapartitionssystemiduchangedisplay/entryunitsvverifythepartitiontablewwritetabletodiskandexitxextrafunctionality(expertsonly)
复制代码 删除磁盘分区
- [root@localhost~]#fdisk/dev/sdaThenumberofcylindersforthisdiskissetto2610.Thereisnothingwrongwiththat,butthisislargerthan1024,andcouldincertainsetupscauseproblemswith:1)softwarethatrunsatboottime(e.g.,oldversionsofLILO)2)bootingandpartitioningsoftwarefromotherOSs(e.g.,DOSFDISK,OS/2FDISK)Command(mforhelp):pDisk/dev/sda:21.4GB,21474836480bytes255heads,63sectors/track,2610cylindersUnits=cylindersof16065*512=8225280bytesDeviceBootStartEndBlocksIdSystem/dev/sda1*11310439183Linux/dev/sda214128810241437+83Linux/dev/sda3128919255116702+83Linux/dev/sda4192626105502262+5Extended/dev/sda519262052102009682Linuxswap/Solaris/dev/sda6205323022008093+83Linux
复制代码 由上可知我的磁盘次要分为6个分区,1,2,3为主分区,4为扩大分区,5为swap分区,6是逻辑分区
- Command(mforhelp):dPartitionnumber(1-6):3Command(mforhelp):pDisk/dev/sda:21.4GB,21474836480bytes255heads,63sectors/track,2610cylindersUnits=cylindersof16065*512=8225280bytesDeviceBootStartEndBlocksIdSystem/dev/sda1*11310439183Linux/dev/sda214128810241437+83Linux/dev/sda4192626105502262+5Extended/dev/sda519262052102009682Linuxswap/Solaris/dev/sda6205323022008093+83Linux删除主分区sad3后能够看到磁盘信息不在包括sad3Command(mforhelp):dPartitionnumber(1-6):4Command(mforhelp):pDisk/dev/sda:21.4GB,21474836480bytes255heads,63sectors/track,2610cylindersUnits=cylindersof16065*512=8225280bytesDeviceBootStartEndBlocksIdSystem/dev/sda1*11310439183Linux/dev/sda214128810241437+83Linux
复制代码 删除扩大分区sad4后能够看到扩大分区,逻辑分区都被删除(由于逻辑分区是由扩大分区衍生而来的)。
增添磁盘分区
磁盘分区最多只能有4个主分区+扩大分区构成,个中扩大分区最多只能有一个,剩下在创立的分区都是由扩大分区衍生出来的逻辑分区
举例1.因为磁盘现分辨别为3个主分区,1个扩大分区。因而在创立时将间接创立逻辑分区,而不在扣问是不是创立主分区大概扩大分区- [root@localhost~]#fdisk/dev/sdaThenumberofcylindersforthisdiskissetto2610.Thereisnothingwrongwiththat,butthisislargerthan1024,andcouldincertainsetupscauseproblemswith:1)softwarethatrunsatboottime(e.g.,oldversionsofLILO)2)bootingandpartitioningsoftwarefromotherOSs(e.g.,DOSFDISK,OS/2FDISK)Command(mforhelp):pDisk/dev/sda:21.4GB,21474836480bytes255heads,63sectors/track,2610cylindersUnits=cylindersof16065*512=8225280bytesDeviceBootStartEndBlocksIdSystem/dev/sda1*11310439183Linux/dev/sda214128810241437+83Linux/dev/sda3128919255116702+83Linux/dev/sda4192626105502262+5Extended/dev/sda519262052102009682Linuxswap/Solaris/dev/sda6205323022008093+83LinuxCommand(mforhelp):nFirstcylinder(2303-2610,default2303):
复制代码 举例2:创立主/扩大分区- [root@localhost~]#fdisk/dev/sdaThenumberofcylindersforthisdiskissetto2610.Thereisnothingwrongwiththat,butthisislargerthan1024,andcouldincertainsetupscauseproblemswith:1)softwarethatrunsatboottime(e.g.,oldversionsofLILO)2)bootingandpartitioningsoftwarefromotherOSs(e.g.,DOSFDISK,OS/2FDISK)Command(mforhelp):d//先将主分区和逻辑分区删除(假如为4个则默许创立逻辑分区)Partitionnumber(1-6):2Command(mforhelp):dPartitionnumber(1-6):4Command(mforhelp):pDisk/dev/sda:21.4GB,21474836480bytes255heads,63sectors/track,2610cylindersUnits=cylindersof16065*512=8225280bytesDeviceBootStartEndBlocksIdSystem/dev/sda1*11310439183Linux/dev/sda3128919255116702+83LinuxCommand(mforhelp):nCommandactioneextendedpprimarypartition(1-4)
复制代码 提醒用户选择是是创立主分区仍是扩大分区
举例3.创立逻辑分区与扩大分区- root@localhost~]#fdisk/dev/sdaThenumberofcylindersforthisdiskissetto2610.Thereisnothingwrongwiththat,butthisislargerthan1024,andcouldincertainsetupscauseproblemswith:1)softwarethatrunsatboottime(e.g.,oldversionsofLILO)2)bootingandpartitioningsoftwarefromotherOSs(e.g.,DOSFDISK,OS/2FDISK)Command(mforhelp):pDisk/dev/sda:21.4GB,21474836480bytes255heads,63sectors/track,2610cylindersUnits=cylindersof16065*512=8225280bytesDeviceBootStartEndBlocksIdSystem/dev/sda1*11310439183Linux/dev/sda214128810241437+83Linux/dev/sda3128919255116702+83Linux/dev/sda4192626105502262+5Extended/dev/sda519262052102009682Linuxswap/Solaris/dev/sda6205323022008093+83LinuxCommand(mforhelp):dPartitionnumber(1-6):4Command(mforhelp):nCommandactioneextendedpprimarypartition(1-4)eSelectedpartition4Firstcylinder(1926-2610,default1926):Usingdefaultvalue1926Lastcylinderor+sizeor+sizeMor+sizeK(1926-2610,default2610):Usingdefaultvalue2610Command(mforhelp):pDisk/dev/sda:21.4GB,21474836480bytes255heads,63sectors/track,2610cylindersUnits=cylindersof16065*512=8225280bytesDeviceBootStartEndBlocksIdSystem/dev/sda1*11310439183Linux/dev/sda214128810241437+83Linux/dev/sda3128919255116702+83Linux/dev/sda4192626105502262+5Extended
复制代码 sd4为新创立的扩大分区,巨细为从柱面1926到2610
- Command(mforhelp):nFirstcylinder(1926-2610,default1926):Usingdefaultvalue1926Lastcylinderor+sizeor+sizeMor+sizeK(1926-2610,default2610):+500M
复制代码 关于此处能够指定柱面号码,以能够经由过程+XXM指定巨细,让其主动分派柱面
Command(mforhelp):p- Disk/dev/sda:21.4GB,21474836480bytes255heads,63sectors/track,2610cylindersUnits=cylindersof16065*512=8225280bytesDeviceBootStartEndBlocksIdSystem/dev/sda1*11310439183Linux/dev/sda214128810241437+83Linux/dev/sda3128919255116702+83Linux/dev/sda4192626105502262+5Extended/dev/sda519261987497983+83Linux
复制代码 sd5为新创立的逻辑分区,巨细为500M
内核对找分区
当我们增添分区后,体系让我们reboot以加载分区。也能够不必重启,只必要关照内容从头查找分区便可- Thepartitiontablehasbeenaltered!Callingioctl()tore-readpartitiontable.WARNING:Re-readingthepartitiontablefailedwitherror16:装备或资本忙.Thekernelstillusestheoldtable.Thenewtablewillbeusedatthenextreboot.Syncingdisks.[root@localhost~]#partprobe
复制代码
磁盘格局化
分区终了后要举行文件体系的格局化
mkfs
语法:mkfs[-t文件体系格局]装备文件名
选项与参数:
-t:文件体系格局,比方ext3,ext2,vfat等
举例- [root@localhost~]#fdisk/dev/sda//这里不带数字Thenumberofcylindersforthisdiskissetto2610.Thereisnothingwrongwiththat,butthisislargerthan1024,andcouldincertainsetupscauseproblemswith:1)softwarethatrunsatboottime(e.g.,oldversionsofLILO)2)bootingandpartitioningsoftwarefromotherOSs(e.g.,DOSFDISK,OS/2FDISK)Command(mforhelp):mCommandactionatoggleabootableflagbeditbsddisklabelctogglethedoscompatibilityflagddeleteapartition//删除磁盘分区llistknownpartitiontypesmprintthismenu//检察磁盘分区功效naddanewpartition//增添一个磁盘分区ocreateanewemptyDOSpartitiontablepprintthepartitiontable//检察磁盘分区qquitwithoutsavingchangesscreateanewemptySundisklabeltchangeapartitionssystemiduchangedisplay/entryunitsvverifythepartitiontablewwritetabletodiskandexitxextrafunctionality(expertsonly)0
复制代码 个中文件体系Label和iBLOCK巨细均接纳默许巨细。假如关于EXT2/EXT3我们对这些信息由特别的需求,可使用mke2fs
mke2fs
语法:mke2fs[-bblock巨细][-iinode巨细][-L卷标][-cj]装备
选项与参数:
-b:设置block巨细,今朝撑持1024,2048,4096
-i:几容量赐与一个inode
-c:反省磁盘毛病
-L:卷标称号(Label)
-j:主动到场日记体系成为EXT3文件体系,不加在默许为EXT2
举例- [root@localhost~]#fdisk/dev/sda//这里不带数字Thenumberofcylindersforthisdiskissetto2610.Thereisnothingwrongwiththat,butthisislargerthan1024,andcouldincertainsetupscauseproblemswith:1)softwarethatrunsatboottime(e.g.,oldversionsofLILO)2)bootingandpartitioningsoftwarefromotherOSs(e.g.,DOSFDISK,OS/2FDISK)Command(mforhelp):mCommandactionatoggleabootableflagbeditbsddisklabelctogglethedoscompatibilityflagddeleteapartition//删除磁盘分区llistknownpartitiontypesmprintthismenu//检察磁盘分区功效naddanewpartition//增添一个磁盘分区ocreateanewemptyDOSpartitiontablepprintthepartitiontable//检察磁盘分区qquitwithoutsavingchangesscreateanewemptySundisklabeltchangeapartitionssystemiduchangedisplay/entryunitsvverifythepartitiontablewwritetabletodiskandexitxextrafunctionality(expertsonly)1
复制代码 磁盘检测(fsck)
语法:fsck[-t文件体系格局][-ACay]
选项与参数
-t:文件体系格局。
-A:根据/etc/fstab的内容,将必要的安装扫瞄一次。
-a:主动修复反省到的有成绩的扇区.
-y:与-a相似,可是某些filesystem仅撑持-y这个参数
-C:能够在查验的历程傍边,利用一个直方图来显现今朝的进度!
EXT2/EXT3的分外选项功效:(e2fsck这支下令所供应)
-f:强迫反省!一样平常来讲,假如fsck没有发明任何unclean的旗标,不会自动进进细部反省的,假如您想要强迫fsck进进细部反省,就得加上-f
-D:针对文件体系下的目次举行优化设置。
举例- [root@localhost~]#fdisk/dev/sda//这里不带数字Thenumberofcylindersforthisdiskissetto2610.Thereisnothingwrongwiththat,butthisislargerthan1024,andcouldincertainsetupscauseproblemswith:1)softwarethatrunsatboottime(e.g.,oldversionsofLILO)2)bootingandpartitioningsoftwarefromotherOSs(e.g.,DOSFDISK,OS/2FDISK)Command(mforhelp):mCommandactionatoggleabootableflagbeditbsddisklabelctogglethedoscompatibilityflagddeleteapartition//删除磁盘分区llistknownpartitiontypesmprintthismenu//检察磁盘分区功效naddanewpartition//增添一个磁盘分区ocreateanewemptyDOSpartitiontablepprintthepartitiontable//检察磁盘分区qquitwithoutsavingchangesscreateanewemptySundisklabeltchangeapartitionssystemiduchangedisplay/entryunitsvverifythepartitiontablewwritetabletodiskandexitxextrafunctionality(expertsonly)2
复制代码 申明:必要磁盘反省的分区不克不及挂载在体系上,必要先被卸载才干磁盘检测
年夜容量磁盘分区(parted)
因为fdisk没法撑持到高于2TB以上的分区,此时就必要parted来处置了
语法:parted[装备][下令[参数]]
选项与参数:
新增分区:mkpart[primary|logical|extended][ext3|vfat]入手下手停止
分区表:print
删除分区:rm[partition]
举例1:检察分区表- [root@localhost~]#fdisk/dev/sda//这里不带数字Thenumberofcylindersforthisdiskissetto2610.Thereisnothingwrongwiththat,butthisislargerthan1024,andcouldincertainsetupscauseproblemswith:1)softwarethatrunsatboottime(e.g.,oldversionsofLILO)2)bootingandpartitioningsoftwarefromotherOSs(e.g.,DOSFDISK,OS/2FDISK)Command(mforhelp):mCommandactionatoggleabootableflagbeditbsddisklabelctogglethedoscompatibilityflagddeleteapartition//删除磁盘分区llistknownpartitiontypesmprintthismenu//检察磁盘分区功效naddanewpartition//增添一个磁盘分区ocreateanewemptyDOSpartitiontablepprintthepartitiontable//检察磁盘分区qquitwithoutsavingchangesscreateanewemptySundisklabeltchangeapartitionssystemiduchangedisplay/entryunitsvverifythepartitiontablewwritetabletodiskandexitxextrafunctionality(expertsonly)3
复制代码 经由过程以上信息能够看出,扩大分区到21.5G,逻辑分区利用到16.9G,那末16.9G~21.5G只局部空间还为被利用(未被分区)
举例2:新增分区- [root@localhost~]#fdisk/dev/sda//这里不带数字Thenumberofcylindersforthisdiskissetto2610.Thereisnothingwrongwiththat,butthisislargerthan1024,andcouldincertainsetupscauseproblemswith:1)softwarethatrunsatboottime(e.g.,oldversionsofLILO)2)bootingandpartitioningsoftwarefromotherOSs(e.g.,DOSFDISK,OS/2FDISK)Command(mforhelp):mCommandactionatoggleabootableflagbeditbsddisklabelctogglethedoscompatibilityflagddeleteapartition//删除磁盘分区llistknownpartitiontypesmprintthismenu//检察磁盘分区功效naddanewpartition//增添一个磁盘分区ocreateanewemptyDOSpartitiontablepprintthepartitiontable//检察磁盘分区qquitwithoutsavingchangesscreateanewemptySundisklabeltchangeapartitionssystemiduchangedisplay/entryunitsvverifythepartitiontablewwritetabletodiskandexitxextrafunctionality(expertsonly)4
复制代码 举例3:删除分区- [root@localhost~]#fdisk/dev/sda//这里不带数字Thenumberofcylindersforthisdiskissetto2610.Thereisnothingwrongwiththat,butthisislargerthan1024,andcouldincertainsetupscauseproblemswith:1)softwarethatrunsatboottime(e.g.,oldversionsofLILO)2)bootingandpartitioningsoftwarefromotherOSs(e.g.,DOSFDISK,OS/2FDISK)Command(mforhelp):mCommandactionatoggleabootableflagbeditbsddisklabelctogglethedoscompatibilityflagddeleteapartition//删除磁盘分区llistknownpartitiontypesmprintthismenu//检察磁盘分区功效naddanewpartition//增添一个磁盘分区ocreateanewemptyDOSpartitiontablepprintthepartitiontable//检察磁盘分区qquitwithoutsavingchangesscreateanewemptySundisklabeltchangeapartitionssystemiduchangedisplay/entryunitsvverifythepartitiontablewwritetabletodiskandexitxextrafunctionality(expertsonly)5
复制代码- [root@localhost~]#fdisk/dev/sda//这里不带数字Thenumberofcylindersforthisdiskissetto2610.Thereisnothingwrongwiththat,butthisislargerthan1024,andcouldincertainsetupscauseproblemswith:1)softwarethatrunsatboottime(e.g.,oldversionsofLILO)2)bootingandpartitioningsoftwarefromotherOSs(e.g.,DOSFDISK,OS/2FDISK)Command(mforhelp):mCommandactionatoggleabootableflagbeditbsddisklabelctogglethedoscompatibilityflagddeleteapartition//删除磁盘分区llistknownpartitiontypesmprintthismenu//检察磁盘分区功效naddanewpartition//增添一个磁盘分区ocreateanewemptyDOSpartitiontablepprintthepartitiontable//检察磁盘分区qquitwithoutsavingchangesscreateanewemptySundisklabeltchangeapartitionssystemiduchangedisplay/entryunitsvverifythepartitiontablewwritetabletodiskandexitxextrafunctionality(expertsonly)6
复制代码 申明:parted分区提交即实行,因而利用起来需当心
本文出自“StarFlex”博客,请务必保存此出处http://tiankefeng.blog.51cto.com/8687281/1372404
如果您觉得本篇CentOSLinux教程讲得好,请记得点击右边漂浮的分享程序,把好文章分享给你的好朋友们! |
|