华南俳烁实业有限公司

考試首頁 | 考試用書 | 培訓課程 | 模擬考場 | 考試論壇  
  當前位置:Linux認證 > 綜合輔導 > 文章內(nèi)容
  

linux從入門到精通(21)

 [ 2016年6月21日 ] 【

規(guī)劃硬盤中的分區(qū)——fdisk

  fdisk [磁盤設(shè)備]

  使用此命令可進入交互操縱,您可以在下面的交互操縱里面胡作非為,但是切記離開時必須按q命令,不能按w

#找出系統(tǒng)中所在根目錄所在磁盤,并查閱該硬盤內(nèi)的相關(guān)信息
[root@localhost ~]# df / <==重點找出磁盤文件名而已 文件系統(tǒng) 1K-塊 已用 可用 已用% 掛載點 /dev/hda2 9920624 2968604 6439952 32% / [root@localhost ~]# fdisk /dev/hda ==>進入交互操縱模式,注意這里不要寫具體的數(shù)字 The number of cylinders for this disk is set to 2610. 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) Command (m for help): m <==等待輸入,m是命令菜單 Command action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition ==>刪除一個分區(qū) l list known partition types ==>創(chuàng)建邏輯分區(qū) m print this menu n add a new partition ==>增加一個分區(qū) o create a new empty DOS partition table p print the partition table ==>在屏幕上顯示分區(qū)表 q quit without saving changes ==>不存儲,直接離開fdisk程序 s create a new empty Sun disklabel t change a partition's system id 變更分區(qū)類型 u change display/entry units v verify the partition table w write table to disk and exit ==>將剛才的操作寫入分區(qū)表,慎重操作 x extra functionality (experts only)

  常見操作有:創(chuàng)建主分區(qū)、創(chuàng)建擴展分區(qū)(將硬盤的所有剩余空間作為擴展分區(qū))、創(chuàng)建邏輯分區(qū)、改變分區(qū)的系統(tǒng)代碼、保存分區(qū)表信息、用partprobe探測硬盤分區(qū)變化

 下面舉出幾例做測試,離開時不保存:

 Command (m for help): p  ==>查看磁盤分區(qū)表,和終端命令模式下的fdisk -l 作用相同

Disk /dev/hda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1   *           1          13      104391   83  Linux
/dev/hda2              14        1288    10241437+  83  Linux
/dev/hda3            1289        1925     5116702+  83  Linux
/dev/hda4            1926        2610     5502262+   5  Extended
/dev/hda5            1926        1989      514048+  82  Linux swap / Solaris

Command (m for help): d  
Partition number (1-5): 4   ==>刪除第4個分區(qū)

Command (m for help): d    ==>刪除第3個分區(qū)
Partition number (1-4): 3

Command (m for help): p  ==>再次顯示時觀察下面只顯示了前兩個分區(qū),第5個沒顯示

Disk /dev/hda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1   *           1          13      104391   83  Linux
/dev/hda2              14        1288    10241437+  83  Linux

Command (m for help): n  ==>創(chuàng)建一個分區(qū)
Command action
   e   extended
   p   primary partition (1-4)
p  ==>選擇創(chuàng)建的分區(qū)類型為主分區(qū)
Partition number (1-4): 4 ==>選擇4號做主分區(qū)
First cylinder (1289-2610, default 1289): 
Using default value 1289   ==>起始柱面若直接按enter鍵就是使用默認值
Last cylinder or +size or +sizeM or +sizeK (1289-2610, default 2610): +512M

Command (m for help): p  ==>再次查看分區(qū)表,發(fā)現(xiàn)多了一個剛從建立的分區(qū)4

Disk /dev/hda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1   *           1          13      104391   83  Linux
/dev/hda2              14        1288    10241437+  83  Linux
/dev/hda4            1289        1351      506047+  83  Linux

Command (m for help): n  ==>再建一個分區(qū)
Command action
   e   extended
   p   primary partition (1-4)
e   ==>建立擴展分區(qū)
Selected partition 3  ==>這個是系統(tǒng)主動選擇的分區(qū)
First cylinder (1352-2610, default 1352): 
Using default value 1352
Last cylinder or +size or +sizeM or +sizeK (1352-2610, default 2610): 
Using default value 2610

Command (m for help): p

Disk /dev/hda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1   *           1          13      104391   83  Linux
/dev/hda2              14        1288    10241437+  83  Linux
/dev/hda3            1352        2610    10112917+   5  Extended  ==>看,剛新建的擴展分區(qū)
/dev/hda4            1289        1351      506047+  83  Linux

Partition table entries are not in disk order

Command (m for help): n  ==>再多建幾個分區(qū)玩玩,反正后面不保存就行了,,呵呵
First cylinder (1352-2610, default 1352): 
Using default value 1352
Last cylinder or +size or +sizeM or +sizeK (1352-2610, default 2610): +2084
Value out of range.
Last cylinder or +size or +sizeM or +sizeK (1352-2610, default 2610): +2084M

Command (m for help): n   ==>有沒有發(fā)現(xiàn),最后建立2個分區(qū)的時候根本沒有詢問我們要建立是主分區(qū)還是擴展分區(qū),為啥?因為分區(qū)已經(jīng)超過4了,您別無選擇,只能是擴展分區(qū)了。。。
First cylinder (1606-2610, default 1606): 
Using default value 1606
Last cylinder or +size or +sizeM or +sizeK (1606-2610, default 2610): 
Using default value 2610

Command (m for help): p

Disk /dev/hda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1   *           1          13      104391   83  Linux
/dev/hda2              14        1288    10241437+  83  Linux
/dev/hda3            1352        2610    10112917+   5  Extended
/dev/hda4            1289        1351      506047+  83  Linux
/dev/hda5            1352        1605     2040223+  83  Linux  ==>這是后面又新建的2個分區(qū)
/dev/hda6            1606        2610     8072631   83  Linux

Partition table entries are not in disk order

Command (m for help): q  ==>這里一定要按q啊,因為我剛才僅僅是演示操作,還破壞性的刪除了2個分區(qū),你要是真要分區(qū),那就要按w保存了。

[root@localhost ~]# 
首頁 1 2 尾頁
本文糾錯】【告訴好友】【打印此文】【返回頂部
將考試網(wǎng)添加到收藏夾 | 每次上網(wǎng)自動訪問考試網(wǎng) | 復制本頁地址,傳給QQ/MSN上的好友 | 申請鏈接 | 意見留言 TOP
關(guān)于本站  網(wǎng)站聲明  廣告服務(wù)  聯(lián)系方式  站內(nèi)導航  考試論壇
Copyright © 2007-2013 中華考試網(wǎng)(Examw.com) All Rights Reserved
河津市| 烟台市| 承德县| 峡江县| 慈利县| 鄱阳县| 重庆市| 乌拉特中旗| 东宁县| 夏河县| 五莲县| 呼和浩特市| 洛浦县| 襄城县| 德令哈市| 中江县| 临城县| 榕江县| 渝北区| 长白| 长岛县| 九龙坡区| 宁明县| 清镇市| 凤庆县| 敦煌市| 哈巴河县| 九龙坡区| 赤壁市| 江源县| 台东市| 宿州市| 喀喇| 甘德县| 始兴县| 南城县| 贵德县| 明光市| 方城县| 霍城县| 二连浩特市|