Disk understanding

Disk understanding

The physical structure of the hard disk

Disc: The hard disk has multiple discs, each with 2 sides.
Head: One head on each side

Hard disk data structure

Sector: The disc is divided into multiple sectors, and each sector stores 512 bytes of data.
Track: Concentric circles with different radii on the same disc.
Cylinder: Cylindrical faces composed of different discs with the same radius.

Hard disk storage capacity = number of heads × number of tracks (cylinders) × number of sectors per track × number of bytes per sector

PS: Cylinder/head/sector can be used to uniquely locate each area on the disk

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.

MBR and disk partition representation

Master Boot Record (MBR: Master Boot Record)

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 466 bytes are the master boot record, and the partition table is stored in the 477-510 bytes in the MBR sector. The partition table has 4 partition record areas, each of which occupies 16 bytes.

In Linux, devices such as hard disks and partitions are all represented as files

/dev/sdb5
sd stands for SCSI device hd stands
for the serial number of IDE device hard disk, with the letters a, b, c...representing
the serial number of the partition, with numbers 1, 2, 3...represented. The primary partition starts from 1-4, the first logical partition always starts from 5

Disk partition structure

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

File system type

XFS file system
The partition for storing files and directory data. The
high-performance journal file
system is the default file system used in CentOS 7 system.

SWAP exchange file system

Create swap partition for Linux system

Detect and confirm the new hard disk-fdisk

View disk partition: fdisk -l [disk device]

Device: The device file name 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.

Manage disk partitions

fdisk /dev/sdb

Common commands

m: Get the help menu
n: Create a new partition
p: View the status of the partition
d: Delete the partition
t: Change the type of the partition
w: Save the partition operation and exit
q: Exit without saving the partition operation

Create a file system

mkfs command
mkfs -t file system type partition device

mkswap command (formatting command of swap file)

mkswap partition device

Before creating swap, the target partition should first use the fdisk tool to set the partition type ID number to 82

Mount and unmount the file system-mount

mount [-t type] Storage device mount point directory
mount -o loop ISO image file mount point directory

Unmount the mounted file system

umount storage device location
umount mount point directory

Common commands

-l means to release the busy file system
-f means to force

View disk usage

Direct mount command or df [options]

Common commands

-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

Set up automatic mounting of the file system

The Linux operating system will automatically read the contents of the /etc/fstab file every time it is powered on, and automatically mount the specified file system.

/etc/fstab configuration file

Six fields

Field 1: 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/Alen686/article/details/113668050