仓酷云

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 449|回复: 8
打印 上一主题 下一主题

[CentOS(社区)] CentOS教程之CentOS磁盘分区,格局化与查验

[复制链接]
若天明 该用户已被删除
跳转到指定楼层
楼主
发表于 2015-1-14 20:43:04 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
如果您觉得本篇CentOSLinux教程讲得好,请记得点击右边漂浮的分享程序,把好文章分享给你的小伙伴们!磁盘分区,格局化与查验


磁盘分区:fdisk
磁盘格局化:mkfs,mke2fs
磁盘检测:fsck
年夜容量磁盘分区:parted

磁盘分区


语法:fdisk[-l]装备称号
-l:输入体系内一切分区

举例:
  1. [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.检察磁盘分区功效
  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)
复制代码
删除磁盘分区
  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+83Linux
复制代码
由上可知我的磁盘次要分为6个分区,1,2,3为主分区,4为扩大分区,5为swap分区,6是逻辑分区
  1. 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个扩大分区。因而在创立时将间接创立逻辑分区,而不在扣问是不是创立主分区大概扩大分区
  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:创立主/扩大分区
  1. [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.创立逻辑分区与扩大分区
  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):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
  1. Command(mforhelp):nFirstcylinder(1926-2610,default1926):Usingdefaultvalue1926Lastcylinderor+sizeor+sizeMor+sizeK(1926-2610,default2610):+500M
复制代码
关于此处能够指定柱面号码,以能够经由过程+XXM指定巨细,让其主动分派柱面
Command(mforhelp):p
  1. 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以加载分区。也能够不必重启,只必要关照内容从头查找分区便可
  1. Thepartitiontablehasbeenaltered!Callingioctl()tore-readpartitiontable.WARNING:Re-readingthepartitiontablefailedwitherror16:装备或资本忙.Thekernelstillusestheoldtable.Thenewtablewillbeusedatthenextreboot.Syncingdisks.[root@localhost~]#partprobe
复制代码

磁盘格局化

分区终了后要举行文件体系的格局化

mkfs

语法:mkfs[-t文件体系格局]装备文件名
选项与参数:
-t:文件体系格局,比方ext3,ext2,vfat等

举例
  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)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

举例
  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)1
复制代码
磁盘检测(fsck)

语法:fsck[-t文件体系格局][-ACay]
选项与参数
-t:文件体系格局。
-A:根据/etc/fstab的内容,将必要的安装扫瞄一次。
-a:主动修复反省到的有成绩的扇区.
-y:与-a相似,可是某些filesystem仅撑持-y这个参数
-C:能够在查验的历程傍边,利用一个直方图来显现今朝的进度!

EXT2/EXT3的分外选项功效:(e2fsck这支下令所供应)
-f:强迫反省!一样平常来讲,假如fsck没有发明任何unclean的旗标,不会自动进进细部反省的,假如您想要强迫fsck进进细部反省,就得加上-f
-D:针对文件体系下的目次举行优化设置。

举例
  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)2
复制代码
申明:必要磁盘反省的分区不克不及挂载在体系上,必要先被卸载才干磁盘检测

年夜容量磁盘分区(parted)

因为fdisk没法撑持到高于2TB以上的分区,此时就必要parted来处置了

语法:parted[装备][下令[参数]]
选项与参数:
新增分区:mkpart[primary|logical|extended][ext3|vfat]入手下手停止
分区表:print
删除分区:rm[partition]

举例1:检察分区表
  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:新增分区
  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)4
复制代码
举例3:删除分区
  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)5
复制代码
  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)6
复制代码
申明:parted分区提交即实行,因而利用起来需当心

本文出自“StarFlex”博客,请务必保存此出处http://tiankefeng.blog.51cto.com/8687281/1372404
如果您觉得本篇CentOSLinux教程讲得好,请记得点击右边漂浮的分享程序,把好文章分享给你的好朋友们!
柔情似水 该用户已被删除
沙发
发表于 2015-1-16 21:49:39 | 只看该作者

CentOS教程之CentOS磁盘分区,格局化与查验

任何一个叫做操作系统的工具都是这样子构成的:内核+用户界面+一般应用程序。
金色的骷髅 该用户已被删除
板凳
发表于 2015-1-24 16:32:47 | 只看该作者
以前觉得Linux就跟dos一样,全是用命令窗口,相对于窗口界面来说多麻烦呀。
小女巫 该用户已被删除
地板
发表于 2015-2-2 11:50:21 | 只看该作者
甚至目前许多应用软件都是基于它的。可是没有哪一个系统是十分完美的。
活着的死人 该用户已被删除
5#
发表于 2015-2-7 21:20:29 | 只看该作者
我们这一代90后,从小接触的是windows98,家里条件好的自己有电脑装的是2000,后来又有了XP,上大学时又有了win7。
因胸联盟 该用户已被删除
6#
发表于 2015-2-23 23:44:49 | 只看该作者
Linux操作系统这个名词记得在很早以前就听过,但当时并不知道具体是什么样的操作系统,只知道是一个与嵌入式密切相关的操作系统。
再见西城 该用户已被删除
7#
发表于 2015-3-7 11:38:16 | 只看该作者
其中不乏很多IT精英的心血。我们学透以后更可以做成自己的OS!?
蒙在股里 该用户已被删除
8#
发表于 2015-3-15 07:14:14 | 只看该作者
学习Linux应具备的。[书籍+网络资源]
变相怪杰 该用户已被删除
9#
发表于 2015-3-21 23:32:14 | 只看该作者
对于英语不是很好的读者红旗 Linux、中标Linux这些中文版本比较适合。现在一些Linux网站有一些Linux版本的免费下载,这里要说的是并不适合Linux初学者。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|仓酷云 鄂ICP备14007578号-2

GMT+8, 2024-12-24 01:23

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表