国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

開通VIP
實例解說Linux中fdisk分區(qū)使用方法

一、fdisk 的介紹;

  fdisk - Partition table manipulator for Linux ,譯成中文的意思是磁盤分區(qū)表操作工具;本人譯的不太好,也沒有看中文文檔;其實就是分區(qū)工具;

  fdsik 能劃分磁盤成為若干個區(qū),同時也能為每個分區(qū)指定分區(qū)的文件系統(tǒng),比如linux 、fat32、 linux 、linuxswap 、fat16 以及其實類Unix類操作系統(tǒng)的文件系統(tǒng)等;當然我們用fdisk對磁盤操作分區(qū)時,并不是一個終點,我們還要對分區(qū)進行格式化所需要的文件系統(tǒng);這樣一個分區(qū)才能使用;這和DOS中的fdisk 是類似的;

  二、合理規(guī)劃您的硬盤分區(qū);

  在操作分區(qū)之前,我們要明白硬盤分區(qū)一點理論,比如硬盤容量和分區(qū)大小的計算;對一個硬盤如何規(guī)劃分區(qū)等,請參考如下文檔,謝謝;

  《合理規(guī)劃您的硬盤分區(qū)》

  三、fdisk -l 查看硬盤及分區(qū)信息;

  通過《合理規(guī)劃您的硬盤分區(qū)》 ,我們知道主分區(qū)(包括擴展分區(qū))的總個數(shù)不能超過四個;也不能把擴展分區(qū)包圍在主分區(qū)之間;根據(jù)這個原則,我們劃分硬盤分區(qū)就比較容易的多;也能為以后減少不必要的麻煩;

  1、通過fdisk -l 查看機器所掛硬盤個數(shù)及分區(qū)情況;

[root@localhost beinan]# fdisk -l
Disk /dev/hda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot Start End Blocks Id System
/dev/hda1 * 1 765 6144831 7 HPFS/NTFS
/dev/hda2 766 2805 16386300 c W95 FAT32 (LBA)
/dev/hda3 2806 9729 55617030 5 Extended
/dev/hda5 2806 3825 8193118+ 83 Linux
/dev/hda6 3826 5100 10241406 83 Linux
/dev/hda7 5101 5198 787153+ 82 Linux swap / Solaris
/dev/hda8 5199 6657 11719386 83 Linux
/dev/hda9 6658 7751 8787523+ 83 Linux
/dev/hda10 7752 9729 15888253+ 83 Linux
Disk /dev/sda: 1035 MB, 1035730944 bytes
256 heads, 63 sectors/track, 125 cylinders
Units = cylinders of 16128 * 512 = 8257536 bytes
   Device Boot Start End Blocks Id System
/dev/sda1 1 25 201568+ c W95 FAT32 (LBA)
/dev/sda2 26 125 806400 5 Extended
/dev/sda5 26 50 201568+ 83 Linux
/dev/sda6 51 76 200781 83 Linux

  通過上面的信息,我們知道此機器中掛載兩個硬盤(或移動硬盤),其中一個是hda 另一個是sda ;如果我們想查看單個硬盤情況,可以通過fdisk -l /dev/hda1 或者fdisk -l /dev/sda1 來操作;以fdisk -l 輸出的硬盤標識為準;

  其中 hda有三個主分區(qū)(包括擴展分區(qū)),分別是主分區(qū) hda1 hda2 和hda3(擴展分區(qū)) ;邏輯分區(qū)是 hda5到hda10;

  其中 sda 有兩個主分區(qū)(包括擴展分區(qū)),分別是 hda1 和hda2 (擴展分區(qū));邏輯分區(qū)是 sda5 hda6 ;

  硬盤總?cè)萘?主分區(qū)(包括擴展分區(qū))總?cè)萘?/p>

  擴展分區(qū)容量=邏輯分區(qū)總?cè)萘?/p>

  通過上面的例子,我們可以得知 hda=hda1+hda2+hda3,其中hda3=hda5+hda6+hda7+hda8+hda9+hda10 …… ……

  2、關于fdisk -l 一些數(shù)值的說明;

Disk /dev/hda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

  這個硬盤是80G的,有255個磁面;63個扇區(qū);9729個磁柱;每個 cylinder(磁柱)的容量是 8225280 bytes=8225.280 K(約為)=8.225280M(約為);

分區(qū)序列 引導 開始 終止 容量 分區(qū)類型ID 分區(qū)類型
Device Boot Start End Blocks Id System
/dev/hda1 * 1 765 6144831 7 HPFS/NTFS
/dev/hda2 766 2805 16386300 c W95 FAT32 (LBA)
/dev/hda3 2806 9729 55617030 5 Extended
/dev/hda5 2806 3825 8193118+ 83 Linux
/dev/hda6 3826 5100 10241406 83 Linux
/dev/hda7 5101 5198 787153+ 82 Linux swap / Solaris
/dev/hda8 5199 6657 11719386 83 Linux
/dev/hda9 6658 7751 8787523+ 83 Linux
/dev/hda10 7752 9729 15888253+ 83 Linux

  說明:

  硬盤分區(qū)的表示:在Linux 是通過hd*x 或 sd*x 表示的,其中 * 表示的是a、b、c …… …… x表示的數(shù)字 1、2、3 …… …… hd大多是IDE硬盤;sd大多是SCSI或移動存儲;

  引導(Boot):表示引導分區(qū),在上面的例子中 hda1 是引導分區(qū);

  Start (開始):表示的一個分區(qū)從X cylinder(磁柱)開始;

  End (結(jié)束):表示一個分區(qū)到 Y cylinder(磁柱)結(jié)束;

  id和System 表示的是一個意思,id看起來不太直觀,我們要在fdisk 一個分區(qū)時,通過指定id來確認分區(qū)類型;比如 7表示的就NTFS 分區(qū);這個在fdisk 中要通過t功能來指定。下面的部份會提到;

  Blocks(容量):這是我翻譯的,其實不準確,表示的意思的確是容量的意思,其單位是K;一個分區(qū)容量的值是由下面的公式而來的;

  Blocks = (相應分區(qū)End數(shù)值 - 相應分區(qū)Start數(shù)值)x 單位cylinder(磁柱)的容量

  所以我們算一下 hda1的 Blocks 的大小 :

  hda1 Blocks=(765-1)x8225.280=6284113.92 K = 6284.113.92M

  注:換算單位以硬盤廠家提供的10進位算起,如果以操作系統(tǒng)二進制來算,這個分區(qū)容量應該更少一些,得出的這個值和我們通過 fdisk-l 看到的/dev/hda1的值是大體相當?shù)模驗閾Q算方法不一樣,所以也不可能盡可能的精確;再加上分區(qū)時的一點損失之類,有時或大或小是存在的;

  我們查看分區(qū)大小或者文件的時候,還是用十進制來計算比較直觀;推算辦法是 byte 向前推小數(shù)點三位就是K ,K單位的值向前推小數(shù)點三位就是M,M向前推小數(shù)點三位就是G…… …… 一般也差不了多少;這么算就行;

  3、估算一個存儲設備是否被完全劃分;

  我們估算一個硬盤是否完全被劃分,我們只要看 fdisk -l 輸出的內(nèi)容中的 cylinders(柱體) 上一個分區(qū)的End 和下一個分區(qū)的Start是不是一個連續(xù)的數(shù)字,另外要看一下每個硬盤設備的fdisk -l 的開頭部份,看一下他的 cylinders(柱體)的值;

  比如hda設備,我們看到的是 9729 cylinders ;我們通過 hda的分區(qū)表可以看到上一個分區(qū)的End的值+1就是下一個分區(qū)的Start 的值;比如 hda2的Start的值是 hda1 的End 的值+1,這證明 hda1 和hda2中間沒有空白分區(qū),是連續(xù)的,以此類推;在 hda10,我們看到 End 的值是9729 ,而在fdisk -l頭部信息中也有9729cylinders,證明這個硬盤已經(jīng)完全劃分;

Disk /dev/sda: 1035 MB, 1035730944 bytes
256 heads, 63 sectors/track, 125 cylinders
Units = cylinders of 16128 * 512 = 8257536 bytes
   Device Boot Start End Blocks Id System
/dev/sda1 1 25 201568+ c W95 FAT32 (LBA)
/dev/sda2 26 125 806400 5 Extended
/dev/sda5 26 50 201568+ 83 Linux
/dev/sda6 51 76 200781 83 Linux

  我們再看看 sda 移動儲是不是被完全劃分了;sda有 125個cylinders(柱體),有一個主分區(qū)和一個擴展分區(qū)構(gòu)成;在擴展分區(qū)中,我們看到End的值為125,而這個移動硬盤的cylinder也是125,這能說明這個硬盤不可能再添加任何主分區(qū)了;根據(jù)我們上面所說的 sda1 sda2 sda5 sda6 之間未有任何未劃分空間,但sda6 的cylinders(柱體)的End值卻是 76 ,而 sda總的cylinders (柱體)有125個,由此看來sda 在 sda6后面有未劃分區(qū)域;

  至于sda 有多少未劃分空間,我們算一下就知道了;擴展分區(qū)總?cè)萘渴?806400 K ,大約是 806.400M左右,而邏輯分區(qū) sda5 和sda6 的大小加起來是 400M左右,所以還仍有400M左右未劃分空間,并且只能劃分為鏈邏輯分區(qū);

  四、fdisk 對硬盤及分區(qū)的操作,進入fdisk 對硬盤操作階段;

  我們可以對硬盤進行分區(qū)操作,前提是您把fdisk -l 弄明白了;通過fdisk -l ,我們能找出機器中所有硬盤個數(shù)及設備名稱;比如上面的例子,我們會看到兩個設備一個是/dev/hda ,另一個是/dev/sda ;

  fdisk 操作硬盤的命令格式如下:

  [root@localhost beinan]# fdisk 設備

  比如我們通過 fdisk -l 得知 /dev/hda 或者 /dev/sda設備;我們?nèi)绻朐偬砑踊蛘邉h除一些分區(qū),可以用

  [root@localhost beinan]# fdisk /dev/hda

  或

  [root@localhost beinan]# fdisk /dev/sda

  注 在以后的例子中,我們要以 /dev/sda設備為例,來講解如何用fdisk 來操作添加、刪除分區(qū)等動作;

  1、fdisk 的說明;

  當我們通過 fdisk 設備,進入相應設備的操作時,會發(fā)現(xiàn)有如下的提示;以 fdisk /dev/sda 設備為例,以下同;

[root@localhost beinan]# fdisk /dev/sda
Command (m for help): 在這里按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 注:l是列出分區(qū)類型,以供我們設置相應分區(qū)的類型;
   m print this menu 注:m 是列出幫助信息;
   n add a new partition 注:添加一個分區(qū);
   o create a new empty DOS partition table
   p print the partition table 注:p列出分區(qū)表;
   q quit without saving changes 注:不保存退出;
   s create a new empty Sun disklabel
   t change a partition‘s system id 注:t 改變分區(qū)類型;
   u change display/entry units
   v verify the partition table
   w write table to disk and exit 注:把分區(qū)表寫入硬盤并退出;
   x extra functionality (experts only) 注:擴展應用,專家功能;

  其實我們常用的只有注有中文的,其它的功能我們不常用(呵,主要是我不會用,否則早會賣弄一下了);x擴展功能,也不是常用的;一般的情況下只要懂得 d l m p q t w 就行了;

  下面以實例操作來詳述,沒有例子沒有辦法就,新手也看不懂;

  2、列出當前操作硬盤的分區(qū)情況,用p;

Command (m for help): p
Disk /dev/sda: 1035 MB, 1035730944 bytes
256 heads, 63 sectors/track, 125 cylinders
Units = cylinders of 16128 * 512 = 8257536 bytes
   Device Boot Start End Blocks Id System
/dev/sda1 1 25 201568+ c W95 FAT32 (LBA)
/dev/sda2 26 125 806400 5 Extended
/dev/sda5 26 50 201568+ 83 Linux
/dev/sda6 51 76 200781 83 Linux

  3、通過fdisk的d指令來刪除一個分區(qū);

Command (m for help): p 注:列出分區(qū)情況;
Disk /dev/sda: 1035 MB, 1035730944 bytes
256 heads, 63 sectors/track, 125 cylinders
Units = cylinders of 16128 * 512 = 8257536 bytes
   Device Boot Start End Blocks Id System
/dev/sda1 1 25 201568+ c W95 FAT32 (LBA)
/dev/sda2 26 125 806400 5 Extended
/dev/sda5 26 50 201568+ 83 Linux
/dev/sda6 51 76 200781 83 Linux
Command (m for help): d 注:執(zhí)行刪除分區(qū)指定;
Partition number (1-6): 6 注:我想刪除 sda6 ,就在這里輸入 6 ;
Command (m for help): p 注:再查看一下硬盤分區(qū)情況,看是否刪除了?
Disk /dev/sda: 1035 MB, 1035730944 bytes
256 heads, 63 sectors/track, 125 cylinders
Units = cylinders of 16128 * 512 = 8257536 bytes
   Device Boot Start End Blocks Id System
/dev/sda1 1 25 201568+ c W95 FAT32 (LBA)
/dev/sda2 26 125 806400 5 Extended
/dev/sda5 26 50 201568+ 83 Linux
Command (m for help):

  警告:刪除分區(qū)時要小心,請看好分區(qū)的序號,如果您刪除了擴展分區(qū),擴展分區(qū)之下的邏輯分區(qū)都會刪除;所以操作時一定要小心;如果知道自己操作錯了,請不要驚慌,用q不保存退出;切記切記?。。?!在分區(qū)操作錯了之時,千萬不要輸入w保存退出?。?!

  4、通過fdisk的n指令增加一個分區(qū);

Command (m for help): p
Disk /dev/sda: 1035 MB, 1035730944 bytes
256 heads, 63 sectors/track, 125 cylinders
Units = cylinders of 16128 * 512 = 8257536 bytes
   Device Boot Start End Blocks Id System
/dev/sda1 1 25 201568+ c W95 FAT32 (LBA)
/dev/sda2 26 125 806400 5 Extended
/dev/sda5 26 50 201568+ 83 Linux
Command (m for help): n 注:增加一個分區(qū);
Command action
   l logical (5 or over) 注:增加邏輯分區(qū),分區(qū)編號要大于5;為什么要大于5,因為已經(jīng)有sda5了;
   p primary partition (1-4) 注:增加一個主分區(qū);編號從 1-4 ;但sda1 和sda2都被占用,所以只能從3開始;
p
Partition number (1-4): 3
No free sectors available 注:失敗中,為什么失???

  注:我試圖增加一個主分區(qū),看來是失敗了,為什么失???因為我們看到主分區(qū)+擴展分區(qū)把整個磁盤都用光了,看擴展分區(qū)的End的值,再看一下 p輸出信息中有125 cylinders;最好還是看前面部份;那里有提到;

  所以我們只能增加邏輯分區(qū)了;

 Command (m for help): n
Command action
   l logical (5 or over)
   p primary partition (1-4)
l 注:在這里輸入l,就進入劃分邏輯分區(qū)階段了;
First cylinder (51-125, default 51): 注:這個就是分區(qū)的Start 值;這里最好直接按回車,如果您輸入了一個非默認的數(shù)字,會造成空間浪費;
Using default value 51
Lastcylinder or +size or +sizeM or +sizeK (51-125, default 125): +200M注:這個是定義分區(qū)大小的,+200M 就是大小為200M ;當然您也可以根據(jù)p提示的單位cylinder的大小來算,然后來指定End的數(shù)值?;仡^看看是怎么算的;還是用+200M這個辦法來添加,這樣能直觀一點。如果您想添加一個10G左右大小的分區(qū),請輸入 +10000M;
Command (m for help):

  5、通過fdisk的t指令指定分區(qū)類型;

Command (m for help): t 注:通過t來指定分區(qū)類型;
Partition number (1-6): 6 注:要改變哪個分區(qū)類型呢?我指定了6,其實也就是sda6
Hex code (type L to list codes):L 注:在這里輸入L,就可以查看分區(qū)類型的id了;
Hex code (type L to list codes): b 注:如果我想讓這個分區(qū)是 W95 FAT32 類型的,通過L查看得知 b是表示的是,所以輸入了b;
Changed system type of partition 6 to b (W95 FAT32) 注:系統(tǒng)信息,改變成功;是否是改變了,請用p查看;
Command (m for help): p
Disk /dev/sda: 1035 MB, 1035730944 bytes
256 heads, 63 sectors/track, 125 cylinders
Units = cylinders of 16128 * 512 = 8257536 bytes
   Device Boot Start End Blocks Id System
/dev/sda1 1 25 201568+ c W95 FAT32 (LBA)
/dev/sda2 26 125 806400 5 Extended
/dev/sda5 26 50 201568+ 83 Linux
/dev/sda6 51 75 201568+ b W95 FAT32

  6、fdisk 的退出,用q或者 w;

  其中 q是 不保存退出,w是保存退出;

  Command (m for help): w
  或
  Command (m for help): q

  7、一個添加分區(qū)的例子;

  本例中我們會添加兩個200M的主分區(qū),其它為擴展分區(qū),在擴展分區(qū)中我們添加兩個200M大小的邏輯分區(qū);

Command (m for help): p 注:列出分區(qū)表;
Disk /dev/sda: 1035 MB, 1035730944 bytes
256 heads, 63 sectors/track, 125 cylinders
Units = cylinders of 16128 * 512 = 8257536 bytes
   Device Boot Start End Blocks Id System
Command (m for help): n 注:添加分區(qū);
Command action
   e extended
   p primary partition (1-4)
p 注:添加主分區(qū);
Partition number (1-4): 1 注:添加主分區(qū)1;
First cylinder (1-125, default 1): 注:直接回車,主分區(qū)1的起始位置;默認為1,默認就好;
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-125, default 125): +200M 注:指定分區(qū)大小,用+200M來指定大小為200M
Command (m for help): n 注:添加新分區(qū);
Command action
   e extended
   p primary partition (1-4)
p 注:添加主分區(qū)
Partition number (1-4): 2 注:添加主分區(qū)2;
First cylinder (26-125, default 26):
Using default value 26
Last cylinder or +size or +sizeM or +sizeK (26-125, default 125): +200M 注:指定分區(qū)大小,用+200M來指定大小為200M
Command (m for help): n
Command action
   e extended
   p primary partition (1-4)
e 注:添加擴展分區(qū);
Partition number (1-4): 3 注:指定為3 ,因為主分區(qū)已經(jīng)分了兩個了,這個也算主分區(qū),從3開始;
First cylinder (51-125, default 51): 注:直接回車;
Using default value 51
Last cylinder or +size or +sizeM or +sizeK (51-125, default 125): 注:直接回車,把其余的所有空間都給擴展分區(qū);
Using default value 125
Command (m for help): p
Disk /dev/sda: 1035 MB, 1035730944 bytes
256 heads, 63 sectors/track, 125 cylinders
Units = cylinders of 16128 * 512 = 8257536 bytes
   Device Boot Start End Blocks Id System
/dev/sda1 1 25 201568+ 83 Linux
/dev/sda2 26 50 201600 83 Linux
/dev/sda3 51 125 604800 5 Extended
Command (m for help): n
Command action
   l logical (5 or over)
   p primary partition (1-4)
l 注:添加邏輯分區(qū);
First cylinder (51-125, default 51):
Using default value 51
Last cylinder or +size or +sizeM or +sizeK (51-125, default 125): +200M 注:添加一個大小為200M大小的分區(qū);
Command (m for help): n
Command action
   l logical (5 or over)
   p primary partition (1-4)
l 注:添加一個邏輯分區(qū);
First cylinder (76-125, default 76):
Using default value 76
Last cylinder or +size or +sizeM or +sizeK (76-125, default 125): +200M 注:添加一個大小為200M大小的分區(qū);
Command (m for help): p 列出分區(qū)表;
Disk /dev/sda: 1035 MB, 1035730944 bytes
256 heads, 63 sectors/track, 125 cylinders
Units = cylinders of 16128 * 512 = 8257536 bytes
   Device Boot Start End Blocks Id System
/dev/sda1 1 25 201568+ 83 Linux
/dev/sda2 26 50 201600 83 Linux
/dev/sda3 51 125 604800 5 Extended
/dev/sda5 51 75 201568+ 83 Linux
/dev/sda6 76 100 201568+ 83 Linux

  然后我們根據(jù)前面所說通過t指令來改變分區(qū)類型;

  最后不要忘記w保存退出;

  五、對分區(qū)進行格式化,以及加載;

  先提示一下;用 mkfs.bfs mkfs.ext2 mkfs.jfs mkfs.msdosmkfs.vfatmkfs.cramfs mkfs.ext3 mkfs.minix mkfs.reiserfs mkfs.xfs等命令來格式化分區(qū),比如我想格式化 sda6為ext3文件系統(tǒng),則輸入;

  [root@localhost beinan]# mkfs.ext3 /dev/sda6

  如果我想加載 sda6到目前系統(tǒng)來存取文件,應該有mount 命令,但首先您得建一個掛載目錄;比如 /mnt/sda6 ;

[root@localhost beinan]# mkdir /mnt/sda6
[root@localhost beinan]# mount /dev/sda6 /mnt/sda6
[root@localhost beinan]# df -lh
Filesystem 容量 已用 可用 已用% 掛載點
/dev/hda8 11G 8.4G 2.0G 81% /
/dev/shm 236M 0 236M 0% /dev/shm
/dev/hda10 16G 6.9G 8.3G 46% /mnt/hda10
/dev/sda6 191M 5.6M 176M 4% /mnt/sda6

  這樣我們就能進入 /mnt/sda6目錄,然后存取文件了;

  具體的權限方法,以及mount 更詳細的用法,在以后我會專門寫一個帖子;在一帖中放下所有的內(nèi)容實在有點為難;

  參考資料:

  《合理規(guī)劃您的硬盤分區(qū)》

本站僅提供存儲服務,所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權內(nèi)容,請點擊舉報
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
linux fdisk命令使用
Linux磁盤系統(tǒng)基礎知識
Linux fdisk命令 | 菜鳥教程
添加swap交換分區(qū)容量
在Linux系統(tǒng)中存儲設備的兩種表示方法 | LinuxSir.Org
Linux 分區(qū)大小調(diào)整完全手冊
更多類似文章 >>
生活服務
分享 收藏 導長圖 關注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!

聯(lián)系客服