In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
In Linux, how are files stored, how is the logical composition of disk partitions realized, and how to partition, format, and mount the disk?
How the file is stored in the block group super block group description symbol
The file system is first divided into multiple block groups and super blocks. Each block group contains inode and data block, and each block group also contains inode bitmap and block bitmap;. Each block group also includes a block group descriptor.
The super block contains information such as volume label, mount time, UUID, magic number, file system characteristics, default options for mounting, file system status, OS type, related quantity of Inode and Block, size, available quantity, reserved space, and so on. Use tune2fs-l / dev/sda3 to view information about the super block.
GDT: records the number of unused inodes, the location of inode bitmap and datablock bitmap, the location of the inode table, and the number of free block and inode. Dumpe2fs / dev/sda3 | less can also use the-h parameter
What are the characteristics of the two linked files?
Hard links: multiple file paths to the same inode
Features: directories do not support the creation of hard links, hard links cannot be created across partitions, and creating hard links increases the inode reference count.
Ln passwd.back passwd.back2
Soft link: another file path that points to one file path
For a normal file, the inode pointer points to the location of the datablock, while the soft link points to the path of another file. The soft link in the file size is the number of bytes of the file path it points to.
Ln-s passwd.back passwd.sylink
[root@localhost tmp] # ls-il
Total dosage 12
33554511-rwx-. 1 root root 836 February 29 09:50 ks-script-XVVd4f
33554501-rw-r--r--. 2 root root 1099 March 1 11:37 passwd.back
33554501-rw-r--r--. 2 root root 1099 March 1 11:37 passwd.back2
33578842 lrwxrwxrwx. 1 root root 11 March 1 11:38 passwd.sylink-> passwd.back
Partition formatting mke2fs
Mke2fs [OPTIONS] device
-t {ext2 | ext3 | ext4}: indicates the type of file system to be created
Mkfs.ext4 = mkfs-t ext4 = mke2fs-t ext4
-b {1024 | 2048 | 4096}: indicates the block size of the file system
-L LABEL: indicates the volume label
-j: create a journaling file system ext3
Mke2fs-j = mke2fs-t ext3 = mkfs-t ext3 = mkfs.ext3
-I #: bytes-per-inode, indicating the ratio of inode to bytes; that is, creating an Indode for every number of bytes
By default, one inode for every 16K byte
-N #: directly indicates the number of inode to be created for this file system
-m #: specify reserved space, percentage
-O [^] FEATURE: creates the target file system with the specified properties
[root@localhost tmp] # mke2fs-t ext3-b 4096-L lq_data-I 32768-m 3 / dev/sda3
Mke2fs 1.42.9 (28-Dec-2013)
File system label = lq_data
OS type: Linux
Block size = 4096 (log=2)
Chunk size = 4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
655360 inodes, 5242880 blocks
157286 blocks (3.00%) reserved for the super user
First data block = 0
Maximum filesystem blocks=4294967296
160 block groups
32768 blocks per group, 32768 fragments per group
4096 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208
4096000
Allocating group tables: done
Writing inode table: complete
Creating journal (32768 blocks): complete
Writing superblocks and filesystem accounting information: done
Master Fdisk Partition
Please complete the experiment.
What is stored in the metadata area
The metadata area stores inode inode bitmaps and block bitmaps
Datastores are disk blocks.
Inode stores information about the permissions and attributes of the file. You can use stat / etc/passwd to view the metadata information of a file.
How to make the kernel recognize the new partition parx kpartx
Cat / proc/partitions
When we have partitioned a disk using fdisk and formatted the partition using the mke2fs tool, we need to let the kernel recognize our new partition.
At this point, you can use cat / proc/partitions to see if the kernel recognizes this partition.
If it is not recognized, ask the kernel to reread the partition information.
A. partx-tell the Linux kernel about the presence and numbering of on-disk partitions
-an Add the specified partitions, or read the disk and add all partitions.
Usage: partx-a / dev/sda
B. kpartx-Create device maps from partition tables
-an Add partition mappings
Usage: kpartx-a / dev/sda
If it doesn't come out once, please brush it again.
Create a swap partition and take effect
Mkswap / dev/sda6
Swapon
Create a 5G swap partition
Blkid locates or displays the attributes of the block device.
[root@localhost ~] # blkid / dev/sda3
Dev/sda3: LABEL= "lq_data" UUID= "f80f0e3d-9ccb-43a2-ac30-98722a8a6ea2" TYPE= "ext3"
[root@localhost] # blkid-L lq_data
/ dev/sda3
[root@localhost] # blkid-U f80f0e3d-9ccb-43a2-ac30-98722a8a6ea2
/ dev/sda3
[root@localhost] # blkid-t TYPE=ext3
/ dev/sda3: LABEL= "lq_data" UUID= "f80f0e3d-9ccb-43a2-ac30-98722a8a6ea2" TYPE= "ext3
E2label view and set the volume label. If you do not follow the volume label, you will view the volume label. If you follow the volume label, you will set a new volume label.
E2label device [LABEL]
[root@localhost ~] # e2label / dev/sda3
Lq_data
[root@localhost ~] # e2label / dev/sda3 DATA
[root@localhost ~] # e2label / dev/sda3
DATA
[root@localhost ~] # blkid / dev/sda3
Dev/sda3: LABEL= "DATA" UUID= "f80f0e3d-9ccb-43a2-ac30-98722a8a6ea2" TYPE= "ext3"
Tune2fs: adjust file system parameters on ext series file systems, of which-O and-o are the most useful
-l view the contents of the super block
-j upgrade ext2 to ext3, lossless upgrade
-L sets the volume label
-m is not formatted, adjust the percentage of reserved space, default is 5%
-O [^] feature adjusts the specified property
-o adjust default mount options
Tune2fs-o acl / dev/sda5
[root@localhost] # mke2fs-t ext2-L TEST-m 10 / dev/sda3
Next, we adjust the properties of the file system through tune2fs, which I first try to do in the mount state.
[root@localhost ~] # mount / dev/sda3 / mnt
a. Upgrade the file system type to ext3
[root@localhost] # tune2fs-j / dev/sda3
Tune2fs 1.42.9 (28-Dec-2013)
Creating journal inode: done
[root@localhost ~] # blkid / dev/sda3
Dev/sda3: LABEL= "TEST" UUID= "96361554-d8a3-43cb-860d-45ce26daaeff" SEC_TYPE= "ext2" TYPE= "ext3"
b. Set the volume label to Corun
[root@localhost] # tune2fs-L Corun / dev/sda3
Tune2fs 1.42.9 (28-Dec-2013)
[root@localhost ~] # blkid / dev/sda3
Dev/sda3: LABEL= "Corun" UUID= "96361554-d8a3-43cb-860d-45ce26daaeff" SEC_TYPE= "ext2" TYPE= "ext3"
c. Change the percentage of space reserved to 2%
[root@localhost] # tune2fs-m 2 / dev/sda3
Tune2fs 1.42.9 (28-Dec-2013)
Setting reserved blocks percentage to 2% (104857 blocks)
Dumpe2fs: displays attribute information for ext series file systems
Dumpe2fs / dev/sda5
Dumpe2fs-h / dev/sda5
Fsck and e2fsck
Special tools for ext series file systems:
E2fsck: check a Linux ext2/ext3/ext4 file system
E2fsck [OPTIONS] device
-y: automatically answer yes to all questions
-f: force detection even if the file system is in the clean state
Fsck:check and repair a Linux file system
-t fstype: indicates the file system type
Fsck-t ext4 = fsck.ext4
-a: automatically fix all errors without interaction
-r: interactive repair
Mounting and unmounting of file system
Mount DEVICE DIR
Umount DEVICE | DIR
Example:
Mount / dev/sda3 / mnt
Umount / dev/sda3
Nan should note that the mount point should be an empty directory, and it is recommended that you place the mount point on the file system where the root is located.
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.