Linux system disk partition Fdisk__linux

Source: Internet
Author: User


For learning a disk partition, you usually learn the fdisk command
Of course, for disks less than 2TB, we basically use the FDISK command to partition
The following is a brief introduction to the basic commands and scenario simulations of the Fdisk operation disk

Introduction to Common commands
FDISK-L View all disk information
Fdisk/dev/sdb Use the Fdisk command tool to manipulate/DEV/SDB disks
M displays all command information, usage
P Display partition information
Q exit
W saves the partition information and writes the partition information to the disk only after the W command is executed
D 1 Delete the first partition of the disk

Scene simulation

There is a 1G disk/dev/sdb

The partition is a primary partition, an extended partition with a size of 200M

Where a 100M logical partition is established above the extended partition/DEV/SDB5

Format File system is MKFS.EXT4

Enable automatic mount to directory/backup3

1 using the FDISK command tool to manipulate disk/dev/sdb
Fdisk/dev/sdb
2 Create a primary partition
Command (M for help): N
Command Action
E Extended
P primary partition (1-4)
P
Partition number (1-4): 1
Using Default value 1
Last cylinder, +cylinders or +size{k,m,g} (1-130, default 130): +400m


Command (M for help): P

disk/dev/sdb:1073 MB, 1073741824 bytes
255 heads, Sectors/track, 130 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk identifier:0x0004a98a

Device Boot Start End Blocks Id System
/DEV/SDB1 1 417658+ Linux

3 Creating an extended partition
Command (M for help): N
Command Action
E Extended
P primary partition (1-4)
E
Partition number (1-4): 2
The cylinder (53-130, default 53):
Using Default Value 53
Last cylinder, +cylinders or +size{k,m,g} (53-130, default 130): +400m

Command (M for help): P

disk/dev/sdb:1073 MB, 1073741824 bytes
255 heads, Sectors/track, 130 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk identifier:0x0004a98a

Device Boot Start End Blocks Id System
/DEV/SDB1 1 417658+ Linux
/DEV/SDB2 417690 5 Extended

4 Creating a logical partition
Command (M for help): N
Command Action
L logical (5 or over)
P primary partition (1-4)
L
The cylinder (53-104, default 53):
Using Default Value 53
Last cylinder, +cylinders or +size{k,m,g} (53-104, default): +100m

Command (M for help): P

disk/dev/sdb:1073 MB, 1073741824 bytes
255 heads, Sectors/track, 130 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk identifier:0x0004a98a

Device Boot Start End Blocks Id System
/DEV/SDB1 1 417658+ Linux
/DEV/SDB2 417690 5 Extended
/DEV/SDB5 112423+ MB Linux

5 Save
Command (M for help): W
The partition table has been altered!

Calling IOCTL () to re-read partition table.
Syncing disks.

6 Partitioning a disk
[Root@hsj2 ~]# MKFS.EXT4/DEV/SDB1
MKE2FS 1.41.12 (17-may-2010)
FileSystem label=
OS Type:linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, stripe width=0 blocks
104448 inodes, 417656 blocks
20882 blocks (5.00%) reserved for the Super user
The Data block=1
Maximum filesystem blocks=67633152
Wuyi block Groups
8192 blocks per group, 8192 fragments per group
2048 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409

Writing Inode Tables:done
Creating journal (8192 blocks): Done
Writing superblocks and filesystem accounting Information:done

This filesystem would be automatically checked every mounts or
180 days, whichever comes. Use Tune2fs-c or-i to override.

[Root@hsj2 ~]# MKFS.EXT4/DEV/SDB5
MKE2FS 1.41.12 (17-may-2010)
FileSystem label=
OS Type:linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, stripe width=0 blocks
28112 inodes, 112420 blocks
5621 Blocks (5.00%) reserved for the Super user
The Data block=1
Maximum filesystem blocks=67371008
Block groups
8192 blocks per group, 8192 fragments per group
2008 Inodes per Group
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729

Writing Inode Tables:done
Creating journal (4096 blocks): Done
Writing superblocks and filesystem accounting Information:done

This filesystem would be automatically checked every mounts or
180 days, whichever comes. Use Tune2fs-c or-i to override.

OK, it's done.

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.