New partition for Linux file System (fdisk command)

Source: Internet
Author: User

Disk-related knowledge:

1, the hard disk has several platters, each disc two faces each has a head

2, the disc is divided into multiple sectors

3. Concentric circle with different radius of the same disc as the track

4, the same radius of different discs of the cylindrical surface is cylindrical

FDISK command:

1. View the disk devices that have been identified:

[Email protected] ~]# fdisk-l/dev/[hs]d[a-z]

disk/dev/sda:128.8 GB, 128849018880 bytes
255 heads, Sectors/track, 15665 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk Identifier:0x0004fe34

Device Boot Start End Blocks Id System
/DEV/SDA1 * 1 512000 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 15666 125316096 8e Linux LVM

The previous paragraph indicates that the disk/DEV/SDA has 120GB, has 255 heads, each track has 63 sectors, a total of 15,665 cylinders, each physical and logical sector is 512 bytes.

The following 7 fields indicate:

(1), device indicates disk partition

(2), boot indicates a bootable operating system, * indicates a bootable operating system

(3), start: Indicates that the partition starts from the first cylinder

(4), end: Indicates the end of this partition from the first few cylinders

(5), blocks means how many blocks are included

(6), ID is the partition type identification, used to identify the type of partition for that operating system

(7), the system partition indicates the type and ID of the operating system to which it belongs.

2. Managing partitions

[Email protected] ~]# Fdisk/dev/sdb

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):

Here to create a file partition with the disk device behind Fdisk, enter M to see the subcommands of Fdisk:

Command (M for help): M
Command Action
A toggle a bootable flag
b Edit BSD Disklabel
C Toggle the DOS compatibility flag
D Delete a partition
L list known partition types
M Print this menu
n Add a new partition
o Create a new empty DOS partition table
P Print the partition table
Q Quit without saving changes
s create a new empty Sun Disklabel
t change a partition ' s system ID
U Change display/entry units
V Verify the partition table
W Write table to disk and exit
X Extra functionality (experts only)

Here's a look at the subcommands commonly used by Fdisk:

P: Displays the existing partition table;
N: Create a new partition
D: Delete an existing partition
T: Modify the partition ID
L: See which partition IDs are supported
W: Save exit
Q: Do not save exit
M: Display Help information

To view an existing partition table with the subcommand p

Command (M for help): P

disk/dev/sdb: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:0X58996CEF

Device Boot Start End Blocks Id System
/DEV/SDB1 1 654 5253223+ Linux
/DEV/SDB2 655 2610 15711570 5 Extended
/DEV/SDB5 655 916 2104483+-up Linux
/DEV/SDB6 917 918 16033+, Linux Swap/solaris

Here you can see that/DEV/SDB now has 4 partitions, you can see that/DEV/SDB1 is the primary partition,/DEV/SDB2 is the extended partition,/DEV/SDB5 and/DEV/SDB6 are logical partitions.

Use the subcommand N to create a new partition:

Command (M for help): N
Command Action
L logical (5 or over)
P primary partition (1-4)

Here you can choose "L" to create the logical partition, select "P" to create the primary partition

Here I choose "L":

Command (M for help): N
Command Action
L logical (5 or over)
P primary partition (1-4)
L
First cylinder (919-2610, default 919):
Using Default Value 919
Last cylinder, +cylinders or +size{k,m,g} (919-2610, default 2610): +2g

Here first cylinder indicates which cylinder the partition starts from, last cylinder represents the end of the bar from which, of course, I directly hit "+2g" means I directly to the size of this partition 2G.

After creating the partition we use the "P" subcommand to see if there is a new 2G partition created:

Command (M for help): P

disk/dev/sdb: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:0X58996CEF

Device Boot Start End Blocks Id System
/DEV/SDB1 1 654 5253223+ Linux
/DEV/SDB2 655 2610 15711570 5 Extended
/DEV/SDB5 655 916 2104483+-up Linux
/DEV/SDB6 917 918 16033+, Linux Swap/solaris
/DEV/SDB7 919 1180 2104483+-up Linux

Here we see that we have created a new partition/dev/sdb7, after the creation of our Linux kernel does not necessarily recognize our newly created partition, we want to see whether the kernel has recognized the new partition can be used to view the cat command/proc/partitions file

[Email protected] ~]# cat/proc/partitions
Major Minor #blocks name

8 0 125829120 SDA
8 1 512000 sda1
8 2 125316096 Sda2
8 20971520 SDB
8 5253223 SDB1
8 1 SDB2
8 2104483 SDB5
8 16033 SDB6
253 0 52428800 dm-0
253 1 983040 dm-1
253 2 71901184 Dm-2

We see here the kernel has not recognized the/DEV/SDB7 device, how to do? We can use the following two commands to notify the kernel to identify our newly created partition device:

1, Partx–a/dev/sdb

2, Kpartx–af/dev/sdb

This article is from the "Summer Month" blog, please make sure to keep this source http://lkc0110.blog.51cto.com/3410558/1751044

New partition for Linux file System (fdisk command)

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.