1, fdisk Profile
[root@localhost /]# whatis fdisk fdisk (8) - manipulate disk partition table # operation partition table
fdisk command applies to 2TB disk set below.
2, fdisk grammar
fdisk [disk name] For example: fdisk / dev / sdb
3, fdisk common options
Options | Explanation |
-l | All disk information display system, including partition information |
-h | Displays Help |
-v | Displays version information |
4. Examples
Information 1) View all system disks
[root@localhost /]# fdisk -l Disk /dev/sda:21.5 GB, 21474836480 bytes, 41943040 sectors # / dev / sda disk information Units = sectors of 1 * 512 = 512 bytes Sector size (logical / physical): 512 byte / 512 byte I / O Size (minimal / optimal): 512 byte / 512 byte Disk Label Type: dos Disk identifier: 0x00094c41 设备 Boot Start End Blocks Id System /dev/sda1 * 2048 1026047 512000 83 Linux /dev/sda2 1026048 41943039 20458496 8e Linux LVM Disk /dev/sdb:21.5 GB, 21474836480 bytes, 41943040 sectors # / dev / sdb disk information Units = sectors of 1 * 512 = 512 bytes Sector size (logical / physical): 512 byte / 512 byte I / O Size (minimal / optimal): 512 byte / 512 byte Disk / dev / mapper / rhel-swap: 2147 MB, 2147483648 bytes, the sector # 4194304 swap information Units = sectors of 1 * 512 = 512 bytes Sector size (logical / physical): 512 byte / 512 byte I / O Size (minimal / optimal): 512 byte / 512 byte Disk /dev/mapper/rhel-root:18.8 GB, 18756927488 bytes, 36634624 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical / physical): 512 byte / 512 byte I / O Size (minimal / optimal): 512 byte / 512 byte
2) Use fdisk command to / dev / sdb partition management
[root@localhost /]# fdisk /dev/sdb Welcome to the fdisk (util-linux 2.23.2). Change will stay in memory until you decide to write the changes to disk. Please think twice before using the write command. Device does not contain a recognized partition table Use disk identifier 0x8b6742b9 create a new DOS disk label. Command (input m to get help): m #m view help Command Operation a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition #d delete partition g create a new empty GPT partition table G create an IRIX (SGI) partition table l list known partition types m print this menu #m view help n add a new partition #n create partitions o create a new empty DOS partition table p print the partition table #p view the partition information q quit without saving changes #q exit without saving s create a new empty Sun disklabel t change a partition's system id #t partition type conversion u change display/entry units v verify the partition table w write table to disk and exit #w Save and Exit x extra functionality (experts only) Command (input m to get help): p #p view the partition information Disk /dev/sdb:21.5 GB, 21474836480 bytes, 41943040 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical / physical): 512 byte / 512 byte I / O Size (minimal / optimal): 512 byte / 512 byte Disk Label Type: dos Disk identifier: 0x8b6742b9 设备 Boot Start End Blocks Id System Command (input m to get help): n #n add a partition Partition type: p primary (0 primary, 0 extended, 4 free) #p primary partition e extended #e extended partition Select (default p): p Partition number (1-4, default 1): # partition number Starting sector (2048-41943039, the default is 2048): the start sector number # We will use the default value 2048 Last sector, sector + or + size {K, M, G} (2048-41943039, defaults to 41943039): + 2G # partition size Partition 1 is set to Linux type, size to 2 GiB Command (input m to get help): p #n create partitions Disk /dev/sdb:21.5 GB, 21474836480 bytes, 41943040 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical / physical): 512 byte / 512 byte I / O Size (minimal / optimal): 512 byte / 512 byte Disk Label Type: dos Disk identifier: 0x8b6742b9 设备 Boot Start End Blocks Id System /dev/sdb1 2048 4196351 2097152 83 Linux Command (input m to get help): n Partition type: p primary (1 primary, 0 extended, 3 free) e extended Select (default p): p Partition number (2-4, default 2): Starting sector (4196352-41943039, default 4,196,352): We will use the default value 4,196,352 Last sector, sector + or + size {K, M, G} (4196352-41943039, defaults to 41943039): + 3G Zone 2 is set to Linux type, size is set to 3 GiB Command (input m to get help): p Disk /dev/sdb:21.5 GB, 21474836480 bytes, 41943040 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical / physical): 512 byte / 512 byte I / O Size (minimal / optimal): 512 byte / 512 byte Disk Label Type: dos Disk identifier: 0x8b6742b9 设备 Boot Start End Blocks Id System /dev/sdb1 2048 4196351 2097152 83 Linux /dev/sdb2 4196352 10487807 3145728 83 Linux Command (input m to get help): n Partition type: p primary (2 primary, 0 extended, 2 free) e extended Select (default p): e Partition number (3,4, 3 by default): Starting sector (10487808-41943039, default 10487808): We will use the default value 10,487,808 Last sector, sector + or + size {K, M, G} (10487808-41943039, default 41943039): We will use the default value 41,943,039 Extended partition 3 is set to the type, size to 15 GiB Command (input m to get help): p Disk /dev/sdb:21.5 GB, 21474836480 bytes, 41943040 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical / physical): 512 byte / 512 byte I / O Size (minimal / optimal): 512 byte / 512 byte Disk Label Type: dos Disk identifier: 0x8b6742b9 设备 Boot Start End Blocks Id System /dev/sdb1 2048 4196351 2097152 83 Linux /dev/sdb2 4196352 10487807 3145728 83 Linux /dev/sdb3 10487808 41943039 15727616 5 Extended Command (input m to get help): n Partition type: p primary (2 primary, 1 extended, 1 free) l logical (numbered from 5) Select (default p): l Add a logical partition 5 Starting sector (10489856-41943039, default 10489856): We will use the default value 10,489,856 Last sector, sector + or + size {K, M, G} (10489856-41943039, defaults to 41943039): + 5G 5 Linux partition has been set to the type, size to 5 GiB Command (input m to get help): p Disk /dev/sdb:21.5 GB, 21474836480 bytes, 41943040 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical / physical): 512 byte / 512 byte I / O Size (minimal / optimal): 512 byte / 512 byte Disk Label Type: dos Disk identifier: 0x8b6742b9 设备 Boot Start End Blocks Id System /dev/sdb1 2048 4196351 2097152 83 Linux /dev/sdb2 4196352 10487807 3145728 83 Linux /dev/sdb3 10487808 41943039 15727616 5 Extended /dev/sdb5 10489856 20975615 5242880 83 Linux Command (input m to get help): d #d delete partition Partition number (1-3, 5, default 5): 1 # to delete the partition number Deleted Partition 1 Command (input m to get help): p Disk /dev/sdb:21.5 GB, 21474836480 bytes, 41943040 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical / physical): 512 byte / 512 byte I / O Size (minimal / optimal): 512 byte / 512 byte Disk Label Type: dos Disk identifier: 0x8b6742b9 设备 Boot Start End Blocks Id System /dev/sdb2 4196352 10487807 3145728 83 Linux /dev/sdb3 10487808 41943039 15727616 5 Extended /dev/sdb5 10489856 20975615 5242880 83 Linux Command (input m to get help): w # Save and Exit The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. [Root @ localhost /] # fidsk -l / dev / sdb # view the partition information / dev / sdb of -bash: fidsk: command not found [root@localhost /]# fdisk -l /dev/sdb Disk /dev/sdb:21.5 GB, 21474836480 bytes, 41943040 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical / physical): 512 byte / 512 byte I / O Size (minimal / optimal): 512 byte / 512 byte Disk Label Type: dos Disk identifier: 0x8b6742b9 设备 Boot Start End Blocks Id System /dev/sdb2 4196352 10487807 3145728 83 Linux /dev/sdb3 10487808 41943039 15727616 5 Extended /dev/sdb5 10489856 20975615 5242880 83 Linux
5, summary
1) fdisk command applies to 2TB disk partition management;
2) fdisk -l to see all disks, partitions;
3) fdisk command operations: ①, m view help information; ②, p view partition information; ③, n create a partition (p main branch, e extended partition, l logical partition); ④, d delete partitions; ⑤, q is not saved exit; ⑥, w save and exit; ⑦, t convert the partition type.