Linux磁盘管理(精品)

上传人:沈*** 文档编号:174408359 上传时间:2022-12-15 格式:DOC 页数:6 大小:251.50KB
收藏 版权申诉 举报 下载
Linux磁盘管理(精品)_第1页
第1页 / 共6页
Linux磁盘管理(精品)_第2页
第2页 / 共6页
Linux磁盘管理(精品)_第3页
第3页 / 共6页
资源描述:

《Linux磁盘管理(精品)》由会员分享,可在线阅读,更多相关《Linux磁盘管理(精品)(6页珍藏版)》请在装配图网上搜索。

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

2、: 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

3、 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 bytes

4、Disk /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第

5、 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/sda9204242169921698218291024140610

6、522268382LinuxLinux 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 m

7、emory 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 w

8、ill 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 *

9、 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 byt

10、es第 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 Su

11、n, 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.

12、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

13、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): nCo

14、mmand 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创建分区。Comm

15、and (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): +10G

16、l显示目录的分区情况,注意这里显示的内容只是一个计算值目前并没有写入磁盘分区表。如果不想保存本次的修改内容可使用“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/sdb2121827

17、4132104193705Extendedl第一个扩展分区的编号总是 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 命令会提示磁盘分区表无法写的错,这里可以重新启动计算机或使用如下命令使改变的分区信息写入磁盘分区表。Comman

18、d (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 # par

19、tprobe(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

20、(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/sdb1St

21、art1End1217Blocks Id System9775521 83 Linux/dev/sdb21218274132104193705Extended/dev/sdb512182434977552183 Linuxl删除分区。Command (m for help): dl输入要删除的分区编号,这里输入“5”表示要删除第 2 个分区。Partition number (1-5): 5l再次查看分区情况,第 5 个分区已经删除。Command (m for help): pDisk /dev/sdb: 225.4 GB, 225485783040 bytes255 heads, 63 s

22、ectors/track, 27413 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesDevice Boot/dev/sdb1Start1End1217Blocks Id System9775521 83 Linux/dev/sdb21218274132104193705ExtendedCommand (m for help): w#保存 fdisk 的修改并退出。The partition table has been altered!Calling ioctl() to re-read partition table.第 5 页,共 17 页感谢您试用AnyBizSoft PDF to Word。试用版仅能转换5页文档。要转换全部文档,免费获取注册码请访问

展开阅读全文
温馨提示:
1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
2: 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
3.本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!