Disk Management and File System

Disk Management and File System

1. Disk structure

1. The physical structure of the disk

Pan head: The hard disk has multiple platters, each with 2 sides.
Magnetic head: One head on each side

2. The data structure of the disk

Sector: The disk is divided into multiple sectors. Each sector stores 512 bytes of data. The smallest storage unit
track of the hard disk : Concentric circles with different radii on the same disk are drawn on the surface of the disk by the magnetic head. Circular track
Cylindrical surface: a cylindrical surface composed of different discs with the same radius, composed of multiple tracks with the same radius

3. Disk storage capacity

Hard disk storage capacity = number of heads x number of tracks (cylinders) x number of sectors per track x number of bytes per sector (512 bytes)
cylinders/heads/sectors can be used to uniquely locate each area on the disk

4. Disk interface type

IDE, SATA, SCSI, SAS, Fibre Channel

IDE: The parallel port data cable connects the motherboard and the hard disk. The anti-interference is too poor, and the cable takes up a lot of space, which is not good for the internal heat dissipation of the computer. It has been gradually replaced by SATA.
SATA: strong anti-interference, support hot swap and other functions, fast speed, strong error correction ability.
SCSI: Minicomputer system interface. SCSI hard disks are widely used by workstation-class personal computers and servers. The CPU occupancy rate is low during data transmission, the speed is fast, and it supports hot swapping.
SAS: It is a new generation of SCSI technology, which is the same as SATA hard disks. It adopts serial technology to obtain higher transmission speed, which can reach 6Gb/s.

2. Disk partition representation

In the Linux system, hard disks, partitions and other devices are all expressed as files.
Example: /dev/sdb5
sd means SCSI device
hd means IDE device
. The serial number of the hard disk. The letters a, b, c... indicate
the serial number of the partition, with the number 1 , 2, 3...... means. The primary partition starts from 1-4, and the first logical partition always starts from 5.

Master boot record (MBR) disk partition

MBR is the master boot record, which is located at the first physical sector of the hard disk. The MBR contains the master boot program and hard disk partition table of the hard disk. The MBR has a total of 512 bytes, the first 446 bytes are the master boot record, and the partition table is stored in the 447-510 bytes in the MBR sector. The partition table has 4 partition record areas, each of which occupies 16 bytes.

The master boot record (MBR) disk partition supports a maximum volume of 2.2TB, and each disk has up to 4 primary partitions, or 3 primary partitions, 1 extended partition and multiple logical partitions in the extended partition).

Disk partition structure

1. There are only 4 primary partitions in the hard disk.
2. The serial numbers of primary and extended partitions are limited to 1~4
. 3. Extended partitions are divided into logical partitions
. 4. The number of logical partitions will always start from 5.

Three. File system type

1.XFS file system

Partition for storing files and directory data A
high-performance log file system, especially good at handling large files, can support millions of terabytes of storage space
, the file system used by default in CentOS 7

2.SWAP exchange file system

Establish a swap partition for the Linux system,
generally set to 1.5~2 times the physical memory

3. Other file system types supported by linux

EXT3、EXT4、FAT32、NTFS、LVM

4. Detect and confirm the new hard disk fdisk command

View or manage the disk partition
fdisk -l [disk device] or fdisk [disk device]
The meaning of each field in the disk information
Device (device): the name of the device file of the partition.
Boot: Whether it is a boot partition. If it is, it is marked with "*".
Start: The starting position (number of cylinders) of the partition in the hard disk.
End: The ending position (number of cylinders) of the partition in the hard disk.
Blocks: The size of the partition, in Blocks (block), the default block size is 1024 bytes.
Id: The system ID number corresponding to the partition. For example, 83 represents the XFS partition or EXT4 partition in Linux, and 8e represents the LVM logical volume.
System: Partition type.

V. Manage Disk Partitions


Common commands in fdisk /dev/sdb interactive mode
m: get help menu
n: create partition
p: view partition status
d: delete partition
t: change partition type
w: save partition operation and exit
q: exit without saving partition operation

After changing the partition settings of the hard disk (especially the hard disk in use), it is recommended to restart the system once, or execute the "partprobe" command to make the operating system detect the new partition table. To prevent damage to the existing data in the hard disk when formatting the partition.

Six. Create a file system mkfs command

The process of creating a file system is the process of formatting the partition
mkfs -t xfs /dev/sdb1
or
mkfs.xfs /dev/sdb1

Create swap file system mkswap command

mkswap [Partition device]
Before creating swap, the target partition should be set to 82 with the partition type ID number through the fdisk tool.
Commonly used commands
mkswap /dev/sdb5

swapon /dev/sdb5 #Enable the
newly added swap partition
swapoff /dev/sdb5 #Disable the
specified swap partition
swapon -s #View
the swap status information of each partition
f ree -m #View the
total swap status information

Seven. Mount and unmount the file system mount command

Mount the file system and ISO image to the specified folder
mount [-t type] Storage device mount point directory
mount -o loop ISO image file mount point directory

-t: used to specify the file system type, usually can be omitted, automatically recognized by the system
-o: mount parameter list, separated by English commas; if used to describe special equipment, use loop to specify the unmounting prerequisites for
unmounting the mounted file system
: The mounted device or directory is not in use, you must exit the mounted directory first.

umount [-lf] storage device directory or mount point directory
-lf: force unmount

8. View disk usage

1. Direct mount command

2.df [Options]
-h: display the capacity unit of the partition
-T: display the type of file system
-i: display the number of inode numbers of the partition

Nine. Set the automatic mounting of the file system: /etc/fstab configuration file

vim /etc/fstab
sets the automatic mounting of the file system. The
Linux operating system will automatically read the contents of the /etc/fstab file and automatically mount the specified file system every time it is powered on.
The meaning of
the configuration of the six fields . The first field: device name or device volume label name.
Field 2: The location of the mount point directory of the file system.
Field 3: File system type, such as xfs, swap, etc.
Field 4: Mount parameters, which are the parameters that can be used after the "-o" option of the mount command. For example, defaults (default parameters), rw (read and write), ro (read only), noexec (disable the execution of the program).
The fifth field: indicates whether the file system needs dump backup (dump is a backup tool). Generally, it is set to 1 to indicate need, and to 0, it will be ignored by dump.
Field 6: This number determines the sequence of disk checks when the system starts. 0 means no inspection, 1 means priority inspection, and 2 means second inspection. The root partition should be set to 1, and the other partitions should be set to 2.

Guess you like

Origin blog.csdn.net/Desire_cure_/article/details/113482728