Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What partitioning tools are available under CentOS Linux

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article is about what partitioning tools are available under CentOS Linux. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Interface type of hard disk

Partition must partition the hard disk, so let's first talk about the interface types of the hard disk. The hard disk is now divided into two types, parallel interface and serial interface. Serial interfaces are now common on servers and PCs.

Parallel interface is divided into IDE interface and SCSI interface. The disadvantage of parallel interface is that the electrical signal will produce interference in the process of transmission.

Interface rate:

IDE:133MB/s

SCIS:640MB/s

The serial interface is divided into STAT,SAS,USB, three kinds of interface, and the SATA interface is also used on our server and PC

Serial port:

SATA:6Gbps

SAS:6Gbps

USB:480MB/s

At present, there are two disk partition modes, MBR and GPT.

MBR mode

MBR: Master Boot Record, 1982, using 32 bits to represent the number of sectors, with no more than 2T partitions

The number of partitions that can be partitioned in MBR mode is: 4 primary partitions; 3 primary partitions + 1 extension (N logical partitions)

Of course, when the hard disk is partitioned, it needs some space to store the partition information, this part of the space is in track 0, sector 0: 512bytes.

Start 446bytes to store boot loader

The intermediate 64bytes holds the partition table, each 16bytes: identifies a partition

Finally, 2bytes: store 55AA to represent the hard disk mode type

GPT mode

GPT:GUID (Globals Unique Identifiers) partition table supports 128partitions, uses 64 bits, and supports 8Z (512Byte/block) 64Z (4096Byte/block)

Use 128bit UUID (Universally Unique Identifier) to indicate that the disk and partition GPT partition tables are automatically backed up at the beginning and end, with CRC check bits

UEFI (Unified extended firmware Interface) hardware supports GPT to enable the operating system to boot

Second, let's take a look at the capabilities of the three partitioning tools under Linux.

Old and strong, fdisk.

Fdisk is a very old partition tool in linux, although the tool is old, but simple and convenient is the advantage of fdisk, of course, gdisk also inherits this advantage, their functions are very similar, but the fdisk tool is mainly used to partition the hard disk in MBR mode, and the gdisk tool is used to partition the hard disk in GPT mode. Here is a fdisk tool. Fdisk cannot partition disks above 2T because MBR mode does not support partitioning formats above 2T.

Fdisk, gdisk tools

Fdisk / dev/sdb

Fdisk-l [- u] [device...] View information about hard drives and partitions

Common subcommands:

M help list

P Partition list

L View Partition Type

T change partition type

N create a new partition

D delete partition

W Save and exit

After fdisk partition, the operation is only in memory and does not really partition the hard disk. If you really need partition w to save it

Q do not save and exit

Of course, if you regret it, typing Q will not save the previous operation.

After the introduction of the options, let me do an experiment for you. Let everyone know how to use this tool.

[root@TianRandai ~] # fdisk / dev/sdb # operate on / dev/sdb 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 # create a partition Partition type: P primary (0 primary, 0 extended) 4 free) e extendedSelect (default p): P # partition type is the primary partition, p is the primary partition, e is the extended partition Partition number (1-4, default 1): 1 # specifies the partition number First sector (2048-41943039, default 2048): Using default value 2048Last sector, + sectors or + size {Kjommage G} (2048-41943039) Default 41943039): + 2GPartition 1 of type Linux and of size 2 GiB is setCommand (m for help): t # specifies the partition tag type Selected partition 1Hex code (type L to list all codes): 82Changed type of partition 'Linux' to' Linux swap / Solaris'Command (m for help): W # save operation The partition table has been altered calling ioctl () to re-read partition table.Syncing disks.

Powerful Partition tool parted

Parted

The partition of the parted tool is operated instantly, so you should be careful when using the partition, because you may partition the reused hard disk by accident, so you must be careful when using it.

Usage: parted [option]. [device [command [parameter].].]

Parted / dev/sdb mklabel gpt | msdos specifies the mode for the disk

Parted / dev/sdb print displays disk information

Parted / dev/sdb mkpart primary/extended/logical 0200 (default M) create partition type and size

Parted / dev/sdb rm 1 delete partition

Parted-l displays information for all disks

After the introduction of the options, let me do an experiment for you. Let everyone know how to use this tool.

[root@TianRandai ~] # parted / dev/sdb mklabel gpt # specifies the disk mode as 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. [root@TianRandai ~] # parted / dev/sdb mkpart primary 02G # creates a partition with a partition type of primary partition and a size of 2GWarning: The resulting partition is not properly aligned for best performance.Ignore/Cancel? I Information: You may need to update / etc/fstab. [root@TianRandai ~] # parted / dev/sdb print # View disk information 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 [root@TianRandai ~] # parted / dev/sdb rm 1 # Delete partition 1Information: You may need to update / etc/fstab. [root@TianRandai ~] # parted / dev/sdb print # check disk information again 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, the partition will be introduced and formatted.

Formatted commands can be used

Mkfs. File system type partition

# mkfs.ext4 / dev/sdb1

After formatting, you can use mounting.

[root@TianRandai ~] # mkfs # various types of file system mkfs mkfs.cramfs mkfs.ext3 mkfs.fat mkfs.msdos mkfs.xfsmkfs.btrfs mkfs.ext2 mkfs.ext4 mkfs.minix mkfs.vfat [root@TianRandai ~] # mkfs.ext4 / dev/sdb1 # format / dev/sdb1 as ext4 [root@TianRandai ~] # mkdir / mnt/disk1 # Create a disk1 directory under / mnt/ [root@TianRandai ~] # mount / dev/sdb1 / mnt/disk1 # to mount the partition of the formatted number to / mnt/disk1 Sahua girl [root@TianRandai ~] # df-h # to check the mount 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 0912M 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 formats partitions of type swap

Swapon is required to enable formatted partitions after formatting

Boot auto mount needs to be written to / etc/fstab about these configurations.

The specific mounting method will be explained later.

[root@TianRandai ~] # free-h # first look at the size of swap total used free shared buff/cache availableMem: 1.8G 483M 429M 10m 911m 1.1GSwap: 2.0G 0B 2.0G [root@TianRandai ~] # mkswap / dev/sdb1 # format / 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 [root@TianRandai ~] # swapon / dev/sdb1 # enable swap partition [root@TianRandai ~] # free-h # View swap size again total used free shared buff/cache availableMem: 1.8G 484m 427M 10M 911m 1.1GSwap: 3.9G 0B 3.9g Thank you for your reading! This is the end of this article on "what partitioning tools are under CentOS Linux". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report