Linux learning four--disk and file system management

Source: Internet
Author: User
Tags disk usage

First, some basic definitions

1. Superblock: Record The overall information of this filesystem, including the total amount of inode/block, the amount of use, the amount of surplus, and the format and relevant information of the file system;
2. Inode: Record the properties of the file, a file occupies an inode, and record the data of the block number of the file;
3. Block: The actual record of the contents of the file, if the file is too large, will occupy more than block.

Second, the Linux supported file system

1. See what Linux supported file systems are:

Ls-l/lib/modules/$ (uname-r)/kernel/fs

2. Check that the system is currently loaded into an in-memory supported file system:

Cat/proc/filesystems

Linux VFS (Virtual Filesystem Switch) to help us manage how to access different file systems

Three, Ext2 file system Introduction

1. Features of block

1) block size and quantity can not be changed after formatting (unless reformatted), generally 1k,2k or 4 K, its size determines the maximum size of a single file and the maximum file system total capacity;

Block size 1KB 2KB 4KB

Maximum single file limit 16GB 256GB 2TB

Maximum file system Total capacity 2TB 8TB 16TB
2) A maximum of one file can be placed within each block;
3) If the file is larger than the block size, then a file will occupy multiple blocks of block;
4) If the file is less than block, then the remaining capacity of the block will not be able to be used again (disk space will be wasted).

2. Features of the Inode

1) Each inode size is fixed to bytes;
2) Each file will only occupy one inode;
3) The number of files the file system can establish is related to the number of inode;
4) The system must first find the inode, and analyze the inode record of the permissions and the user is consistent, if it is possible to start the actual reading block content.

5) The Inode record block number area is defined as 12 direct, one indirect, one double indirect with a three indirect record area.

Iv. file System related operations

1. DF: List The overall disk usage of the file system

DF [-ahikhtm] [directory or file name]

Options and Parameters:

-A: Lists all file systems, including system-specific/proc, etc.

-K: Displays the file system in Kbytes capacity;

-M: Display the file system in MBytes capacity;

-H: GBytes, MBytes, Kbytes and other formats are displayed by people who are easier to read;

-H: Replace m=1024k with m=1000k;

-T: Along with the filesystem name of the partition (e.g. ext3), also listed;

-I: Do not use the hard disk capacity, but the number of inode to display

2. Du: Evaluating disk usage for file systems

Du [-ahskm] file or directory name

Options and Parameters:

-A: Lists all files and directory capacity, because the default is only the number of files under the directory.

-H: Displayed in a more readable capacity format (g/m);

-S: Lists the total, not the capacity of each directory;

-S: does not include totals under sub-directories. Du defaults to the size of all files, so assuming that you are using du under/etc, all file sizes, including the sub-directory capacity under/etc, will be counted once. Then the final capacity (/etc) will also be added once, so if you want to list all the data under a directory, you can also add-s to choose, reduce the total of secondary directory!

-K: List capacity display in Kbytes;

-M: List capacity display with MBytes;

3. ln establishes the file link

ln [-SF] source file destination file

Options and Parameters:

-S: If you do not add any parameters to the link, it is hard link, as for-S is symbolic link

-F: If the target file exists, the target file will be removed and then created!

When you create a new catalog, the link number is typically 2, and the link number in the upper directory increases by 1, for example,/tmp/test has/tmp/test and/tmp/test/. Two link, and for the upper directory, add link/tmp/test/.

4. FDISK disk partition (partition 2TB above with parted)

FDISK-L view Current disk partition information

Fdisk disk: Enter the disk partition management system

5. MKFS Disk Format

MKFS [-T file System format] Appliance file name

Options and Parameters:

-T: can take file system format, such as Ext3, ext2, VFAT, etc. (System support will be effective)

6. MKE2FS more granular disk formatting

Options and Parameters:

-B: You can set the size of each block, currently supports 2048, 4096 bytes three kinds;

Size of the-i:inode

-C: Check for disk errors, only one time-C, the rapid reading and writing test, if the release two times-c-c, will test read and write (Read-write), will be slow ~

-L: Can be followed by a header name (label)

-j: Originally MKE2FS is EXT2, add-j, will join Journal and become EXT3.

7. fsck to check the file system for errors

8. Badblocks Check if the hard drive or floppy disk sector has bad track

9. Mount,unmount Disk mount and dismount

Attention:

1) A single file system should not be repeatedly mounted in different mount points (directories);
2) A single directory should not repeatedly mount multiple file systems;
3) The directory to be a mount point should theoretically be an empty directory. If it is not empty, the original file will be hidden after mounting.

Mknod Modify the file system information, such as the main device code, minor device code, etc.

E2label. modify File System headers

TUNE2FS modified file system for EXT2,EXT3,EXT4 etc.

Hdparm set some parameters when the hard disk is an IDE interface

14. Mkswap can be used to create large files as swap files, and swapon, Swapoff Open or close swap file to implement virtual memory.

Small tricks, you can use DD If=/dev/zero of=/tmp/swap bs=1m count=128 to build large files.

Linux learning four--disk and file system management

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.