Latest web development tutorials

Linux fdisk命令

Linux 命令大全 Linux命令大全

Linux fdisk是一個創建和維護分區表的程序,它兼容DOS類型的分區表、BSD或者SUN類型的磁盤列表。

語法

fdisk [必要参数][选择参数]

必要參數:

  • -l 列出素所有分區表
  • -u 與"-l"搭配使用,顯示分區數目

選擇參數:

  • -s<分區編號> 指定分區
  • -v 版本信息

菜單操作說明

  • m :顯示菜單和幫助信息
  • a :活動分區標記/引導分區
  • d :刪除分區
  • l :顯示分區類型
  • n :新建分區
  • p :顯示分區信息
  • q :退出不保存
  • t :設置分區號
  • v :進行分區檢查
  • w :保存修改
  • x :擴展應用,高級功能

實例

顯示當前分區情況:

# fdisk -l

Disk /dev/sda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

  Device Boot   Start     End   Blocks  Id System
/dev/sda1  *      1     13   104391  83 Linux
/dev/sda2       14    1305  10377990  8e Linux LVM

Disk /dev/sdb: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdb doesn't contain a valid partition table

顯示SCSI硬盤的每個分區情況

# fdisk -lu  

Disk /dev/sda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders, total 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes

  Device Boot   Start     End   Blocks  Id System
/dev/sda1  *     63   208844   104391  83 Linux
/dev/sda2     208845  20964824  10377990  8e Linux LVM

Disk /dev/sdb: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders, total 10485760 sectors
Units = sectors of 1 * 512 = 512 bytes

Disk /dev/sdb doesn't contain a valid partition table

Linux 命令大全 Linux命令大全