Linux fdisk command Detailed: Partitioning a hard disk

We have on the system hard disk partition during the installation of the operating system, but if I add a new hard drive and want normal use, do not need to reinstall the operating system before they can partition it?

Of course not, there is a special partition command in Linux fdisk and parted. Wherein fdisk command more commonly, but not the partition larger than 2TB; if needed to support the partition larger than 2TB, you need to use the command parted, of course, also parted command assigned smaller partitions. Let's look at how to use the command fdisk partition.
fdisk command
format fdisk command is as follows:
[root @ localhost ~] # fdisk ~ L
# listed in the system partition
[root @ localhost ~] # fdisk device file name
# to the hard disk partition

For example:
[the root @ localhost ~] # the fdisk -l
# checks the local hard disk and partition may be identified
Disk /dev/sda:32.2 GB, 32,212,254,720 bytes
# hard file name and size of the hard disk
255 Heads, 63 is sectors / Track, 3916 Cylinders
# of 255 heads, and 63 sectors 3916 cylinders
Units = cylinders of 16065 * 512 = 8.22528 million bytes
# of each cylinder size
sector size (Logical / PHYSICAL): 512 bytes / 512 bytes
# of each sector the size of
the I / O size (Minimum / Optimal): 512 bytes / 512 bytes
Disk identifier The: 0x0009e098
Device the Boot Start End Blocks LD System
/ dev / sda1 * 1 26 204800 83 Linux
partition 1 does not End ON Cylinder boundary.
# partition 1 does not fill the hard disk
/ dev / sda2 26 281 2048000 82 Linux swap / the Solaris
partition 2 does not End ON Cylinder boundary
# 2 does not occupy hard disk partition
/ dev / sda3 29,203,456 83 3917 281 is the Linux
# boot partition device file name starting cylinder terminates cylinder capacity ID system
Disk / dev / sdb: 21.5 GB , 21474836480 bytes # identifying the second hard disk, the size of the hard disk
255 heads, sectors 63 is / Track, 2610. Cylinders
Units = Cylinders of 16065 * 512 = 8.22528 million bytes
Sector size (Logical / PHYSICAL): 512 bytes / 512 bytes
the I / O size (Minimum / Optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000

Use "fdisk -l" to view partition information, you can see two hard drives (/ dev / sda and / dev / sdb) the information that we add. We explain the information. The new channel is the entire upper half of the state status of the disk, the total size of / dev / sda disk is 32.2 GB, a total of 3916 cylinders, each cylinder read / write data of 255 heads each management 63 sectors. The size of each cylinder is 8225280 Bytes, the size of each sector is 512 Bytes.

The lower half of the partition information is information, a total of seven, the following meanings:
Device: partition device file name.
Boot: whether the boot partition, where / dev / sda1 as the boot partition.
Start: starting cylinder, on behalf of the partition where to start.
End: to terminate cylinders, on behalf of the partition where the end.
Blocks: size of the partition, the unit is KB.
id: ID partition file system. In the fdisk command, you can use the "i" view.
System: What partition installed system Yes.

If this does not fill up the entire hard drive partition, it will prompt "Partition 1 does not end on cyl inder boundary", represents the first partition is not the end of the cylinder to the hard drive. You find it? / Dev / sda has been allocated over the partition, there is no free space up. While the second hard disk / dev / sdb already been identified, but no partition.

Our hard disk / dev / sdb, for example to do the exercises, command is as follows:
[root @ localhost ~] # fdisk / dev / sdb
# to / dev / sdb partition
Device contains neither a valid DOS partition table , nor Sun, SGI or OSF disklabel
Building A new new DOS disklabel with Disk identifier The 0xed7e8bc7.
Changes in Memory by Will REMAIN only, an until you Decide to the Write Them.
the After that, of Course,, at The Previous Content by Will not BE Recoverable.
Warning: invalid 0x0000 Flag of the Table 4 Partition by Will W corrected by BE (Rite)
the WARNING: the DOS-compatible MODE IS deprecated.it 'S Strongly Recommended to OFF Switch The MODE (Command' C ') and the display Change Units to sectors (Command' U ').
the Command (m for Help ): m
position of waiting for input command # interactive interface, input m help
the command Action
# useable instructions
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
I 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 verity the partition table
w write table to disk and exit
x extra functionality (experts only)

Note that partition is the command "fdisk / dev / sdb", it is because we did not partition the hard disk now, using fdisk command purpose is to create a partition, so "1-59" These figures do not exist.

In the input interface fdisk m can get help, help can be identified in a list of interactive commands fdisk, we explain these commands, as shown in Table 1.

Table 1 the fdisk interaction
command description
a bootable flag set
b bsd disk label editing
c DOS operating system compatible flag set
d to delete a partition
1 file system type known display. 82 is a Linux swap partition, 83 Linux partition
m to display the help menu
n New Partition
0 create an empty DOS partition table
P list of the partitions
q exit without saving
s new blank SUN Disk Label
t change a partition system ID
U change display record unit
V verify the partition table
w save and exit
X additional functionality (experts only)

Published 160 original articles · won 97 Like · views 160 000 +

Guess you like

Origin blog.csdn.net/zyy1659949090/article/details/88176692