Brief introduction
With the rapid development of science and technology, more and more enterprises for the stability of the server more and more high, more and more enterprises began to use the Linux system to deploy their services, in order to efficient stability, of course any operating system needs a basic foundation, that is hard disk, and hard disk partition, Today to recommend some of the CentOS Linux partition tools and how to view the partition environment, will also give you some basic knowledge of hard disk
First, the interface type of the hard disk
Partition is sure to partition the hard disk, then first to talk about the hard disk interface type, hard disk is now divided into two categories, parallel interface and serial interface, now the server and the PC is generally a serial interface.
Parallel interface, divided into IDE and SCSI two interface, the disadvantage of parallel interface is that the electrical signal in the process of transmission will cause interference.
Interface Rate:
ide:133mb/s
scis:640mb/s
Serial interface, divided into Stat,sas,usb, three kinds of interfaces, our servers and PCs on the part of the SATA interface is also used
Serial:
sata:6gbps
sas:6gbps
usb:480mb/s
There are two types of disk partitioning modes, MBR, GPT two.
MBR mode
Mbr:master boot record,1982 year, use 32 bit to represent sector number, partition not more than 2T
The number of MBR modes that can be partitioned is: 4 primary partitions, 3 primary partition +1 extension (n logical partitions)
Of course, the hard disk in the partition requires a portion of space to store these partition information, this part of the space is 0 tracks 0 sectors: 512bytes.
Start 446bytes Store boot loader
Intermediate 64bytes Storage partition table, each 16bytes: identifies a partition
Last 2bytes: Store 55AA to indicate hard disk mode type
GPT mode
Gpt:guid (Globals Unique Identifiers) partition table supports 128 partitions with 64-bit support for 8Z (512byte/block) 64Z (4096byte/block)
Use a 128-bit UUID (universally Unique Identifier) to indicate that the disk and partition GPT partition tables are automatically backed up at the head and tail two parts, and have a CRC check bit
UEFI (Unified extension Firmware interface) hardware supports GPT, enabling the operating system to boot
Second, let's have a glimpse of Linux under the 3 partition tool capabilities.
Hale Fdisk.
Fdisk in Linux is a very old partition tool, although the tool is old, but simple convenience is the advantage of Fdisk, of course, Gdisk also inherited this advantage, they are very similar function, but the Fdisk tool is mainly used to partition MBR mode hard disk, The Gdisk tool is used to partition a GPT-mode hard disk, and here is a Fdisk tool. FDISK cannot partition more than 2T of disks because MBR mode does not support more than 2T partition formats.
FDISK, Gdisk Tools
Fdisk/dev/sdb
Fdisk-l [-u] [device ...] view hard disk and partition information
Common subcommands:
M Help List
650) this.width=650; "src=" Http://www.178linux.com/wp-content/uploads/2017/03/20170319162704_89102.png "style=" border:0px; "/>
P Partition List
650) this.width=650; "src=" Http://www.178linux.com/wp-content/uploads/2017/03/20170319162720_70807.png "style=" border:0px; "/>
L View Partition type
650) this.width=650; "src=" Http://www.178linux.com/wp-content/uploads/2017/03/20170319162732_47839.png "style=" border:0px; "/>
t change the partition type
650) this.width=650; "src=" Http://www.178linux.com/wp-content/uploads/2017/03/20170319162755_60833.png "style=" border:0px; "/>
n Create a new partition
650) this.width=650; "src=" Http://www.178linux.com/wp-content/uploads/2017/03/20170319163514_62341.png "style=" border:0px; "/>
D Delete Partition
650) this.width=650; "src=" Http://www.178linux.com/wp-content/uploads/2017/03/20170319162929_55450.png "style=" border:0px; "/>
W Save and exit
Fdisk partition, the operation is only in memory is not really partition of the hard disk, if you really need to save partition W
650) this.width=650; "src=" Http://www.178linux.com/wp-content/uploads/2017/03/20170319163430_13640.png "style=" border:0px; "/>
Q Do not save and exit
Of course if you regret, input Q will not save the previous action
I'm going to do an experiment for you when the options are finished. Let's look at how this tool works.
[[email protected] ~] #fdisk /dev/sdb #对/dev/sdb to operate welcome to fdisk (util-linux 2.23.2). changes will remain in memory only, until you decide to Write them. Be careful before using the write command. command (M FOR HELP): n #建立一个分区Partition type: p primary (0 primary, 0 extended, 4 free) e extendedSelect (default p): p #分区类型为主分区, p is the primary partition, E is the extended partition partition number (1-4, default 1): 1 #指定分区号First sector ( 2048-41943039, default 2048): using default value 2048last sector, + sectors or +size{k,m,g} (2048-41943039, default 41943039): +2GPartition 1 of type Linux and of size 2 GiB is setCommand (m FOR HELP): t #指定分区标记类型Selected partition 1hex code (type l to list all codes): 82changed type of partition ' Linux ' to ' Linux swap / solaris ' command (m for help): w #保存操作the partition table has been altered! Calling ioctl () to re-read partition table. Syncing disks.
Powerful partitioning tool parted
Parted
The partitioning of the parted tool is immediate, so use caution when partitioning, because you may accidentally partition the hard drive, so be cautious and cautious when using it.
Usage: parted [options] ... [Device [command [parameters] ...] ...]
Parted/dev/sdb Mklabel Gpt|msdos Specify the mode for the disk
PARTED/DEV/SDB Print Display disk information
Parted/dev/sdb mkpart primary/extended/logical 0 200 (default m) create partition type and size
Parted/dev/sdb RM 1 Delete partition
Parted-l displaying information for all disks
I'm going to do an experiment for you when the options are finished. Let's look at how this tool works.
[[email protected] ~] #parted /dev/sdb mklabel gpt #指定磁盘模式为GPTWarning: the existing disk label on /dev/sdb will be destroyed and all data on this Diskwill be lost. do you want to continue? yes/no? yes Information: You may Need to update /etc/fstab. [[email protected] ~] #parted /dev/sdb mkpart primary 0 2G #创建分区, partitioningType primary partition, size 2gwarning: the resulting partition is not properly aligned For best performance. ignore/cancel? i information: you may need to update /etc/fstab. [[email protected] ~] #parted /dev/sdb print #查看磁盘信息 model: vmware, vmware virtual S (SCSI) disk /dev/sdb: 21.5gbsector size (logical/physical): 512b/512bpartition table: gptdisk flags: number start end size file system name flags 1 17.4kb 2000mb 2000mb primary[[email Protected] ~] #parted /dev/sdb rm 1 #删除分区1Information: you may need to update /etc/fstab. [[email protected] ~] #parted /dev/sdb print #再次查看磁盘信息 Model: VMware, vmware virtual s (SCSI) disk /dev/sdb: 21.5gbsector size (logical/physicAL): 512b/512bpartition table: gptdisk flags: number start end size file system name flags
After the introduction of the partition will be introduced format
The formatted command can be used
Mkfs. File system Type Partitioning
#mkfs. ext4/dev/sdb1
After formatting, you can use the mounted
[[email protected] ~] #mkdir /mnt/disk1 #在/mnt/to build a disk1 directory [[email protected] ~] #mount /dev/sdb1 /mnt/disk1 #将格式化号的分区挂载到/mnt/disk1 flower Girl [[ Email protected] ~] #df -h # View mounts and Usage filesystem size used avail use% mounted on/dev/sda2 10G 4.5G 5.5G 45% /devtmpfs 898m 0 898M 0% /devtmpfs 912m 88k 912m 1% /dev/shmtmpfs 912M 9.0M 903M 1% /runtmpfs 912M 0 912M 0% /sys/fs/cgroup/dev/sda1 1014M 169M 846M 17% /boottmpfs 183m 20k 183m 1% /run/user/0/dev/sdb1 1.9g 5.7m 1.7g 1% /mnt/disk1
Mkswap formatting swap-type partitions
After formatting requires Swapon to enable the formatted partition
Boot Auto mount requires that these configurations be written to/etc/fstab
Specific mounting methods will be explained in detail later.
[[email protected] ~] #free -h #先看一下swap的大小 total used free shared buff/cache availablemem: 1.8G 483M 429M 10M 911M 1.1GSwap: 2.0G 0b 2.0g[[email protected] ~] #mkswap /dev/sdb1 #格式化/DEV/SDB1 Partition mkswap: /dev/sdb1: warning: wiping old Ext4 signature. setting up swapspace version 1, size = 1953104 kibno label, Uuid=5d9a150e-c247-4c7f-a4be-273a72bd3b5a[[email protected] ~] #swapon /dev/sdb1 #启用swap分区 [[email protected] ~] #free -h #再次查看swap大小 total used free shared buff/cache availableMem: 1.8G 484M 427M 10m 911m 1.1GSwap: 3.9G 0b 3.9g
If there is a next issue, you will be presented with the Mount Mount, soft RAID technology, and logical volume configuration method.
This article is from the "12612752" blog, please be sure to keep this source http://12622752.blog.51cto.com/12612752/1908157
Recommended 3 Partitioning tools for CentOS Linux