Linux command: fdisk

Source: Internet
Author: User
Tags hex code

fdisk Introduction to Commands:

Check that the current system identifies several hard drives or partitions the disk.

vfs:virtual File System virtual filesystem

1 . Command format:

fdisk [options] <disk> partitioning the hard disk

fdisk [Options]-l <disk> list hard disk partition information

Fdisk-s <partition> Show the size of the partition

Fdisk-l View all hard disk partitions in the current system

[Email protected] ~]# fdisk-l

disk/dev/sda:21.5 GB, 21474836480 bytes

255 heads, Sectors/track, 2610 cylinders

Units = Cylinders of 16065 * 8225280 bytes

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

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

Disk Identifier:0x0001e9b8

Device Boot Start End Blocks Id System

/DEV/SDA1 * 1 204800 Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2 1046 8192000 Linux

/dev/sda3 1046 1556 4096000-up Linux

/DEV/SDA4 1556 2611 8477696 5 Extended

/dev/sda5 1556 1811 2048000-up Linux

/dev/sda6 1811 2066 2048000-up Linux

/dev/sda7 2066 2258 1536000, Linux Swap/solaris

Format: mkfs-t ext3/path formatted as ext3 type file system

2 . Command function:

View current system identifies several hard drives or manages hard disk partitions

To manage disk partitions:

Fdisk/dev/sda

P: Displays the partition of the current hardware, including unsaved changes

N: Create a new partition

E: Extended partition

P: Primary partition

D: Delete a partition

W: Save exit

Q: Do not save exit

T: Modify the partition type

L: View in T status so supported type

L: Show all supported types

Partprobe notifies the kernel to reread the partition table so that the newly created partition can be read.

cat/pro/partitions View the partition table that the kernel has read, only the partitions recognized by the kernel can be formatted, mounted, etc. .

[Email protected] ~]# cat/proc/partitions

Major Minor #blocks name


8 0 20971520 SDA

8 1 204800 sda1

8 2 8192000 Sda2

8 3 4096000 Sda3

8 4 1 SDA4

8 5 2048000 Sda5

8 6 2048000 Sda6

8 7 1536000 Sda7


3 . Command parameters:

-B <size> sector size (2048 or 4096)

-C switch off dos-compatible mode

-H Display Help

-U <size> display the cylinder size in the sector

-V Print version

-C <number> Specify the number of cylinders

-H <number> Specify the number of heads

-S <number> Specify the number of sect

4 . Command instance:

1. Demo Create a new partition, delete a partition, modify the partition type.

Fdisk/dev/sda

[Email protected] ~]# FDISK/DEV/SDA

Warning:dos-compatible mode is deprecated. It ' s strongly recommended to

Switch off the mode (command ' C ') and change display units to

Sectors (Command ' u ').


Command (M for help): N new partition, if it is a new hard disk will prompt to create a new primary partition (P) or an extended partition (e)

First cylinder (2258-2611, default 2258): Enter the starting cylinder defaults

Using Default Value 2258

Last cylinder, +cylinders or +size{k,m,g} (2258-2611, default 2611): +1g Create a 1G partition

Command (M for help): T t modify partition type

Partition number (1-8): 8

Hex code (Type L to list codes): L l View System-supported partition types


0 Empty NEC DOS bayi minix/old Lin BF Solaris

1 FAT12 Plan 9 swap/so C1 drdos/sec (fat-

2 Xenix root 3c partitionmagic Linux C4 drdos/sec (fat-

3 Xenix usr Venix 80286 os/2 hidden c:c6 drdos/sec (fat-

4 FAT16 <32m PPC PReP Boot-up Linux extended C7 Syrinx

5 Extended SFS, NTFS volume set da non-fs data

Hex code (type L to list codes): 82 Input partition type

Changed system type of partition 8 to Swap/solaris (Linux)


Command (M for help): P shows the partitioned table that has been established


disk/dev/sda:21.5 GB, 21474836480 bytes

255 heads, Sectors/track, 2610 cylinders

Units = Cylinders of 16065 * 8225280 bytes

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

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

Disk Identifier:0x0001e9b8


Device Boot Start End Blocks Id System

/DEV/SDA1 * 1 204800 Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2 1046 8192000 Linux

/dev/sda3 1046 1556 4096000-up Linux

/DEV/SDA4 1556 2611 8477696 5 Extended

/dev/sda5 1556 1811 2048000-up Linux

/dev/sda6 1811 2066 2048000-up Linux

/dev/sda7 2066 2258 1536000, Linux Swap/solaris

/dev/sda8 2258 2389 1059691, Linux Swap/solaris

SDA8 is just the newly created partition

Ommand (M for help): W Save exit new Partition established successfully

The partition table has been altered!

Calling IOCTL () to re-read partition table.

[[email protected] ~]# Partprobe partprobe notify kernel Reread partition table, let kernel recognize new partition

[Email protected] ~]# cat/proc/partitions

Major Minor #blocks name

8 0 20971520 SDA

8 1 204800 sda1

8 2 8192000 Sda2

8 3 4096000 Sda3

8 4 1 SDA4

8 5 2048000 Sda5

8 6 2048000 Sda6

8 7 1536000 Sda7

8 8 1024000 The SDA8 kernel has identified the new partition, only the partition can be formatted, mounted, and so on.


This article is from the "Learn Linux history" blog, please be sure to keep this source http://woyaoxuelinux.blog.51cto.com/5663865/1866987

Linux command: fdisk

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.