




免费预览已结束,剩余1页可下载查看
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1.1 通过命令对磁盘进行分区在 Linux 中最常用的分区工具是 fdisk。这个命令行工具可以在最基本的环境中选择,但是只有 root 用户可以使用。该命令语法如下。fdisk -l 设备号常用选项:ll设备号:需要进行配置的磁盘。-l:显示指定磁盘的分区情况。fdisk 命令的选项并不多,主要的操作是进入 fdisk 环境的的相关操作,下面看几个 fdisk命令的例子。显示所有硬盘的分区情况在 fdisk -l 显示的信息中,该计算机共有二块非 IDE 硬盘,其中/dev/sda 已经有分区;/dev/sda 还没有进行分区。rootsrv # fdisk -lDisk /dev/sda: 214.7 GB, 214748364800 bytes255 heads, 63 sectors/track, 26108 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesDevice Boot/dev/sda1 *Start1End25Blocks Id System200781 83 Linux/dev/sda22663995119915583 Linux/dev/sda36400127735119915583Linux/dev/sda4/dev/sda512774127742610815323107113387+ 5 Extended20482843+ 83 Linux/dev/sda6153241787320482843+ 83Linux/dev/sda7/dev/sda81787420424204232169820482843+ 83 Linux10241406 83 Linux/dev/sda9 21699 21829 1052226Disk /dev/sdb: 225.4 GB, 225485783040 bytes255 heads, 63 sectors/track, 27413 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesDisk /dev/sdb doesnt contain a valid partition table显示指定硬盘的分区情况显示第一块非 IDE 硬盘的分区情况。rootsrv # fdisk -l /dev/sdaDisk /dev/sda: 214.7 GB, 214748364800 bytes255 heads, 63 sectors/track, 26108 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytes82Linux swap / SolarisDevice BootStartEndBlocksIdSystem第 1 页,共 17 页/dev/sda1*12520078183Linux/dev/sda22663995119915583 Linux/dev/sda36400127735119915583Linux/dev/sda4/dev/sda5/dev/sda6/dev/sda71277412774153241787426108153231787320423107113387+ 5 Extended20482843+ 83 Linux20482843+ 83 Linux20482843+ 83 Linux/dev/sda8/dev/sda9204242169921698218291024140610522268382LinuxLinux swap / Solaris使用 fdisk 创建及管理硬盘分区使用 fdisk 命令进行分区时,直接使用“fdisk 设备号”即可进入 fdisk 命令环境,比如要对第二块非 IDE 硬盘进行分区,可使用“fdisk /dev/sdb”。rootsrv # fdisk /dev/sdbDevice contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabelBuilding a new DOS disklabel. Changes will remain in memory only,until you decide to write them. After that, of course, the previouscontent wont be recoverable.1) software that runs at boot time (e.g., old versions of LILO)2) booting and partitioning software from other OSs(e.g., DOS FDISK, OS/2 FDISK)Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)Command (m for help):在进入 fdisk 环境后,需要使用一系统指令进行分区操作。可以通过“m”查看这些指令的帮助信息。下面是几个在 fdisk 环境中常用的指令。(1) p:显示当前磁盘分区情况。在显示内容中“Disk /dev/sdb: 225.4 GB,225485783040 bytes”表示第二块非 IDE 硬盘的容量为 210G;“255 heads, 63sectors/track, 27413 cylinders”是 fdisk 计算的柱面数等信息; Units = cylindersof 16065 * 512 = 8225280 bytes”是每个柱面的大小为 8M 多一点;接下是磁盘的分区表信息每列含义如下:llllllDevice:指向这个设备节点,通常作为这个分区的名称使用。Boot:如果在该表有“*”表示所在行的分区是可引导的,每个磁盘上可以有一个主分区被标为可引导。Start、End:分区开始和结束的柱面。Blocks:以 1024 字节的块为计算单位的分区大小。Id:一个 2 位的十六进制数,代表分区类型。System:Id 定义的分区类型的文本名称。Command (m for help): pDisk /dev/sdb: 225.4 GB, 225485783040 bytes第 2 页,共 17 页“255 heads, 63 sectors/track, 27413 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesDevice BootStartEndBlocksIdSystem(2) n:建立新的分区、w 保存 fdisk 的修改并退出、q 不保存 fdisk 的修改并退出。l使用 fdisk 命令为/dev/sdb 管理分区。rootsrv # fdisk /dev/sdbDevice contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabelBuilding a new DOS disklabel. Changes will remain in memory only,until you decide to write them. After that, of course, the previouscontent wont be recoverable.1) software that runs at boot time (e.g., old versions of LILO)2) booting and partitioning software from other OSs(e.g., DOS FDISK, OS/2 FDISK)Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)创建分区。Command (m for help): nCommand actionl输入“e”表示要建立扩展分区;输入“p”表示要建立主分区。pepextendedprimary partition (1-4)l输入分区编号。Partition number (1-4): 1l输入新建分区的起始柱面数,一般不输入直接回车。First cylinder (1-27413, default 1):Using default value 1l输入新建分区的结束柱面数。输入柱面数虽然可以精确的进行分区,但计算起来比较麻烦。一般这里都直接输入新建分区的大小让 fdisk 自己计算,这样实际分区的大小可能与输入的大小有一点差别,但这个差别并不大不会影响正确使用。直接输入大小时使用“+”接分区大小及单位,比如下面输入的就是希望新建分区的大小是 10G。还可以使用 M、T 等其它一些单位。Last cylinder or +size or +sizeM or +sizeK (1-27413, default 27413): +10G创建分区。Command (m for help): nCommand actionepextendedprimary partition (1-4)el输入 e,建立扩展分区。第 3 页,共 17 页l输入分区编号。Partition number (1-4): 2First cylinder (1218-27413, default 1218):Using default value 1218l直接回车表示把磁盘所有的剩余空间都给这个分区。Last cylinder or +size or +sizeM or +sizeK (1218-27413, default 27413):Using default value 27413l创建分区。Command (m for help): nCommand actionl输入“l”表示要建立逻辑分区,由于一块磁盘只能有一个扩展分区,上一步已经建立了一个扩展分区,所以这里只能建立主分区或在扩展分区主建立逻辑分区。lplogical (5 or over)primary partition (1-4)lFirst cylinder (1218-27413, default 1218):Using default value 1218l输入分区大小。Last cylinder or +size or +sizeM or +sizeK (1218-27413, default 27413): +10Gl显示目录的分区情况,注意这里显示的内容只是一个计算值目前并没有写入磁盘分区表。如果不想保存本次的修改内容可使用“q”退出。Command (m for help): pDisk /dev/sdb: 225.4 GB, 225485783040 bytes255 heads, 63 sectors/track, 27413 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesDevice Boot/dev/sdb1Start1End1217Blocks Id System9775521 83 Linux/dev/sdb21218274132104193705Extendedl第一个扩展分区的编号总是 5 开始。/dev/sdb512182434977552183 Linuxl保存 fdisk 的修改并退出。Command (m for help): wThe partition table has been altered!Calling ioctl() to re-read partition table.Syncing disks.对于已有分区并在使用的硬盘使用 fdisk 改变分区保存退出时,fdisk 命令会提示磁盘分区表无法写的错,这里可以重新启动计算机或使用如下命令使改变的分区信息写入磁盘分区表。Command (m for help): w第 4 页,共 17 页The partition table has been altered!Calling ioctl() to re-read partition table.#无法写磁盘分区表。WARNING: Re-reading the partition table failed with error 16: Device or resource busy.The kernel still uses the old table.The new table will be used at the next reboot.rootsrv # partprobe(3) d:删除分区。#使用 partprobe 命令使新建的分区信息写入磁盘分区表。l使用 fdisk 命令为/dev/sdb 管理分区。rootsrv # fdisk /dev/sdbThe number of cylinders for this disk is set to 27413.There is nothing wrong with that, but this is larger than 1024,and could in certain setups cause problems with:1) software that runs at boot time (e.g., old versions of LILO)2) booting and partitioning software from other OSs(e.g., DOS FDISK, OS/2 FDISK)l显示当前磁盘分区情况。Command (m for help): pDisk /dev/sdb: 225.4 GB, 225485783040 bytes255 heads, 63 sectors/track, 27413 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesDevice Boot/dev/sdb1Start1End1217Blocks Id System9775521 83 Linux/dev/sdb21
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 历史押题大题真题及答案
- 植物种子画框创新创业项目商业计划书
- 嵌入式CPU创新创业项目商业计划书
- 2025至2030年中国吸顶盘市场分析及竞争策略研究报告
- 医院医生个人实习总结
- 石英玻璃熔制工国庆节后复工安全考核试卷含答案
- 家电采购合同(标准版)
- 制冷工国庆节后复工安全考核试卷含答案
- 儿童发育指导师中秋节后复工安全考核试卷含答案
- 聚氯乙烯装置操作工中秋节后复工安全考核试卷含答案
- YY/T 1268-2023环氧乙烷灭菌的产品追加和过程等效
- 抽油机井示功图分析判断1
- 机电一体化说专业比赛
- 平地机操作规程
- GB/T 39141.3-2022无机和蓝宝石手表玻璃第3部分:定性标准和试验方法
- GB/T 1142-2004套式扩孔钻
- 2022年天津市河东区生态环境系统事业单位招聘笔试试题及答案
- 研究生学术道德与学术规范课件
- 浦发银行个人信用报告异议申请表
- 电镀行业环境执法现场检查要点
- 趣味成语 完整版PPT
评论
0/150
提交评论