Details Linux file system basics and related operations and swap partitions

Source: Internet
Author: User
Tags disk usage inode usage

First, the basic concept

A file system is an endogenous software that manages the files stored on a storage device.

Only the kernel can interact with the hardware's storage devices. The kernel also does not start when the operating system is not started, because the kernel must rely on the file system to boot. However, the file system is stored in the kernel and the file system does not exist before the kernel boots. The problem with this surround, like a "chicken egg, egg chicken" problem. In fact, when the operating system starts, the Bootloader in the MBR automatically recognizes the root file system (/), and the kernel in the root filesystem is started. The operating system starts to complete.

Ii. Types of file systems

virtual file system (VFS) : Different file systems can be identified and converted to a file system that can be recognized by the cost machine.

Basic File System :ext2,ext3,ext4,xfs, JFS,NTFS , and so on.

Network File System :NFS , and so on.

Disc File System :iso9660.

Cluster File System :GFS, which distributes on multiple computers, the computer through a certain way, the cluster of all the storage space in the resources of the integration, and external to the unified interface to provide file access to a file system.  

Swap partition :swap.

Iii. Ext4 File system How to manage files

EXT4 is a commonly used file system, a brief introduction to the management of the file system.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/7D/2F/wKiom1bhdyDT1wWkAAB4i_NFmc4317.png "title=" QQ picture 20160310213010.png "width=" 544 "height=" 288 "alt=" Wkiom1bhdydt1wwkaab4i_nfmc4317.png "/>

Block: The basic unit of File system Management file, block size is usually 2^nk.

Inode: The owner, group, Access, timestamp of the file being stored. The most important thing is to store the data block information where the file resides.

Inode Bitmap: Stores unused inode and used inode information. It is convenient to allocate the appropriate inode for the file when storing the file.

Block bitmap: Similar to an inode bitmap, holds unused blocks and blocks that have been used. Convenient for file allocation block, store file contents.

Super BLOCK: Store the inode, Inode Bitmap, and block bitmap in the file system.

Logging area: To prevent the storage of files during the process, due to a hardware failure such as power failure caused the file store to fail, when the boot again, delete the invalid file. When the file is stored, an inode is assigned to the file, both in the Inode area and in the log record area, if the storage succeeds, the inode is deleted, and if a failure occurs during the stored procedure, the Inode is logged and the file system detection and cleanup is facilitated for the next boot.

Four, file system operation:

1, partition can only be 4 primary partition, why?

The MBR that starts the operating system altogether contains 512 bytes, the first 446 bytes of storage bootloader is used to start the operating system, and then 64 bytes to store the partition information, each 16 bytes to hold a partition information, so an operating system can only be four primary partitions, if you want to use multiple partitions, You can set one or two partitions to an extended partition, and then you can create multiple logical partitions in the extended partition.

2. Partition operation:

Command: fdisk <device-name>, enter the interactive interface.

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/7D/2F/wKiom1bhd9vx24VDAABnXoa8vaw960.png "title=" Qq20160310213319.png "width=" 637 "height=" 275 "alt=" Wkiom1bhd9vx24vdaabnxoa8vaw960.png "/>

Common Command for Interactive:

N: Add new partition

D: Delete partition

P: Print partition information for the current disk

T: Adjust partition mark (partition ID)

L: List ID information for all partitions

W: Save partition information and exit

Q: Do not save exit

M: Get Help

New partition information Viewing method:

1. Save the partition information of all storage devices in the/proc/partition file.

2, use the command. Fdisk-l <device-name>

2. Formatting

Command: MKE2FS [option] <device-name>, MKFS;

Option:

-T Fs-type: Specifying File system type (Common)

-L Label: Specify Volume label

-B block-size: specifying chunk size

-I Byte_per_inode: Specify a few bytes for one inode

-N Inode-num; Specify Inode number

-I inode-size: Specify Inode size

Different ways to create EXT4 partitions (similar to other file systems):

1. #  mke2fs-t ext4/dev/sdb1;

2. #  MKFS.EXT4

3. #  mkfs-t ext4/dev/sdb1

Other commands:

1. Blkid <device-name> View the file system type of the storage device.

        # blkid/dev/sdb1

2. dumpe2fs [option] <device-mname> view block group information.

Option:-h only displays the information in Super block.

3. tune2fs [option] <device-name> adjust the information in the Super block

Option:

-L: View Super block information

-L Label: modifying volume label information

-j: If the original file system is ext2, the upgrade to ext3 does not affect the data.

-O Mount-option: Specifying Mount Properties

-O: Adjust partition characteristics

Turn off a feature: Tune2fs ^feature <device-path>

Open a Feature: TUNE2FS feature <device-path>

4, fsck, e2fsck. Detects the file system.

3. Mount | unmount storage device

Mounting: Mount <device-path> <destdir-name>

          # Mount/dev/sdb1/mnt/sdb_data

Auto Mount: Edit the device you want to mount in the/etc/fstab file, and then execute the command "Mount-a".

Uninstall: umount {device-path | destdir-name}

          # umount/dev/sdb1

          # Umount/mnt/sdb_data

4. View disk usage

Command: Df,du

DF [option] <device-name>: View hangs on device usage

Option:-h conversions for adults easily identifiable units

-I view inode usage

du [option] <file-name>: View file usage of storage devices

Option:-h human-readable

-s usage of the entire directory on disk

V. Creation of SWAP partitions

1. Adjust the partition type:

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/7D/2F/wKiom1bheRSieqIlAABBB_8rEWg942.png "title=" Qq20160310213855.png "width=" 595 "height=" 157 " alt=" Wkiom1bhersieqilaabbb_8rewg942.png "/>

2. To format the swap partition:

Command: Mkswap <device-name>

        # mkswap/dev/sdb1

3. Start | Close swap partition

Command: swapon [option] <device-path>, swapoff [option] <device-path>

Option:-A: (Start | disable) all swap partitions

-P #: Specify Priority at startup

Start: # swapon/dev/sdb1

Close: # swapoff/dev/sdb1


================= above is my introduction to the file system, if there is an inappropriate welcome to point out 650) this.width=650; "src=" Http://img.baidu.com/hi/jx2/j_0057.gif "alt=" j_ 0057.gif "/>=========================


























This article is from the "11219885" blog, please be sure to keep this source http://11229885.blog.51cto.com/11219885/1749744

Details Linux file system basics and related operations and swap partitions

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.