With the rapid development of technology, more and more enterprises have higher and higher requirements for the stability of servers. More and more enterprises are beginning to use Linux systems to deploy their own services in order to achieve high efficiency and stability. Of course, Any operating system requires the most basic foundation, which is the hard disk and hard disk partitions. Today I will recommend several partition tools under CentOS Linux and how to view the partition environment. I will also give you some basic knowledge about hard disks
1. Hard disk interface type
Partitioning must be a partition of the hard disk, so let’s first talk about the interface type of the hard disk. The hard disk will be divided now. It is divided into two categories, parallel interface and serial interface. Nowadays, serial interface is commonly used on servers and PCs. OK interface.
Parallel interface is divided into two interfaces: IDE and SCSI. The disadvantage of the parallel interface is that electrical signals will cause interference during transmission.
Interface rate:
IDE:133MB/s
SCIS:640MB/s
Serial interfaces are divided into three interfaces: STAT, SAS, and USB. Our servers and PCs also use SATA interfaces
Serial port:
SATA:6Gbps
SAS: 6Gbps
USB:480MB/s
The current disk partition modes are divided into two types, MBR and GPT.
MBR Mode
MBR: Master Boot Record, 1982, uses 32 bits to represent the number of sectors, and the partition does not exceed 2T
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 and sector 0: 512 bytes.
Start 446 bytes to store boot loader
The middle 64 bytes store the partition table, and every 16 bytes: identifies a partition
The last 2 bytes: store 55AA to indicate the hard disk mode type
GPT Mode
GPT: GUID (Globals Unique Identifiers) partition table supports 128 partitions, uses 64 bits, supports 8Z (512Byte/block) 64Z (4096Byte/block)
Use 128-bit UUID (Universally Unique Identifier) to represent the disk and partition. The GPT partition table is automatically backed up in the first and last copies, and has a CRC check digit
UEFI (Unified Extensible Firmware Interface) hardware supports GPT, enabling the operating system to boot
2. Let us see the capabilities of the three partition tools under Linux.
Laodangyizhuang fdisk.
fdisk is a very old partitioning tool in Linux. Although the tool is old, simplicity and convenience are the advantages of fdisk. Of course, gdisk also inherits this advantage. Their functions are very similar, but the fdisk tool is mainly used to To partition a hard disk in MBR mode, the gdisk tool is used to partition a hard disk in GPT mode. Here we will talk about the fdisk tool. fdisk cannot target 2T
fdisk, gdisk tools
fdisk /dev/sdb
fdisk -l [-u] [device...] View hard disk and partition information
Commonly used 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 partitioning, the operation is only in the memory and does not actually partition the hard disk. If you really need to partition w, just save it
q Exit without saving
Of course, if you regret it, entering q will not save the previous operation
After introducing the options, let me do an experiment for you. Let everyone know how to use this tool.
[root@TianRandai ~]#fdisk /dev/sdb#对/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 #建立一个分区 Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): p #分区类型为主分区,p是主分区,e是扩展分区 Partition number (1-4, default 1): 1#指定分区号 First sector (2048-41943039, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039): +2G Partition 1 of type Linux and of size 2 GiB is set Command (m for help): t #指定分区标记类型 Selected partition 1 Hex code (type L to list all codes): 82 Changed 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 instantaneous, so you must be careful when partitioning, because you may accidentally partition the reused hard disk, so you must be cautious and cautious when using it.
Usage: parted [options]... [device [command [parameters]...]...]
parted /dev/sdb mklabel gpt|msdos specifies 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 displays information about all disks
选项介绍完,我来给大家做一个实验。让大家了解一下这款工具的使用方式。
[root@TianRandai ~]#parted /dev/sdb mklabel gpt #指定磁盘模式为GPT Warning: The existing disk label on /dev/sdb will be destroyed and all data on this disk will 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 0 2G #创建分区,分区类型为主分区,大小为2G Warning: 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 #查看磁盘信息 Model: VMware, VMware Virtual S (scsi) Disk /dev/sdb: 21.5GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: NumberStart End SizeFile systemName Flags 117.4kB2000MB2000MB primary [root@TianRandai ~]#parted /dev/sdb rm 1 #删除分区1 Information: You may need to update /etc/fstab. [root@TianRandai ~]#parted /dev/sdb print#再次查看磁盘信息 Model: VMware, VMware Virtual S (scsi) Disk /dev/sdb: 21.5GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: NumberStartEndSizeFile systemNameFlags
介绍完了分区就要介绍格式化了
格式化的命令可以使用
mkfs.文件系统类型 分区
#mkfs.ext4 /dev/sdb1
格式化后就可以使用挂载了
[root@TianRandai ~]#mkfs #文件系统的各个类型 mkfs mkfs.cramfsmkfs.ext3mkfs.fat mkfs.msdos mkfs.xfs mkfs.btrfs mkfs.ext2mkfs.ext4mkfs.minix mkfs.vfat [root@TianRandai ~]#mkfs.ext4 /dev/sdb1#将/dev/sdb1格式化为ext4
[root@TianRandai ~]#mkdir /mnt/disk1#在/mnt/下建一个disk1目录 [root@TianRandai ~]#mount /dev/sdb1 /mnt/disk1#将格式化号的分区挂载到/mnt/disk1撒花姑娘 [root@TianRandai ~]#df -h #查看挂载及使用情况 FilesystemSizeUsed Avail Use% Mounted on /dev/sda210G4.5G5.5G45% / devtmpfs898M 0898M 0% /dev tmpfs 912M 88K912M 1% /dev/shm tmpfs 912M9.0M903M 1% /run tmpfs 912M 0912M 0% /sys/fs/cgroup /dev/sda11014M169M846M17% /boot tmpfs 183M 20K183M 1% /run/user/0 /dev/sdb1 1.9G5.7M1.7G 1% /mnt/disk1
mkswap 格式化swap类型的分区
格式化后需要swapon来启用格式化后的分区
开机自动挂载需要讲这些配置写到/etc/fstab中
具体的挂载的方法会在后面具体讲解。
[root@TianRandai ~]#free -h#先看一下swap的大小 totalusedfreesharedbuff/cache available Mem: 1.8G483M429M 10M911M1.1G Swap:2.0G0B2.0G [root@TianRandai ~]#mkswap /dev/sdb1 #格式化/dev/sdb1分区 mkswap: /dev/sdb1: warning: wiping old ext4 signature. Setting up swapspace version 1, size = 1953104 KiB no label, UUID=5d9a150e-c247-4c7f-a4be-273a72bd3b5a [root@TianRandai ~]#swapon /dev/sdb1 #启用swap分区 [root@TianRandai ~]#free -h#再次查看swap大小 totalusedfreesharedbuff/cache available Mem: 1.8G484M427M 10M911M1.1G Swap:3.9G0B3.9G
The above is the detailed content of Detailed explanation of three disk partitioning tools on CentOS Linux. For more information, please follow other related articles on the PHP Chinese website!

linux设备节点是应用程序和设备驱动程序沟通的一个桥梁;设备节点被创建在“/dev”,是连接内核与用户层的枢纽,相当于硬盘的inode一样的东西,记录了硬件设备的位置和信息。设备节点使用户可以与内核进行硬件的沟通,读写设备以及其他的操作。

区别:1、open是UNIX系统调用函数,而fopen是ANSIC标准中的C语言库函数;2、open的移植性没fopen好;3、fopen只能操纵普通正规文件,而open可以操作普通文件、网络套接字等;4、open无缓冲,fopen有缓冲。

端口映射又称端口转发,是指将外部主机的IP地址的端口映射到Intranet中的一台计算机,当用户访问外网IP的这个端口时,服务器自动将请求映射到对应局域网内部的机器上;可以通过使用动态或固定的公共网络IP路由ADSL宽带路由器来实现。

在linux中,eof是自定义终止符,是“END Of File”的缩写;因为是自定义的终止符,所以eof就不是固定的,可以随意的设置别名,linux中按“ctrl+d”就代表eof,eof一般会配合cat命令用于多行文本输出,指文件末尾。

在linux中,可以利用“rpm -qa pcre”命令判断pcre是否安装;rpm命令专门用于管理各项套件,使用该命令后,若结果中出现pcre的版本信息,则表示pcre已经安装,若没有出现版本信息,则表示没有安装pcre。

linux查询mac地址的方法:1、打开系统,在桌面中点击鼠标右键,选择“打开终端”;2、在终端中,执行“ifconfig”命令,查看输出结果,在输出信息第四行中紧跟“ether”单词后的字符串就是mac地址。

手机远程linux工具有:1、JuiceSSH,是一款功能强大的安卓SSH客户端应用,可直接对linux服务进行管理;2、Termius,可以利用手机来连接Linux服务器;3、Termux,一个强大的远程终端工具;4、向日葵远程控制等等。

linux中,lsb是linux标准基础的意思,是“Linux Standards Base”的缩写,是linux标准化领域中的标准;lsb制定了应用程序与运行环境之间的二进制接口,保证了linux发行版与linux应用程序之间的良好结合。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Dreamweaver CS6
Visual web development tools

WebStorm Mac version
Useful JavaScript development tools