In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail the example analysis of disk storage and file system in CentOS8. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.
Zoning
Two partition formats: MBR and GPT
MBR partition
The partition table information of the MBR partition disk is stored in the 0th sector of track 0 of the hard disk with a total of 512 bytes.
The first 446 bytes are bootloader
The middle 64 bits are disk partition table information, each partition information accounts for 16 bytes, storing a total of 4 partitions. (this is the data that needs to be backed up.)
The last 55AA is the end marker.
MBR partition structure
1. The hard disk master boot record MBR consists of four parts.
two。 The master bootstrap (offset address 0000H--0088H), which is responsible for loading from the active partition and running
System bootstrap
3. Error message data area, offset address 0089H--00E1H is error message, 00E2H--01BDH is all
0 byte
The partition table (DPT,Disk Partition Table) contains 4 partition items, offset address 01BEH--01FDH
Each partition table item is 16 bytes long, and a total of 64 bytes are partition item 1, partition item 2, partition item 3, partition item 4
The 2 byte values of the offset address 01FE--01FF are the closing flag 55AA.
MBR structure
GPT partition
Supports 128partitions, uses 64 bits, and supports 8Z (512Byte/block) 64Z (4096Byte/block)
Use 128bit UUID to represent disk and partition GPT partition tables
Automatic backup in head and tail, with CRC check bit
UEFI (Unified extended firmware Interface) hardware supports GPT to enable the operating system to boot
GPT partition structure
Commands for managing partitions list block device lsblk
Lists information about all available block devices and shows the dependencies between them
-a: show all devices
-b: displays the device size in bytes mode
-f: displays file system information
Create Partition tool fdisk create MBR Partition
-l [- u] [device...] View partition
Subcommand
P Partition list
T change partition type
N create a new partition
D delete partition
V check partition
U conversion unit
W Save and exit
Q do not save and exit
Gdisk creates GPT Partition
GPT Partition tool for Class fdisk
Parted Advanced Partition Operation
The parted operation takes effect in real time, so please use it carefully.
-l: lists partition information
Synchronize partition table
Check to see if the kernel recognizes the new partition
Cat / proc/partations
Centos6 informs the kernel to reread the hard disk partition table.
For new partitions
Partx-a / dev/DEVICE
Kpartx-a / dev/DEVICE-f: force
Delete partition for
Partx-d-nr Mmurn / dev/DEVICE
CentOS5,7 uses partprobe
Partprobe [/ dev/DEVICE]
Reread the partition table, and when the deleted file appears, it still takes up space. Partprobe can reread the partition without rebooting.
A file system is a method and data structure used by the operating system to identify files on a storage device or partition; that is, a method of organizing files on a storage device. The software structure responsible for managing and storing file information in the operating system is called the file management system. From the system point of view, the file system organizes and allocates the space of the file storage device. a system that is responsible for file storage and for protecting and retrieving stored files. Specifically, it is responsible for establishing file systems for users, storing, reading, modifying, dumping files, controlling file access, security control, logging, compression, encryption, etc., supported in Linux.
Ll / lib/modules/uname-r/kernel/fs
Create a file system
Mkfs
Mkfs.FS_TYPE / dev/DEVICE
-t: specify the file system
Create ext file system fs:ext series file system special management tool
-t {ext2 | ext3 | ext4} specify the file system type
-b {1024 | 2048 | 4096} specify block size
-L 'LABEL' sets the volume label
-j is equivalent to-t ext3
mkfs.ext3 = mkfs-t ext3 = mke2fs-j = mke2fs-t ext3
-I # create an inode; for every number of bytes in the data space should not be less than the block size
-N # specifies how many inode are created in the partition
-I the amount of disk space occupied by an inode record, 128 Murray 4096
-m # defaults to 5%, reserved space for managers as a percentage of total space
-O FEATURE [,...] Enable specified properties
-O ^ FEATURE turns off the specified feature
File system label blkid: block device attribute information view
-U UUID finds the corresponding device based on the specified UUID
-L LABEL finds the corresponding device based on the specified LABEL
E2label: LABELfindfs for managing ext series file systems: finding partitions
findfs [options] LABEL=\
findfs [options] UUID=\
Tune2fs: reset the value of the adjustable parameters of the ext series file system
-l view the super block information of the specified file system; super block
-L 'LABEL' modifies volume label
-m # percentage of space reserved for administrators
-j upgrades ext2 to ext3
The -O file system property is enabled or disabled,-O ^ has_journal
-o adjusts the default mount option for the file system,-o ^ acl
-U UUID modifies UUID number
Dumpe2fs
Group management of disk blocks
-h: view super block information without displaying grouping information
File system detection and repair
Often occurs after a crash or abnormal shutdown, mount the file system marked "no clean"
Note: do not repair in the mounted state
Fsck: File System Check
fsck.FS_TYPE
fsck-t FS_TYPE
-p automatically fixes errors
-r interactively fix errors
FS_TYPE must be the same as the file type already on the partition
A special detection and repair tool for e2fsck:ext series files
-y automatically answers as yes
-f mandatory repair
Mount the file system with the mount command
Mount: the act of associating an additional file system with an existing directory in the root file system, thus making this directory an entry for other files
Associate the device with the mount point: mount Point
mount
When uninstalling: you can use a device or a mount point
umount device name | Mount point
The original file under the mount point will be temporarily hidden after the mount is completed.
The mount point directory is generally empty
Mount
Display all currently mounted devices by viewing the / etc/mtab file
Common command options
-t vsftype specifies the file system type on the device to be mounted
-r readonly, read-only mount
-w read and write, read-write mount
-n is not updated / etc/mtab,mount is not visible
-a automatically mounts all devices that support automatic mount (defined in the / etc/fstab file, and there is an auto function in the mount option)
-L 'LABEL' specifies the mount device with volume label
-U 'UUID' specifies the device to be mounted in UUID
-B,-- bind bind directory to another directory
View all mounted devices traced to the kernel by cat / proc/mounts
-o options: (option to mount the file system), multiple options separated by commas
Ync Asynchronous Mode
Sync synchronization mode, writing to disk when memory changes
Atime/noatime contains directories and files
Access timestamp of diratime/nodiratime directory
Does auto/noauto support automatic mounting and the-an option?
Does exec/noexec support running applications on the file system
Does dev/nodev support the use of device files on this file system
Does suid/nosuid support suid and sgid permissions?
Remount remount
Ro read-only
Rw read and write
Does user/nouser allow ordinary users to mount this device, / etc/fstab uses
Acl enables the acl feature on this file system
Loop uses loop devices
_ netdev mounts network resources only when the network is available, such as NFS file system
Defaults is equivalent to rw, suid, dev, exec, auto, nouser, async
Umount
Mount command
Check the mount status
Findmnt MOUNT_POINT | device
View the processes that are accessing the specified file system
Lsof MOUNT_POINT
Fuser-v MOUNT_POINT
Terminates all processes that are accessing the specified file system
Fuser-km MOUNT_POINT
Unloading
Umount DEVICE
Umount MOUNT_POINT
Example
Mount sdb1
Judge whether to mount or not
Remount
Mknod creates device files
Uninstall sdb2
Cannot unmount if it is in use
View user processes that are using mounted devices
Forcibly stop using mount points
File mount configuration file etc/fstab defines a file system to be mounted per line
1. The device or pseudo file system to be mounted
Device file
LABEL:LABEL= ""
UUID:UUID= ""
Pseudo file system name: proc, sysfs
2. Mount point
3. File system type: ext4,xfs,iso9660,nfs,none
4. Mounting options: defaults, acl,bind
5. Dump frequency: 0: no backup 1: dump every day 2: dump every other day
6. The order of file systems checked by fsck: the allowed number is 0 1 2
0: no self-test
1: self-check first; generally only rootfs is used.
2: non-rootfs use
Swap swap partition swap swap partition is a complement to system RAM, and Swap partition supports virtual memory. When there is not enough RAM to hold the data processed by the system, the data will be written to the swap partition. When the system lacks swap space, the kernel will run out of RAM memory and terminate the process. Configuring too much swap space will cause storage devices to be allocated but idle, resulting in waste, and too much swap space will also mask memory leaks to enable swap swap partition swapon [OPTION]. [DEVICE]-a: activate all swap partitions-p PRIORITY: specify priority / etc/fstab in column 4: pri=value disables swap swap partition
Swapoff [OPTION]... [DEVICE]
The priority of swap can specify the priority of swap partition from 0 to 32767. If the user does not specify the priority, the core will automatically assign a priority to the swap. This priority starts from-1. Each new swap without user-specified priority will subtract one from this priority and the default priority of the added swap is higher, unless the user specifies a priority. The priority specified by the user (positive) is always higher than the core default (negative) to optimize performance: distributed storage, high-performance disk storage. This is the end of the article on "sample analysis of disk storage and file systems in CentOS8". I hope the above content can be helpful to you, so that you can learn more knowledge, if you think the article is good. Please share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.