欢迎光临
我们一直在努力

fdisk 磁盘分区命令

fdisk 是一个维护分区表的程序,兼容DOS,BSD,SUN类型的磁盘列表

使用方法

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

必要参数

  • -l 列出所有分区表
  • -u 与”-l”搭配使用,显示分区数
fdisk -l    #列出所有分区表
Disk /dev/loop0: 166.4 MiB, 174522368 bytes, 340864 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 /dev/sda: 465.8 GiB, 500107862016 bytes, 976773168 sectors
Disk model: ST500DM002-1BD14
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x5f5df0e2

Device Boot Start End Sectors Size Id Type
/dev/sda1 * 512 33279 32768 16M 83 Linux
/dev/sda2 33792 492543 458752 224M 83 Linux
/dev/sda3 493568 976773167 976279600 465.5G 83 Linux
fdisk -lu
Disk /dev/loop0: 166.4 MiB, 174522368 bytes, 340864 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 /dev/sda: 465.8 GiB, 500107862016 bytes, 976773168 sectors
Disk model: ST500DM002-1BD14
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x5f5df0e2

Device Boot Start End Sectors Size Id Type
/dev/sda1 * 512 33279 32768 16M 83 Linux
/dev/sda2 33792 492543 458752 224M 83 Linux
/dev/sda3 493568 976773167 976279600 465.5G 83 Linux

选择参数

  • -s <分区参数>指定分区
  • -v 版本信息

菜单操作说明

  • m :显示菜单和帮助信息
  • a :活动分区标记/引导分区
  • d :删除分区
  • l :显示分区类型
  • n :新建分区
  • p :显示分区信息
  • q :退出不保存
  • t :设置分区号
  • v :进行分区检查
  • w :保存修改
  • x :扩展应用,高级功能
fdisk /dev/sda    #操作sda磁盘

Welcome to fdisk (util-linux 2.33).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help):
Command (m for help): m    #显示菜单及帮助信息

Help:

DOS (MBR)
a toggle a bootable flag
b edit nested BSD disklabel
c toggle the dos compatibility flag

Generic
d delete a partition
F list free unpartitioned space
l list known partition types
n add a new partition
p print the partition table
t change a partition type
v verify the partition table
i print information about a partition

Misc
m print this menu
u change display/entry units
x extra functionality (experts only)

Script
I load disk layout from sfdisk script file
O dump disk layout to sfdisk script file

Save & Exit
w write table to disk and exit
q quit without saving changes

Create a new label
g create a new empty GPT partition table
G create a new empty SGI (IRIX) partition table
o create a new empty DOS partition table
s create a new empty Sun partition table


Command (m for help):
Command (m for help): a    #活动分区标记/引导分区
Partition number (1-3, default 3): 1

The bootable flag on partition 1 is disabled now.

Command (m for help):
Command (m for help): d    #删除分区
Partition number (1-3, default 3): 3    #输入需要删除分区的序号

Partition 3 has been deleted.

Command (m for help):
Command (m for help): l    #显示分区类型

0 Empty 24 NEC DOS 81 Minix / old Lin bf Solaris 
1 FAT12 27 Hidden NTFS Win 82 Linux swap / So c1 DRDOS/sec (FAT-
2 XENIX root 39 Plan 9 83 Linux c4 DRDOS/sec (FAT-
3 XENIX usr 3c PartitionMagic 84 OS/2 hidden or c6 DRDOS/sec (FAT-
4 FAT16 <32M 40 Venix 80286 85 Linux extended c7 Syrinx 
5 Extended 41 PPC PReP Boot 86 NTFS volume set da Non-FS data 
6 FAT16 42 SFS 87 NTFS volume set db CP/M / CTOS / .
7 HPFS/NTFS/exFAT 4d QNX4.x 88 Linux plaintext de Dell Utility 
8 AIX 4e QNX4.x 2nd part 8e Linux LVM df BootIt 
9 AIX bootable 4f QNX4.x 3rd part 93 Amoeba e1 DOS access 
a OS/2 Boot Manag 50 OnTrack DM 94 Amoeba BBT e3 DOS R/O 
b W95 FAT32 51 OnTrack DM6 Aux 9f BSD/OS e4 SpeedStor 
c W95 FAT32 (LBA) 52 CP/M a0 IBM Thinkpad hi ea Rufus alignment
e W95 FAT16 (LBA) 53 OnTrack DM6 Aux a5 FreeBSD eb BeOS fs 
f W95 Ext'd (LBA) 54 OnTrackDM6 a6 OpenBSD ee GPT 
10 OPUS 55 EZ-Drive a7 NeXTSTEP ef EFI (FAT-12/16/
11 Hidden FAT12 56 Golden Bow a8 Darwin UFS f0 Linux/PA-RISC b
12 Compaq diagnost 5c Priam Edisk a9 NetBSD f1 SpeedStor 
14 Hidden FAT16 <3 61 SpeedStor ab Darwin boot f4 SpeedStor 
16 Hidden FAT16 63 GNU HURD or Sys af HFS / HFS+ f2 DOS secondary 
17 Hidden HPFS/NTF 64 Novell Netware b7 BSDI fs fb VMware VMFS 
18 AST SmartSleep 65 Novell Netware b8 BSDI swap fc VMware VMKCORE 
1b Hidden W95 FAT3 70 DiskSecure Mult bb Boot Wizard hid fd Linux raid auto
1c Hidden W95 FAT3 75 PC/IX bc Acronis FAT32 L fe LANstep 
1e Hidden W95 FAT1 80 Old Minix be Solaris boot ff BBT

Command (m for help):
Command (m for help): n    #新建分区
Partition type
p primary (2 primary, 0 extended, 2 free)
e extended (container for logical partitions)
Select (default p): p    #选择主分区或者逻辑分区
Partition number (3,4, default 3):    #分区的序号
First sector (33280-976773167, default 493568):    #选择开始扇区
Last sector, +/-sectors or +/-size{K,M,G,T,P} (493568-976773167, default 976773167):    #选择结束扇区

Created a new partition 3 of type 'Linux' and of size 465.5 GiB.

Command (m for help):
Command (m for help): p    #显示分区信息
Disk /dev/sda: 465.8 GiB, 500107862016 bytes, 976773168 sectors
Disk model: ST500DM002-1BD14
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x5f5df0e2

Device Boot Start End Sectors Size Id Type
/dev/sda1 512 33279 32768 16M 83 Linux
/dev/sda2 33792 492543 458752 224M 83 Linux
/dev/sda3 493568 976773167 976279600 465.5G 83 Linux

Command (m for help):

执行完操作命令后需要输入”W”来保持退出

Command (m for help): w
赞(0) 打赏
未经允许不得转载:NixonLi博客 » fdisk 磁盘分区命令

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏