Linux Operation and Maintenance Basic System Disk Management Tutorial

Linux Operation and Maintenance Basic System Disk Management Tutorial

1. Disk partition:

insert image description here

insert image description here

insert image description here

insert image description here

2. fdisk partition

If the disk is smaller than 2 TB, use fdisk partition; if it is larger than 2 TB, use gdisk partition

1. Check the disk status [root@localhost ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
fd0 2:0 1 4K 0 disk 
sda 8:0 0 20G 0 disk 
├─sda1 8:1 0 500M 0 part /boot
└─sda2 8:2 0 19.5G 0 part 
  ├─rhel-root 253:0 0 17.5G 0 lvm /
  └─rhel-swap 253:1 0 2G 0 lvm [SWAP]
sdb 8:16 0 20G 0 disk 
sdc 8:32 0 20G 0 disk 
sr0 11:0 1 3.5G 0 rom 
2. Partition [root@localhost ~]# fdisk /dev/sdb
Command (enter m to get help): n //Create a new partition Partition type:
   p primary (0 primary, 0 extended, 4 free) //Primary partition e extended //Extended partition Select (default p): p //Select the primary partition number (1-4, default 1):
Starting sector (2048-41943039, default is 2048):
The default value of 2048 will be used
Last sector, +sectoror +size{K,M,G} (2048-41943039, default is 41943039): +99MB
Partition 1 is set to Linux type and 94 MiB in size
Command (enter m to get help): n //Create a new partition Partition type:
   p primary (1 primary, 0 extended, 3 free)
   e extended //Extended partition Select (default p): e
Partition number (2-4, default 2):
Starting sector (194560-41943039, default is 194560):
The default value of 194560 will be used
Last sector, +sectoror +size{K,M,G} (194560-41943039, default is 41943039):
The default value of 41943039 will be used
Partition 2 has been set to Extended type and size set to 19.9 GiB
//Create logical partition command (enter m to get help): n //Create new partition Partition type:
   p primary (1 primary, 1 extended, 2 free)
   l logical (numbered from 5)
Select (default p): l //Create logical partitions and add logical partition 5
Starting sector (196608-41943039, default is 196608):
The default value of 196608 will be used
Last sector, +sectoror +size{K,M,G} (196608-41943039, default is 41943039): +100MB
Partition 5 is set to Linux type and 95 MiB in size
Command (type m for help): p //View partition creation Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes/512 bytes I/O size (minimum/optimal): 512 bytes/512 bytes Disk label type: dos
Disk identifier: 0xf812a8fb
   DeviceBoot Start End Blocks Id System
/dev/sdb1 2048 194559 96256 83 Linux
/dev/sdb2 194560 41943039 20874240 5 Extended
/dev/sdb5 196608 391167 97280 83 Linux
Command (type m for help): w //Keep partitions The partition table has been altered!
Calling ioctl() to re-read partition table.
Synchronizing disks.

3. Disk formatting

1.Format disk file type [root@localhost ~]# mkfs.
mkfs.btrfs mkfs.cramfs mkfs.ext2 mkfs.ext3 mkfs.ext4 mkfs.minix mkfs.xfs 
2. Format as xfs file system [root@localhost ~]# mkfs.xfs /dev/sdb1
 Finish

4. Permanently mount the disk

//Use the blkid command to obtain the UUID of each partition
[root@localhost ~]# blkid |grep "sdb1"
/dev/sdb1: UUID="e271b5b2-b1ba-4b18-bde5-66e394fb02d9" TYPE="xfs"
//Use UUID to mount the disk sdb1 partition As for db1, temporarily mount [root@localhost ~]# mount UUID="e271b5b2-b1ba-4b18-bde5-66e394fb02d9" /db1
//You can also write the following line to /etc/fstab to mount it permanently and automatically mount it when the computer starts [root@localhost ~]# tail -1 /etc/fstab
UUID=e271b5b2-b1ba-4b18-bde5-66e394fb02d9 /db1 xfs defaults 0 0
//Load the fstab configuration file and check if there are any syntax errors [root@localhost ~]# mount –a
1. Use the blkid command to obtain the UUID of each partition
[root@localhost ~]# blkid |grep sdb1
/dev/sdb1: UUID="00e35670-d6c9-44d1-8e8c-f52bd71edf59" TYPE="xfs"
2. Write the following line to /etc/fstab to mount it permanently and automatically at boot time [root@localhost ~]# tail -1 /etc/fstab    
UUID=00e35670-d6c9-44d1-8e8c-f52bd71edf59 /oppo xfs defaults 0 0

Introduction to the fstab configuration file:

root@localhost ~]# vim /etc/fstab
1//Partition ID (UUID or device name) 2//Mount point 3//File type 4//Mount parameters 5//Do not check 6//Do not back up 1//00e35670-d6c9-44d1-8e8c-f52bd71edf59 2///oppo 3//xfs 4//defaults 5//0 6// 0
//Mount parameters, you can write fstab configuration file, or use -o parameter to specify parameters when mounting. Parameter meaning system default value async system writes memory data to disk at regular intervals.
sync synchronizes data in memory and disk from time to time;
suid, nosuid allow/disallow partitions to have suid attributessuid
rw, ro You can specify whether the file system is read-only (ro) or writable (rw) rw
exec, noexec allow/disallow executable file execution, do not mount the root partition exec
user, nouser Allow/disallow users other than root to mount partitions nouser
auto, noauto Automatically mount at boot/not automatically mount auto
default default file system mount settings rw, suid, dev, exec, auto, nouser, async
//Load all configurations [root@localhost ~]# mount -a

Check disk mount status

[root@localhost ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
fd0 2:0 1 4K 0 disk 
sda 8:0 0 20G 0 disk 
├─sda1 8:1 0 500M 0 part /boot
└─sda2 8:2 0 19.5G 0 part 
  ├─rhel-root 253:0 0 17.5G 0 lvm /
  └─rhel-swap 253:1 0 2G 0 lvm [SWAP]
sdb 8:16 0 20G 0 disk 
├─sdb1 8:17 0 191M 0 part /oppo
├─sdb2 8:18 0 1K 0 part 
└─sdb5 8:21 0 95M 0 part 
sdc 8:32 0 20G 0 disk 
sr0 11:0 1 3.5G 0 rom /mnt

The above is the detailed content of the Linux operation and maintenance basic system disk management tutorial. For more information about Linux operation and maintenance basic system disk management, please pay attention to other related articles on 123WORDPRESS.COM!

You may also be interested in:
  • Linux operation and maintenance basic swap partition and lvm management tutorial
  • Linux operation and maintenance basic process management real-time monitoring and control
  • Linux operation and maintenance basic process management and environment composition analysis
  • Linux operation and maintenance basics httpd static web page tutorial

<<:  Vue+Openlayer realizes the dragging and rotation deformation effect of graphics

>>:  How to create a style guide for your website in web interface design (with pictures and text)

Recommend

CSS stacking and z-index example code

Cascading and Cascading Levels HTML elements are ...

How to operate Linux file and folder permissions

Linux file permissions First, let's check the...

js to realize a simple puzzle game

This article shares the specific code of js to im...

Detailed process of installing various software in Docker under Windows

1. Install MySQL # Download mysql in docker docke...

17 excellent web designs carefully crafted by startups

Startups often bring us surprises with their unco...

Detailed tutorial on installing MySQL 8 in CentOS 7

Prepare Environmental information for this articl...

Vue parent-child component mutual value transfer and call

Table of contents 1. Parent passes value to child...

Implementation of Element-ui Layout (Row and Col components)

Table of contents Basic instructions and usage An...

Using js to implement the two-way binding function of data in Vue2.0

Object.defineProperty Understanding grammar: Obje...

Teach you how to use docker-maven-plugin to automate deployment

1. Introduction to docker-maven-plugin In our con...

An article teaches you how to use js to achieve the barrage effect

Table of contents Create a new html file: Create ...

Docker configures the storage location of local images and containers

Use the find command to find files larger than a ...

How to use Dayjs to calculate common dates in Vue

When using vue to develop projects, the front end...