Chapter V, Section 1 Disk (2) 4.13

one,

1、        Superblock

  Superblock is a place to record information about the entire filesystem. Without Superblock, there would be no such filesystem.

  The total amount of blocks and inodes

  Number of unused and used inodes/blocks

  Size of block and inode (block is 1, 2, 4K, and inode is 128 bytes)

  Information about the file system, such as the mount time of the filesystem, the time when the data was last written, and the time when the disk was last checked (fsck).

  A valid bit value. If the file system is mounted, the valid bit is 0. If it is not mounted, the valid bit is 1.

2.         block bitmap (block comparison table)

Used and unused block numbers

1) Blocks will be used when adding files. You can know which blocks are empty in the block bitmap

2) When deleting a file, the block number originally occupied by the file needs to be released, and the relative block flag in the block bitmap is changed to [Not in use]

3、        inode bitmap

 Record used and unused inode numbers

 

 

4.         dumpe2fs displays the current disk status    dumpe2fs + disk name

5.         What does creating a directory do?

When the ext4 file system creates a directory, it allocates an inode and at least one block

  inode records directory permissions and attributes, and can record the assigned block number

  block records the file name in the directory and the inode number occupied by the file

ls     -i   View the inode number occupied by the files in the directory

      -li  View the inode and block occupied by the files in the directory (both are multiples of 1024), and the details of the file

ll     -d   to view the block of the directory

       -di  view the inode and block of the directory

6.         What does creating a document do?

  ext4 creates a file and allocates an inode and the number of blocks relative to the file size

7.         Reading the directory tree

  The directory tree starts from the following directory, obtains the inode content of the root directory, and reads the file name data in the block of the root directory according to the inode, and then reads the correct file name layer by layer.

   ll –di directory to view the inode and block of the directory

8.         Disk directory and capacity

df : List overall disk usage of filesystems (shows information for all filesystems)

   -a : Display information about all files and directories, and those used by 0 will also be listed

   -h : list capacity in human-readable form

   -i : Display the remaining inode and total capacity

du : evaluate the disk usage of the file system (the capacity of the estimated directory all the year round)

    Only show the directory capacity and the total amount occupied by the directory

   -a : List all file and directory capacities

   -h : display in human-readable capacity format (GM) ;

   -s : List the total amount occupied by the directory

   -S : The capacity of each directory under the directory, which is slightly different from -s.

   -k : List capacity display in KBytes

   -m : list capacity display in MBytes ;

Note: List the capacity of each directory under the directory  du –Sm /* Use * to represent each directory

9.         Soft and hard links

Soft link (symbolic link, Sysbolic Link):

A file similar to the Windows shortcut function, which allows you to quickly link to the target file (or directory);

 ln -s [ original file] [ target file] (the original file is written as an absolute path)   

           The object file generated by the connection can only be used in its current directory.

Hard Links (Entity Links, Real Links, Hard Links):

 Copy, add a file name link to an inode number associated record (one inode with multiple file names)

   Cannot span Filesystem; cannot link directory

   ln  copied document directory  destination directory

 

         

 

 

2. Disk partitioning, formatting, checking and mounting

  1) Split the disk to create a usable partition

  2) Format the partition to create a filesystem usable by the system

  3)  If you want to be more careful, you can check the filesystem you just created

  4)  On the Linux system, you need to create a mount point (that is, a directory) and mount it

1. fdisk -l to view all disk information

2. The partition to be separated by the fdisk disk (name of the new hard disk)--→ Enter the partition module

m : view command, help documentation=help

d : delete the partition

l : List partition types

n : new

p : print partition information

q : quit without saving

w : save

3. n add - select disk p/e (p) - serial number - magnetic column (enter, the default starts from 1) - size - w save

When making a typo, delete with ctrl + backspace keys

4. Format:

mkfs –t ext4 disk name

  -t : can connect to file system format

5. Inspection (can do or not)

fsck   [-t filesystem] [-ACay] device name

   -t : can connect to file system format

   -A : Scan the required devices once according to the contents of /etc/fstab . This command is usually run during startup.

  -a : autofix

   -y : auto-fix, some filesystems only support -y

   -C : During the inspection process, use a histogram to display the current progress

6. Mount

1) Things to note before mounting:

• A single file system should not be mounted repeatedly on different mount points (directories)

• A single directory should not mount multiple file systems repeatedly;

• In theory, the directory to be used as a mount point should be an empty directory.

2) The mount point directory is generally in /mnt, first create an empty directory

The directory of the device to be mounted by  mount  (as long as lost+found is found in the mount directory, the mount is successful)

  -a : Mount all unmounted disks according to the data in the configuration file /etc/fstab

3) Automatically mount /etc/fstab at boot

 Some limitations of system mounts:

a.  The root directory / must be mounted, and it must be mounted before other mount points.

b.  Other mount points must be created directories, which can be specified arbitrarily, but must comply with the necessary system directory architecture principles

c.  All mount points can only be mounted once at the same time.

d.  All partitions can only be mounted once at the same time.

e.  If unmounting, you must first move the working directory outside the mount point (and its subdirectories).

      step:

        In a manually mounted directory: umount mount device

        In /etc/fstab:

            First column: Disk name (device to mount)         

Second column: mount directory    

Third column: file system (ext4)

        Fourth column: file system parameters (do not modify, default)      

The fifth column: Can it be used by the dump backup command, 0 means not to do a dump backup, 1 means to do a dump every day. 2 also represents other indefinite dump backup actions, usually this value is either 0 or 1.

 The sixth column: Whether to check the sector with fsck, 0 means not to check, 1 means the earliest check (generally only the root directory will be configured as 1), 2 also needs to be checked, but 1 will be checked earlier! Generally speaking, the root directory is configured as 1, and other filesystems to be checked are configured as 2.

4) reboot

Note: /etc/fstab is the configuration file at startup, but the actual filesystem mounts are recorded in the two files /etc/mtab and /proc/mounts.

 If the configuration is incorrect and the restart is unsuccessful, you need to enter the single-person maintenance mode. At that time, / was in a read-only state, and you could not modify /etc/fstab or upgrade /etc/mtab.

Mount root partition writable: mount -n -oremount,rw/

7. Mount and uninstall

umount mount device

   -f : force uninstall    -n: uninstall without upgrading /etc/mtab

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325986177&siteId=291194637