Linux 4-disk and file system management

Source: Internet
Author: User

Linux 4-disk and file system management
1. Some Basic Definitions 1. superblock: record the overall information of this filesystem, including the total inode/block, usage, remaining amount, and file system format and related information; 2. inode: records the attributes of an archive. An archive occupies one inode and records the block number of the archive data. 3. block: records the content of an object. If the object is too large, multiple blocks are occupied. Ii. Linux-Supported file systems 1. check what file systems are supported by Linux: ls-l/lib/modules/$ (uname-r)/kernel/fs 2. view the file system currently supported by the system loaded into the memory: cat/proc/filesystems Linux VFS (Virtual Filesystem Switch) help us manage how to access different file systems 3. Introduction to Ext2 file systems 1. block features 1) the block size and quantity cannot be changed after being formatted (unless re-formatted), generally 1 K, 2 K or 4 K, its size determines the maximum size of a single file and the maximum total size of the file system. The Block size is 1KB, 2KB, 4KB, and the maximum size of a single file is 16 GB, 256 GB, 2 TB, and the maximum size of the file system is 2 TB, 8 TB, 16 tb2) each block can only store the data of one file. 3) if the file is larger than the block size An archive occupies multiple blocks. 4) if the archive is smaller than the block, the remaining capacity of the block cannot be used again (disk space is wasted ). 2. inode features 1) Each inode is fixed to 128 bytes; 2) each file occupies only one inode; 3) the number of files that can be created by the file system depends on the number of inode. 4) when the system reads files, it needs to find the inode and analyze whether the permissions recorded by the inode are consistent with those recorded by the user, if yes, you can start to read the block content. 5) The inode record block number is defined as 12 Direct, one indirect, one double indirect, and three indirect record areas. Iv. File System Operations 1. df: list the total disk usage of the file system df [-ahikHTm] [directory or file name] Options and parameters:-a: List all file systems, including the system-specific/proc and other file systems;-k: displays each file system with the capacity of KBytes;-m: displays each file system with the capacity of MBytes;-h: display Data in easy-to-read formats such as GBytes, MBytes, and KBytes.-H: Replace the carry mode of M = 1000 K with M = 1024 K.-T: the filesystem name (for example, ext3) of the partition is also listed.-I: the disk capacity is not used, but the inode quantity is used. 2. du: Evaluate the disk usage of the file system du [-ahskm] file or directory name options and parameters:-a: List all files and directory capacity, by default, only the files under the directory are counted. -H: displayed in G/M format, which is easy to read.-s: only lists the total amount, rather than the occupied capacity of each directory.-S: excluding the total number of sub-directories. By default, du lists the sizes of all files. Therefore, if you use du under/etc, the sub-directory capacity under/etc will also be calculated once. Then, the final Capacity (/etc) will be added once. Therefore, if you want to list all the data in a directory, you can add the-S option to the partition, reduce the number of times the directory is added! -K: Capacity Display by KBytes;-m: Capacity Display by MBytes; 3. ln establishes the archive link ln [-sf] to connect the options and parameters of the source file target file:-s: If no parameters are added, it is hard link, -s is the symbolic link-f: if the target file exists, you can manually remove the target file and create it again! When creating a directory, the number of links is generally 2, while the number of links in the upper directory increases by 1. For example,/tmp/test has/tmp/test and/tmp/test /. link/tmp/test /.. 4. fdisk disk partition (parted for a partition of more than 2 TB) fdisk-l view the current disk partition information fdisk Disk: Enter the disk partition management system 5. mkfs disk formatting mkfs [-t File System Format] device file name options and parameters:-t: can be connected to the file system format, such as ext3, ext2, vfat and so on (the system is supported to take effect) 6. more detailed disk formatting options and parameters for mke2fs:-B: You can set the size of each block. Currently, three types of data are supported: 1024,204 8, 4096 bytes;-I: inode size-c: check disk errors. If-c is issued only once, a quick read/write test is performed. -C will test read-write, which will be slow ~ -L: followed by the header name (Label)-j: the original mke2fs is EXT2. After adding-j, it will be added to journal and become EXT3. 7. fsck to check whether the file system has an error 8. badblocks check whether the hard disk or floppy disk sector has bad track 9. mount and unmount Note: 1) a single file system should not be repeatedly mounted to different mount points (directories); 2) multiple file systems should not be mounted in a single directory; 3) the directories to be used as Mount Points should theoretically be empty directories. If it is not empty, the original file will be hidden after mounting. 10. mknod: Modify information about the file system, such as the main device code and secondary device code. 11. e2label: Modify file system header 12. tune2fs: Change the file system to ext2, ext3, ext4, etc. 13. when hdparm is used as the IDE interface, set some parameters 14. mkswap can be used to create a large file as a swap file, and swapon and swapoff can be used to enable or disable swap file to implement virtual memory. TIPS: You can use dd if =/dev/zero of =/tmp/swap bs = 1 M count = 128 to create a large file.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.