




已阅读5页,还剩14页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
Linux下分区详解之-Fdisk1、 通过Fdisk查看系统分区详细信息:Fdisk l 详解:rootjetsenLin # fdisk - Disk /dev/sda: 10.7 GB, 10737418240 bytes255 heads, 63 sectors/track, 1305 cylindersUnits = cylinders of 16065 * 512 = 8225280bytes注释:这个硬盘的大小是10.7GB,有255个磁面,63个扇区,1305磁柱(cylinders)每个cylinder(磁柱)的容量是 8225280 bytes=8225.280 K(约为)=8.225280M(约为);Device Boot Start End Blocks Id System/dev/sda1 * 1 13 104391 83 Linux/dev/sda2 14 1305 10377990 8e Linux LVMid和System 表示的是一个意思,id看起来不太直观,我们要在fdisk 一个分区时,通过指定id来确认分区类型;比如 7表示的就NTFS 分区;这个在fdisk 中要通过t功能来指定。下面的部分会提到;Disk /dev/sdb: 21.4 GB,21474836480 bytes255 heads, 63 sectors/track, 2610 cylindersUnits = cylinders of 16065 * 512 = 8225280bytesDisk /dev/sdb doesnt contain a validpartition table说明:硬盘分区的表示:在Linux 是通过hd*x 或 sd*x 表示的:其中* 表示的是a、b、c . .另外x 表示的数字 1、2、3 . .hd大多是IDE硬盘;sd大多是SCSI或移动存储;引导(Boot):表示引导分区,在上面的例子中sda1 是引导分区;Start (开始):表示的一个分区从Xcylinder(磁柱)开始;End (结束):表示一个分区到 Ycylinder(磁柱)结束;2、 学会使用fdisk帮助功能:rootjetsenLin# fdisk /dev/sdaThenumber of cylinders for this disk is set to 1305.There isnothing wrong with that, but this is larger than 1024,and couldin certain setups cause problems with:1) softwarethat 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)Command(m for help): m -输出帮助信息Commandactiona toggle a bootable flag -设置启动分区b edit bsd disklabel -编辑分区标签c toggle thedoscompatibility flagd delete a partition -删除一个分区l list known partition types -列出分区类型m print this menu -帮助n add a new partition -建立一个新的分区o create a new empty DOS partition table -创建一个新的空白DOS分区表p print the partition table -打印分区表q quit without saving changes -退出不保存设置s createa new empty Sun disklabel -t changea partitions system id -改变分区的IDu changedisplay/entry units -改变显示的单位v verifythe partition table -检查验证分区表w write table to disk and exit -保存分区表x extra functionality (experts only)Command (m for help):3、 通过Fdisk对磁盘分区进行操作:Fdisk 创建分区:rootjetsenLin #fdisk /dev/sdbDevice contains neither a valid DOSpartition table, nor Sun, SGI or OSF disklabelBuilding a new DOS disklabel. Changes willremain in memory only,until you decide to write them. After that,of course, the previouscontent wont be The number of cylinders for this disk isset to 2610.There is nothing wrong with that, but thisis larger than 1024,and could in certain setups cause problemswith:1) software that runs at boot time (e.g.,old versions of LILO)2) booting and partitioning software fromother OSs(e.g., DOS FDISK, OS/2 FDISK)Warning: invalid flag 0x0000 of partitiontable 4 will be corrected by w(rite)Command (m for help): n -输入m会有帮助信息出来,输入n不打印帮助信息Command actione extendedp primary partition (1-4) -指定分区类型 e为扩展分区 p为主分区pPartition number (1-4): 1 -定义分区数量 -主分区最多只能有四个First cylinder (1-2610, default 1): 1 -设定起始分区的位置Last cylinder or +size or +sizeM or +sizeK(1-2610, default 2610):Using default value 2610 -设定结束分区的位置Command (m for help): w -保存刚才的配置信息。The partition table has been altered!Calling ioctl() to re-read partition table.Syncing disks.rootjetsenLin # Fdisk 删除分区:rootjetsenLin # fdisk /dev/sdb The number of cylinders for this disk isset to 2610.There is nothing wrong with that, but thisis larger than 1024,and could in certain setups cause problemswith:1) software that runs at boot time (e.g.,old versions of LILO)2) booting and partitioning software fromother OSs(e.g., DOS FDISK, OS/2 FDISK)Command (m for help): d -d 是代表删除,并且会列出当前磁盘的分区数。Selected partition 1Command (m for help): p -p 是代表删除后,显示磁盘还有几个剩余的分区。Disk /dev/sdb: 21.4 GB, 21474836480 bytes255 heads, 63 sectors/track, 2610 cylindersUnits = cylinders of 16065 * 512 = 8225280bytesDevice Boot Start End Blocks Id System -已经没有分区了Command (m for help): w -保存刚才的操作并且生效The partition table has been altered!Calling ioctl() to re-read partition table.WARNING: Re-reading the partition tablefailed with error 16: Device or resource busy. The kernel still uses the old table.The new table will be used at the nextreboot.这里报了一错误,分区表正在使用,删除再下次启动生效Syncing disks. -同步新的磁盘信息rootjetsenLin # fdisk -l /dev/sdbDisk /dev/sdb: 21.4 GB, 21474836480 bytes255 heads, 63 sectors/track, 2610 cylindersUnits = cylinders of 16065 * 512 = 8225280bytesDevice Boot Start End Blocks Id S 通过fdisk 命令来创建一指定大小的分区并增加一个分区Fdisk n创建分区:rootjetsenLin # fdisk /dev/sdbThe number of cylinders for this disk isset to 2610.There is nothing wrong with that, but thisis larger than 1024,and could in certain setups cause problemswith:1) software that runs at boot time (e.g.,old versions of LILO)2) booting and partitioning software fromother OSs(e.g., DOS FDISK, OS/2 FDISK)Command (m for help): n -创建分区Command actione extendedp primary partition (1-4) -指定分区类型为主分区pPartition number (1-4): 1 -指定其实分区号First cylinder (1-2610, default 1): 1 -指定起始柱面号Last cylinder or +size or +sizeM or +sizeK(1-2610, default 2610): 1024 -指定终止柱面号Command (m for help): w -保存分区配置信息The partition table has been altered!Calling ioctl() to re-read partition WARNING: Re-reading the partition tablefailed with error 16: Device or resource busy.The kernel still uses the old table.The new table will be used at the nextreboot.Syncing disks.增加分区:rootjetsenLin # fdisk /dev/sdb -增加分区The number of cylinders for this disk isset to 2610.There is nothing wrong with that, but thisis larger than 1024,and could in certain setups cause problemswith:1) software that runs at boot time (e.g.,old versions of LILO)2) booting and partitioning software fromother OSs(e.g., DOS FDISK, OS/2 FDISK)Command (m for help): n -分区类型Command actione extendedp primary partition (1-4) -还是指定主分区pPartition number (1-4): 1 -分区号,我指定1。Partition 1is already defined. Delete it beforere-adding it.提示分区号1已经存在,删除后操作Command (m for help): n -我们重新创建分区Command actione extendedp primary partition (1-4) -指定分区类型pPartition number (1-4): 2 -因为分区1已经存在,所以我们指定分区2,可通过。First cylinder (1025-2610, default 1025): -指定起始礠柱号,默认是上一分区后一号。Using default value 1025Last cylinder or +size or +sizeM or +sizeK(1025-2610, default 2610): 2000 -指定终止礠柱号。 Command (m for help): w -保存分区配置The partition table has been altered!Calling ioctl() to re-read partition table.WARNING: Re-reading the partition tablefailed with error 16: Device or resource busy.The kernel still uses the old table.The new table will be used at the nextreboot.Syncing disks.rootjetsenLin #通过fdisk命令来来修改现有分区类型Fdisk 通过t参数来指定查看分区类型rootjetsenLin # fdisk -l /dev/sdb 查看分区信息,类型是Linux,id是83Disk /dev/sdb: 21.4 GB, 21474836480 bytes255 heads, 63 sectors/track, 2610 cylindersUnits = cylinders of 16065 * 512 = 8225280bytesDevice Boot Start End Blocks Id System/dev/sdb1 1 1024 8225248+ 83 Linux/dev/sdb2 1025 2000 7839720 83 Linux修改分区类型rootjetsenLin # fdisk /dev/sdbThe number of cylinders for this disk isset to 2610.There is nothing wrong with that, but thisis larger than 1024,and could in certain setups cause problemswith:1) software that runs at boot time (e.g.,old versions of LILO)2) booting and partitioning software fromother OSs(e.g., DOS FDISK, OS/2 FDISK) Command (m for help): t -进入修改分区类型Partition number (1-4): 1 -指定需要修改的分区号Hex code (type L tolist codes): 6 -指定分区号为6,也就是FAT16注意:查看分区类型的代码,在这里可以输入L查看就可以了Changed system type of partition 1 to 6(FAT16)Command (m for help): w -保存The partition table has been altered!Calling ioctl() to re-read partition table.WARNING: Re-reading the partition tablefailed with error 16: Device or resource busy.The kernel still uses the old table.The new table will be used at the nextreboot.WARNING: If you have created or modifiedany DOS 6.xpartitions, please see the fdisk manualpage for additionalinformation.Syncing disks.rootjetsenLin # fdisk -l /dev/sdb -我们看到已经FAT16,并且ID也改成6了。Disk /dev/sdb: 21.4 GB, 21474836480 bytes255 heads, 63 sectors/track, 2610 cylindersUnits = cylinders of 16065 * 512 = 8225280bytesDevice Boot Start End Blocks Id System/dev/sdb1 1 1024 8225248+ 6 FAT16/dev/sdb2 1025 2000 7839720 83 LinuxrootjetsenLin #4、 对分区进行格式化及加载:对分区进行格式化的命令如下等,mkfs后面所接的代表的是将要格式化成的文件系统类型:mkfs.bfs mkfs.ext2mkfs.ext3mkfs.jfsmkfs.msdosmkfs.vfatmkfs.cramfsmkfs.minixmkfs.reiserfsmkfs.xfs格式化分区:rootjetsenLin # mkfs.ext4 /dev/sdb1 -格式化分区类型为ext4mke4fs 1.41.5(23-Apr-2009)Filesystem label= -我们没有指定卷标,就没有OS type: Linux -操作系统类型Block size=4096 (log=2) -单个块的大小Fragment size=4096 (log=2) -片大小1310720 inodes, 5241198blocks262059 blocks (5.00%)reserved for the super userFirst data block=0 Maximum filesystem blocks=0160 block groups32768 blocks per group, 32768fragments per group8192 inodes per groupSuperblock backups stored on blocks:32768, 98304, 163840, 229376, 294912,819200, 884736, 1605632, 2654208,4096000 Writing inode tables:done Creating journal (32768blocks): doneWriting superblocks andfilesystem accounting
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 四川省凉山彝族自治州2026届化学高二上期末经典模拟试题含答案
- GB∕T 24353-2022 《风险管理 指南》之10:“6风险管理过程-6.7记录和报告”专业深度解读和实践应用培训指导材料(2025C1升级版)(可编辑!)
- 民法典解释课件
- 2025年CPA考试会计科目冲刺押题卷含考点预测
- 2025年公共营养师考试冲刺押题专项训练试卷
- 2026届山东枣庄八中高三化学第一学期期末达标检测试题含解析
- 测试工程师的岗位职责是什么
- 岩土面试题目及答案高中
- 智能穿戴行业市场分析报告
- 云南省玉溪市新平一中2026届高三化学第一学期期中经典试题含解析
- 消化科临床重点专科建设项目申报汇报课件
- DLT 671-2010 发电机变压器组保护装置通.用技术条件
- 文物行业操作人员安全培训
- 养老院安全培训课件
- 《数理经济学讲义》课件
- 工程造价咨询服务方案(技术方案)
- 立式气液分离器计算
- 高中休学半年后复学申请书
- 旧变压器移位专项方案
- 订单采购模板
- 幼儿园优质公开课:中班科学《有趣的漩涡》教案
评论
0/150
提交评论