华南俳烁实业有限公司

考試首頁 | 考試用書 | 培訓課程 | 模擬考場 | 考試論壇  
  當前位置:操作系統(tǒng) > Linux > 文章內容
  

Linux操作系統(tǒng)學習筆記管理磁盤和文件系統(tǒng)(2)

 [ 2016年6月16日 ] 【

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

  fdisk [磁盤設備]

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

#找出系統(tǒng)中所在根目錄所在磁盤,并查閱該硬盤內的相關信息
[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
關于本站  網(wǎng)站聲明  廣告服務  聯(lián)系方式  站內導航  考試論壇
Copyright © 2007-2013 中華考試網(wǎng)(Examw.com) All Rights Reserved
永登县| 兴山县| 濉溪县| 明水县| 信阳市| 洛扎县| 阿坝| 葫芦岛市| 韶山市| 姜堰市| 积石山| 阿拉善盟| 喜德县| 丹棱县| 嘉鱼县| 肥东县| 西城区| 盐津县| 苍南县| 刚察县| 建始县| 贞丰县| 辽源市| 汉源县| 阆中市| 疏勒县| 沈阳市| 姜堰市| 乌拉特后旗| 贺州市| 全南县| 祁门县| 南京市| 瑞昌市| 厦门市| 乌鲁木齐市| 临沧市| 青岛市| 苗栗市| 盖州市| 聊城市|