CentOS教程之CentOS磁盘分区,格局化与查验
如果您觉得本篇CentOSLinux教程讲得好,请记得点击右边漂浮的分享程序,把好文章分享给你的小伙伴们!磁盘分区,格局化与查验磁盘分区:fdisk
磁盘格局化:mkfs,mke2fs
磁盘检测:fsck
年夜容量磁盘分区:parted
磁盘分区
语法:fdisk[-l]装备称号
-l:输入体系内一切分区
举例:
#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.检察磁盘文件名
#df/
文件体系1K-块已用可用已用%挂载点
/dev/sda299206244329108507944847%/
2.检察磁盘分区功效
#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)
删除磁盘分区
#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个扩大分区。因而在创立时将间接创立逻辑分区,而不在扣问是不是创立主分区大概扩大分区
#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:创立主/扩大分区
#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+5Extendedsd4为新创立的扩大分区,巨细为从柱面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+83Linuxsd5为新创立的逻辑分区,巨细为500M
内核对找分区
当我们增添分区后,体系让我们reboot以加载分区。也能够不必重启,只必要关照内容从头查找分区便可
Thepartitiontablehasbeenaltered!Callingioctl()tore-readpartitiontable.WARNING:Re-readingthepartitiontablefailedwitherror16:装备或资本忙.Thekernelstillusestheoldtable.Thenewtablewillbeusedatthenextreboot.Syncingdisks.#partprobe
磁盘格局化
分区终了后要举行文件体系的格局化
mkfs
语法:mkfs[-t文件体系格局]装备文件名
选项与参数:
-t:文件体系格局,比方ext3,ext2,vfat等
举例
#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
举例
#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:针对文件体系下的目次举行优化设置。
举例
#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入手下手停止
分区表:print
删除分区:rm
举例1:检察分区表
#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:新增分区
#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:删除分区
#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#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教程讲得好,请记得点击右边漂浮的分享程序,把好文章分享给你的好朋友们!
CentOS教程之CentOS磁盘分区,格局化与查验
任何一个叫做操作系统的工具都是这样子构成的:内核+用户界面+一般应用程序。 以前觉得Linux就跟dos一样,全是用命令窗口,相对于窗口界面来说多麻烦呀。 甚至目前许多应用软件都是基于它的。可是没有哪一个系统是十分完美的。 我们这一代90后,从小接触的是windows98,家里条件好的自己有电脑装的是2000,后来又有了XP,上大学时又有了win7。 Linux操作系统这个名词记得在很早以前就听过,但当时并不知道具体是什么样的操作系统,只知道是一个与嵌入式密切相关的操作系统。 其中不乏很多IT精英的心血。我们学透以后更可以做成自己的OS!? 学习Linux应具备的。[书籍+网络资源] 对于英语不是很好的读者红旗 Linux、中标Linux这些中文版本比较适合。现在一些Linux网站有一些Linux版本的免费下载,这里要说的是并不适合Linux初学者。
页:
[1]