Linux storage management (part 2)

Linux storage management (on)

Linux storage management (part 2)

File system

File system type

windows: FAT16 FAT32 NTFS
linux: EXT4 EXT3 XFS
index: directory, the first dozen pages of the dictionary

EXT4 file system
  • Type
    Index file system
  • Icon
    Insert picture description here
  • noun

Inode: Record the attributes of the file (metadata of the file), a file occupies an inode, and record the block number where the file is located. The inode size is 128 bytes. Metadata: file attribute, size, owner, group, connection number, block number, block number
bolck: the actual data of the file is stored, the actual content of the file is stored, if the file is large, it will occupy more block and block size The default is 4K

  • Create a file, observe the inode information
    Create a file
touch 1.txt

Observe inode information

ls -l -i 1.txt

Insert picture description here
The inode is 35349222, and the inode determines the number of files in the file system.
The disk space limit is based on two aspects: inode and block. Inode determines the number of files in the file system, while block determines the size of the file. A block is 4096k.

File link

File link is to send a link to a file to different locations. Visiting this file link is equivalent to visiting the source file.
File links are divided into two parts: symbolic links and hard links.

Symbolic link
  • Create a file
touch /home/file
  • Input content
ehco 111 > /home/file

If you want to view the file file at this time, you can only view the file file under /home, so how can you access the file file in different locations?

  • Create a soft connection
ln -s /home/file /file1
  • Observe the soft connection
    Insert picture description here

It is found that the type of the soft link and the source file are not the same. When we double-click the file1 file, 111 will appear

echo 123 >> /file1

Insert picture description here
Add content to the soft connection of file1 created in the root directory, write 123, and then return to /home to observe the source file.
Insert picture description here
It is found that the source file has also changed, indicating that the two files are one file. If the soft link of file1 is deleted, the content is still there. If the source file is deleted, the content is gone.
Soft links are like shortcuts, which can make soft links to files and folders. The soft link records only the absolute path of the source file. If the soft link loses the source file, it cannot be used.

Hard link
  • Successfully create hard links in the same partition, but fail to create hard links in different partitions
echo 22 > /file2
ln /file2 /file2-h1

Insert picture description here
The difference between hard link and soft link is that hard link does not depend on source files.
Hard links can only be done for files, not for folders. Hard links can only be done in the same partition, not in different partitions.

RAID

RAID: Disk array, function: fault tolerance, improve read and write speed

RAID type

RAID0: At least two hard disks, fast reading and writing speed, but not fault-tolerant.
RAID1: Commonly known as mirrored volume, mirrored set, the capacity of the mirrored volume is 50%, the read and write speed is average, and it is fault-tolerant.
Insert picture description here
RAID5: There are at least three hard drives, and they are of equal size.

Hard RAID and soft RAID

Hard RAID: Requires RAID card, own CPU, fast processing speed, battery and no battery.
Software RAID: realized through operating system, such as windows, linux

  • Prepare 4 hard disks
    Prepare 3 data disks and a hot spare disk
ls -l /dev/sd*
  • Create RAID
mdadm -C /dev/md0 -l5 -n3 -x1 /dev/sd{
    
    b,c,d,e}
  • Format, mount
mkfs.ext4 /dev/md0
mkdir /mnt/raid5
mount /dev/md0 /mnt/raid5/
cp -rf /etc/ mnt/raid5/etc1
df -hT
  • View RAID information
mdadm -D /dev/md0
  • Simulate a hard disk damage and remove it
mdadm /dev/md0 -f /dev/sdb -r /dev/sdb

Insert picture description here
Observe that the data is being reconstructed, and the data will not be lost.
linux search and compression

Guess you like

Origin blog.csdn.net/qq_45671732/article/details/109706956