System partition management

1. Devices on Linux

In the Linux operating system, various device drivers (device drivers) manage various devices (devices) through the device controller (device controller)
System partition management
. :
System partition management
/dev/vda means the first virtual hard disk
/dev/sda means the first hard disk with SATA interface
/dev/hd0 means the first hard disk with IDE interface
/dev/mapper/ means it is virtualized by software equipment

2. Check the equipment

fdisk -l View the real devices in the system
cat /procpartition View the devices recognized by the system
blkid View the devices used by the
System partition management
system There are two virtual disks in the system, both 10.7G,
/dev/vda has only one partition, /dev/vdb is not partitioned

3. Disk partition

Partition information = MBR (446 bytes) + MPT (64) + 55aa (2 bytes)
MBR is the master boot record, which is used to read the operating system's own boot program into the memory and jump to the operating system's boot program. It has nothing to do with any operating system itself.
MPT is the main partition table. Its function is to divide a single physical hard disk into several relatively independent areas, so that we can use the hard disk more conveniently.
55aa is the validity of the hard disk indicating
the difference between MBR and GPT
: In personal PCs, the MBR partitioning method is basically used, but the disadvantage of the MBR method is that it can only support up to 2TB, and there is a GPT partitioning method. The maximum support is 18EB.
Partition: MBR supports P+P+P+E, primary partition and expandable partition (most PCs are MBR mode, in WINDOWS system, this is why MBR only supports 4 partitions, but there are C, D, E , F, G disk relationship, the reason is that in the extended partition, it is partitioned again and divided into more disks, but please note that the scalable partition is similar to a container, and the container is re-partitioned. If the partition is killed, all other partitions in the container will be gone). The GPT method does not distinguish between primary partitions or expandable partitions, and can be divided into 128 partitions, regardless of whether they are primary or expandable.
How to check whether the partition mode is mbr or gpt. You can modify the parted /dev/vdb of
System partition management
which partition mode by yourself. Change the vdb disk to gpt format and check it again.

System partition management

System partition management

Fourth, the disk partition

Detailed explanation of fdisk command parameters
m help
d delete
n create
p primary partition
e extended partition, pay attention to give all the remaining space to the extended partition
w write the current operation into the hard disk partition table
t modify the partition id
p display the partition table information
q exit
l List all partition types
Use this to partition the disk
System partition management

If there is an error when saving and exiting, it means that the policy has not been flushed to the disk, and partprobe can be used to flush to the disk partition table.
System partition management

5. File system

Although the disk has been partitioned, this block of partition cannot be used directly.
This disk needs to be formatted. A relatively simple understanding of the file system is to use the file system to refresh the operation of the file. to disk.
Common file systems are ext2, ext3, ext4, fat, vfat, ntfs.
After formatting the partition, you can use blkid to view it, and then you can mount and use this block partition.
System partition management
If you need to mount the disk and implement self-starting at boot, the /etc/fstab file is used.
System partition management
The meanings of the five parameters in this file are
/dev/vdb1: the name of the device to be mounted
/mnt: the point at which the file system is to be mounted
xfs: what is the type of the block device file system
defaults: rw, suid , dev, exec, auto, nouser, and async.
0: No backup (use dump for backup)
0: No detection (use fsck for detection)
Use mount -a after the file is written, and use df to view it ,
Note: This file should be written very carefully, because the system will read the contents of this file and mount it automatically when it is turned on. If the parameters in this file or the device to be mounted are incorrect, the system will not It can be started normally.
System partition management
After mount -a, the
application instance
has been successfully mounted. If you find that the swap partition is not enough during system use, you can separate a partition from the disk for formatting. Modify it to the type of swap), and write this in the fstab file to expand the size of the swap partition.
fdisk /dev/vdb
uses l to change a new partition type to swap type
System partition management
Format: mkswap /dev/vdb2
System partition management
write this policy as fstab file,
System partition management

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325266347&siteId=291194637