歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux技術 >> linux下磁盤怎麼分區

linux下磁盤怎麼分區

日期:2017/2/28 11:59:59   编辑:Linux技術

  linux分區不同於windows,linux下硬盤設備名為(IDE硬盤為hdx(x為從a—d)因為IDE硬盤最多四個,SCSI,SATA,USB硬盤為sdx(x為a—z)),硬盤主分區最多為4個,不用說大家也知道,那麼linux下磁盤怎麼分區?小編為大家分享了linux下磁盤分區的方法,下面大家跟著學習啦小編一起來了解一下吧。

  linux下磁盤分區方法

  先用fdisk分區,分區完成後再用mkfs格式化並創建文件系統,掛載,磁盤就能使用啦。

  分區的原理:

  MBR:主引導扇區

  主分區表:64bytes,最多只能分四個主分區,每個主分區的記錄(相關信息,比如分區大小,位置)在主分區表裡占14bytes。

  如果要建多於四個的分區,就要拿出一個主分區做為擴展分區,再在擴展分區裡面進行其它的分區操作。在 建擴展分區的時候會建立一張對應的擴展分區表,它記錄了在這個擴展分區裡的分區的相關信息;理論上它沒有分區數量的限制,在擴展分區內部的分區叫做邏輯分區,如上圖中的 /dev/hda5,/dev/hda6/,/dev/hda7

  格式化原理:

  在分好區後,分區裡面是空的,沒有任何東西。為了能讓OS識別,就必須要向分區裡寫入相應格式的數據。比如windows的FAT32,NTFS;Linux的ext2,ext3,ext4(目前ext3格式的用的比較多,ext4還在實驗之中,在新的Fedora上使用的就是ext4的文件系統)。

  Windows/dos常用的分區工具:fdisk/partition magic/diskpart

  Linux下常用的分區工具:

  fdisk/sfdisk:命令行工具,各種版本和環境都能使用,包含在軟件包util-linux中

  diskdruid:圖形化分區工具,只能在安裝REDHAT系統時使用。

  下面我們開始實驗:

  環境/工具:Fedora 14/256M內存卡;fdisk

  第一步:fdisk

  [root@novice ~]# fdisk -l /dev/sdb

  Disk /dev/sdb: 254 MB, 254017536 bytes

  8 heads, 61 sectors/track, 1016 cylinders, total 496128 sectors

  Units = sectors of 1 * 512 = 512 bytes

  Sector size (logical/physical): 512 bytes / 512 bytes

  I/O size (minimum/optimal): 512 bytes / 512 bytes

  Disk identifier: 0x00000000

  Device Boot Start End Blocks Id System

  [root@novice ~]# fdisk /dev/sdb

  Command (m for help): #在輸入上面的命令後會出現左邊的提示,輸入m就會得到一個幫助菜單,如下:

  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

  l list known partition types

  m print this menu

  n add a new partition

  o create a new empty DOS partition table

  p print the partition table

  q quit without saving changes

  s create a new empty Sun disklabel

  t change a partition's system id

  u change display/entry units

  v verify the partition table

  w write table to disk and exit

  x extra functionality (experts only)

  #help雖然是英文的,可都很簡單,在這裡不再解釋。

  #現在,我們正式開始分區的操作:

  Command (m for help): n #新建分區

  Command action

  e extended

  p primary partition (1-4)

  #e/p分別對應擴展分區 /主分區;我們先分四個主分區,每個50M;然後再來增加主分區或擴展分區,看會出現怎樣的狀況,嘿嘿。

Copyright © Linux教程網 All Rights Reserved