In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail how to manage disks and file systems in Linux. The content of the article is of high quality, so the editor will share it with you for reference. I hope you will have some understanding of the relevant knowledge after reading this article.
Linux disk and file system management
There are two main formats of disk partition tables, one is the MBR partition table with more restrictions, and the other is the newer and less restricted GPT partition table. In the MBR partition table, the first sector is the most important, which includes: (1) the main boot areas (Master boot record, MBR) and partition table (partition table), of which MBR occupies 446 Bytes and partition table occupies 64 Bytes. In addition to expanding the number of partitions, the GPT partition table can also support more disk capacity than 2TB.
File system Properti
The file system usually stores these two parts of data in different blocks, permissions and attributes in the inode, and the actual data in the data block block. In addition, there is a super block (superblock) that records the overall information of the entire file system, including the total amount of inode and block, usage, remaining, and so on.
Superblock: record the overall information of this filesystem, including the total amount, usage, and remaining amount of inode/block, as well as the format and related information of the file system.
Inode: records the attributes of a file. A file occupies an inode and records the block number where the file's data is located.
Block: actually record the contents of the file. If the file is too large, it will take up multiple block.
EXT2 file system (inode) for Linux
When Ext2 is formatted, it looks a bit like this:
The six main contents of each block group (block group) are as follows:
Data block (data chunk) data block is used to place file content data. The block sizes supported in the Ext2 file system are 1K, 2K and 4K. The size of the block is fixed when formatted, and each block is numbered to facilitate the recording of the inode.
Inode table (inode form)
The content of inode is recorded in the attributes of the file and which number of block the actual data of the file is placed in! Basically, inode records at least the following file data: the access mode of the file (read/write/excute); the owner and group of the file (owner/group); the capacity of the file; the time the file was created or changed (ctime); the last read time (atime); the last modified time (mtime); and the flag that defines the file's characteristics, such as SetUID... The pointer of the real content of the file
Superblock (super block) Superblock is a place where information about the entire filesystem is recorded. Without Superblock, there would be no filesystem. The main information he recorded are:
The total amount of block and inode; the number of unused and used inode / block; the size of block and inode (block is 1,2,4K score Inode is 128Bytes or 256Bytes); filesystem mount time, the last time to write data, the last time to check the disk (fsck) and other file system related information; a valid bit value, if the file system has been mounted, then valid bit is 0, if not mounted, then valid bit is 1.
Filesystem Description (File system description) this section describes the block number at the beginning and end of each block group, as well as which block number each segment (superblock, bitmap, inodemap, data block) lies between. This part can also be observed by dumpe2fs.
Block bitmap (Block comparison Table) if you want to add files, you will always use block! Which block do you want to use to record it? Of course, choose "empty block" to record the data of the new file. Then how do you know which block is empty? This has to be assisted by block bitmap. You can know which block is empty from block bitmap, so our system can quickly find available space to dispose of files. Similarly, if you delete certain files, the block number originally occupied by those files will have to be released, and the logo corresponding to the block number in block bitmap will have to be changed to "not in use". This is what bitmap does.
Inode bitmap (inode comparison Table) is actually a function similar to block bitmap, except that block bitmap records used and unused block numbers, while inode bitmap records used and unused inode numbers.
Dumpe2fs: an instruction to query the superblock information of the Ext family
Dumpe2fs / dev/vda5
The access of EXT2/EXT3/EXT4 files and the function of journal file system
The journal file system (journal) will have an extra recording area to record the main activities of the file system at any time, which can speed up the recovery time of the system.
The meaning of the mount point (mount point)
The act of combining a file system with a directory tree is called a mount. The point is: the mount point must be a directory, which is the entry into the file system. So you don't have any file system that you can use, and you have to "mount" it to a directory in the directory tree before you can use it.
Simple operation of the file system
Df: lists the overall disk usage of the file system; du: evaluates the disk usage of the file system (commonly used in the estimated directory capacity)
Entity links and symbolic links: ln
Hard Link (physical link, hard link, or actual link)
Suppose my system has a physical link to / root/crontab that is / etc/crontab, that is, these two file names are linked to the same inode.
Symbolic Link (symbolic links, i.e. shortcuts)
This shortcut between Symbolic Link and Windows can equate him. The file created by Symbolic link is a separate new file, so it takes up inode and block.
Partitioning, formatting, verification and mounting of disks
What actions should we do if we want to add a disk to the system:
Partition the disk to create an available partition
Format (format) the partition to create a filesystem available to the system
If you want to be more careful, you can verify the filesystem you just created
On a Linux system, you need to create a mount point (that is, a directory) and mount it
Observe disk partition status
Lsblk lists all disks on the system
Blkid lists parameters such as UUID of the device
Parted lists the partition table type and partition information of the disk
Disk partitions: gdisk/fdisk
Disk formatting (create file system)
XFS file system mkfs.xfs
XFS File system for RAID performance Optimization (Optional)
EXT4 file system mkfs.ext4
Other file system mkfs
File system inspection
Xfs_repair handles XFS file system
Fsck.ext4 handles EXT4 file system
File system mount and unmount
Mount
A single file system should not be mounted repeatedly in different mount points (directories)
Multiple file systems should not be mounted repeatedly in a single directory
Directories that are used as mount points should theoretically be empty directories.
Set up boot mount
Boot mount / etc/fstab and / etc/mtab, in fact, / etc/fstab (filesystem table) is to write all the options and parameters to this file when we mount using the mount instruction.
Creation of memory swap space (swap)
Create a swap using entity partitions
Create a swap using a file
On how to manage the disk and file system in Linux to share here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can 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.