知识屋:更实用的电脑技术知识网站
所在位置:首页 > 操作系统 > linux

Linux分区、格式化、挂载

发布时间:2014-09-05 17:41:45作者:知识屋

什么叫分区?分区指的是告诉操作系统,我这块磁盘,按柱面的范围划分成若干个分区。例如1-50个柱面做sda1,51-100个柱面做sda2分区。这样,将一个硬盘(或者lun),划分为更小更好管理的单位,接下来我们可以对不同的分区,格式化成不同的文件系统等。
什么叫格式化?格式化的目的是将分区弄成文件系统,文件系统有什么作用呢?引入文件系统后,各个程序都通过文件系统接口访问磁盘,文件系统能保障访问同一文件的先后顺序,提供目录树,限定用户权限等。如果没有文件系统,每个用户都直接调用磁盘控制器驱动程序,无法限定文件权限,并且可能会在磁盘上互相覆盖。
在虚拟机vmware workstation上,加一块20g的scsi硬盘
并没有发现磁盘,证明要重启一下,加磁盘的动作是冷添加。[root@pri%20dev]#%20ls%20"%20grep%20sdsdasda1sda2sda3重启一下后,就能看到新增加的sdb。[root@pri%20dev]#%20ls%20|%20grep%20sdsdasda1sda2sda3sdb
然后用fdisk命令做分区,m是帮助,n是添加,w是保存。[root@pri%20dev]#%20fdisk%20/dev/sdbCommand%20(m%20for%20help):%20m%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20#按m获取帮助Command%20action%20%20%20a%20toggle%20a%20bootable%20flag%20%20%20b%20edit%20bsd%20disklabel%20%20%20c%20toggle%20the%20dos%20compatibility%20flag%20%20%20d%20delete%20a%20partition%20%20%20l%20list%20known%20partition%20types%20%20%20m%20print%20this%20menu%20%20%20n%20add%20a%20new%20partition%20%20%20o%20create%20a%20new%20empty%20DOS%20partition%20table%20%20%20p%20print%20the%20partition%20table%20%20%20q%20quit%20without%20saving%20changes%20%20%20s%20create%20a%20new%20empty%20Sun%20disklabel%20%20%20t%20change%20a%20partition's%20system%20id%20%20%20u%20change%20display/entry%20units%20%20%20v%20verify%20the%20partition%20table%20%20%20w%20write%20table%20to%20disk%20and%20exit%20%20%20x%20extra%20functionality%20(experts%20only)Command%20(m%20for%20help):%20nCommand%20action%20%20%20e%20extended%20%20%20p%20primary%20partition%20(1-4)pPartition%20number%20(1-4):%201First%20cylinder%20(1-1566,%20default%201):Using%20default%20value%201Last%20cylinder%20or%20+size%20or%20+sizeM%20or%20+sizeK%20(1-1566,%20default%201566):%20100Command%20(m%20for%20help):%20nCommand%20action%20%20%20e%20extended%20%20%20p%20primary%20partition%20(1-4)pPartition%20number%20(1-4):%202First%20cylinder%20(101-1566,%20default%20101):%20101Last%20cylinder%20or%20+size%20or%20+sizeM%20or%20+sizeK%20(101-1566,%20default%201566):%20200Command%20(m%20for%20help):%20nCommand%20action%20%20%20e%20extended%20%20%20p%20primary%20partition%20(1-4)3Invalid%20partition%20number%20for%20type%20`3'Command%20action%20%20%20e%20extended%20%20%20p%20primary%20partition%20(1-4)pPartition%20number%20(1-4):%203First%20cylinder%20(201-1566,%20default%20201):Using%20default%20value%20201Last%20cylinder%20or%20+size%20or%20+sizeM%20or%20+sizeK%20(201-1566,%20default%201566):%20300Command%20(m%20for%20help):%20nCommand%20action%20%20%20e%20extended%20%20%20p%20primary%20partition%20(1-4)4Invalid%20partition%20number%20for%20type%20`4'
当加到第4个的时候,就不可以了。证明主分区最多只能有3个,剩下的一个只能作为扩展分区。
Command%20(m%20for%20help):%20nCommand%20action%20%20%20e%20extended%20%20%20p%20primary%20partition%20(1-4)eSelected%20partition%204First%20cylinder%20(301-1566,%20default%20301):Using%20default%20value%20301Last%20cylinder%20or%20+size%20or%20+sizeM%20or%20+sizeK%20(301-1566,%20default%201566):%20400Command%20(m%20for%20help):%20nFirst%20cylinder%20(301-400,%20default%20301):Using%20default%20value%20301Last%20cylinder%20or%20+size%20or%20+sizeM%20or%20+sizeK%20(301-400,%20default%20400):Using%20default%20value%20400
我们再划分一个扩展分区,301-400,再按n划分,则只能从这个301-400的扩展分区再来划分出逻辑分区了,400以后的柱面就浪费了。而且后续我们格式化的对象,只能是主分区与逻辑分区,而无法是扩展分区。
格式化mkfs%20-t%20ext3%20/dev/sdb1这样就能把sdb1这个分区,格式化成ext3文件系统。格式化过后的分区,可以再重新被格式化成另外一种文件系统,例如ext2,vfs
挂载:讲文件系统与目录树结合的操作,我们叫挂载。[root@pri%20dev]#%20cd%20/u01[root@pri%20u01]#%20lsapp[root@pri%20u01]#%20mkdir%20test[root@pri%20u01]#%20mount%20/dev/sdb1%20/u01/test[root@pri%20u01]#%20cd%20/u01/test[root@pri%20test]#%20df%20-h%20.Filesystem%20Size%20Used%20Avail%20Use%%20Mounted%20on/dev/sdb1%20773M%2017M%20716M%203%%20/u01/test挂载点一定是目录,该目录为进入该文件系统的入口。如果不进行挂载,我们就无法使用这个文件系统。
(免责声明:文章内容如涉及作品内容、版权和其它问题,请及时与我们联系,我们将在第一时间删除内容,文章内容仅供参考)
收藏
  • 人气文章
  • 最新文章
  • 下载排行榜
  • 热门排行榜