File systems in Linux

Source: Internet
Author: User
Tags uuid

First, the creation of the file system-partition format

Formatting:

Low-level formatting: dividing tracks

Advanced formatting: Create a file system that divides the entire partition into small logical addressing units of the same size, each of which is called blocks (block), according to a specific standard.

The standard for dividing blocks: in Linux file systems, the main block partitioning standard is: Each block includes 2^1 or 2^2 or 2^3 sectors, that is, the block size can be: 1024byte,2048byte or 4096Byte;

Ii. steps to create a file system:

1. Divide the zoning into blocks of equal size:

Metadata blocks: properties that store files, such as size, permissions, timestamps, data block pointers, whose storage space is called Inode, each inode size is 128byte, each inode has its corresponding inode number

Data blocks: Storing the content of streaming data contained in a file

Special files: Only the inode in the metadata block, such as device files and symbolic link files


2. As disk space becomes larger, the number of blocks that are divided is increasing and management becomes more difficult; This problem is resolved by partitioning block groups:

Block groups:

Each block group has independent metadata blocks and data blocks;

When the data is stored, the data in the Block group is preferred, if the number of blocks within the block is not enough, the file system can be used to request multiple block groups for collaborative storage;


Super BLOCK:

It mainly defines the number of block groups in the whole partition, and the boundaries of each block group;

In order to prevent the failure of the Super block caused the entire file system to crash, the file system will automatically back up the Super block;

3. To prevent data inconsistency, introduce the concept of log blocks in the file system

Log block: Logging for data write operations


Third, the Linux supported file system:

1.Linux Proprietary file system:

EXT Series: ext, ext2, ext3, Ext4

EXT4 Features:

Single partition Max 50TB;

Single File Max 64EB;

Can be set on the root partition;

Can be set on the boot partition;

2.XFS: Max partition 500TB, ...

3.reiserfs:

4.btrfs: Technical Preview version

5.iso9660: Disc File system

6.fat:vfat

7.NTFS: Default is not supported, you can obtain support by adjusting kernel parameters;

8. Network File system: NFS, CIFS

9. Cluster file system: GFS2, OCFS2

10. Distributed File System:

Kernel level: Ceph

User space (Application level): MogileFS, Moosefs, Glusterfs

11.Unix file systems: UFS, FFS, JFS, ZFS

12. Pseudo File system: Proc, SYS, TMPFS, hugepagefs;

is not a file system that manages disk data, but rather a file system that manages memory data;


Iv. tools for creating file Systems MKFS

Format: MKFS [Options] [-t type] [fs-options] device [size]

Example:

Mkfs-t EXT4/DEV/SDB1

Can be used directly when creating EXT4 file system

Mkfs.ext4/dev/sdb1


Attention:

1. Do not use the disk device name to make or extend the partition device name as a parameter of the MKFS command;

If the disk device name is used as a parameter to the MKFS command, all partitions will be deleted;

If you use an extended partition device as a parameter to the MKFS command, all logical partitions will be deleted;

2. Only primary and logical partitions can be used to create file systems using the MKFS command;


If the target file system you are creating is the Ext Series file system, you can use the MKE2FS command;

MKE2FS:

Mke2fs-create an EXT2/EXT3/EXT4 filesystem

Common options:

-B block-size: When creating the file system, specify the size of each block; The default value is 4096, the unit is byte; when adjusting, only 1024,2048 and 4096 are written;

-I bytes-per-inode: When creating the file system, specify the ratio of inode to byte, i.e.: How many bytes create an inode, the default value is 16384;

-j: Create a file system with log function, namely: ext3;

-L New-volume-label: Specifies the volume label when creating the file system;

-M Reserved-blocks-percentage: Specifies the percentage of disk space reserved for the administrator when creating the file system; The default value is 5;

-N: Does not really create a file system, but rather shows what is done when the file system is created;

-N number-of-inodes: The number of inode created in this file system is directly indicated when the file system is created;

-O [^]feature[,...] : Turn off or turn on file system features when creating a file system;

-T fs-type: Specifies the file system type when creating the file system;


V. Modify the volume label of the Ext series file system:

E2label command

Format: E2label device [New-label]

If the New-label parameter is not added, the volume label of the specified device is viewed


Six, file system detection and repair tools:

1.fsck

Format: fsck [-ar] [-t fstab] [filesystem]

Common options:

-T Fstype: Specifies the file system type of the file system to be detected

-A: Automatically fix detected issues without interaction

-R: Interactive Repair


2.ext Series File system Special Repair tool E2FSCK

Format: e2fsck [-y] [-f] Device

Common options:

-Y: All questions in the interactive process are answered with "Yes"

-F: Force detection and repair

Vii. query tools for file systems:

1.blkid:

Common options:

-L Label: block Device lookup targeting based on specified volume label

-U UUID: Find and locate block devices based on specified UUID


2.findfs:

Format: Findfs [Label=<label>] [Uuid=<uuid>]


Eight, swap partition system

Modify the method of the swap partition system: In the interactive mode of Fdisk, use the T command to modify the specified partition type to 82;


Ix. File System mount:

Mount: For Linux systems, the file system can only have a unique primary access portal, which is referred to as the "root file System", and all other file systems must be associated in a particular way to the root filesystem or subdirectory of the root filesystem, and this association process is called "mount" ; The directory used to correlate the root file system and other file systems is called a "mount point";


Mount point: Typically a directory that, after being a mount point, is the access entry for other file systems, such as:/boot

Requirements:

1. The directory that is the mount point must exist beforehand;

2. The directory that is the mount point should be a directory that is not used or is not occupied by other processes, in other words, must be an idle directory;

3. As a mount point directory, once the other file system is mounted, the original file system features are lost; Simply put, if a directory has a file name, once the other file system is mounted, the original file name is not visible, so the new content in the directory is the file name of the new filesystem This process continues until the new file system is uninstalled;


1. Mount the file system using the Mount command

Format: Mount [-LHV]

mount-a [-FFNRSVW] [-t vfstype] [-O optlist]

Mount [-FNRSVW] [-o option[,option] ...] Device|dir

Mount [-FNRSVW] [-t vfstype] [-O options] Device dir


Common options:

-R,--read-only: Mount the target file system as read-only, usually for CD-ROM mounting;

-W,--RW,--read-write: Mount the target file system in a readable and writable manner; usually the default

-N,--no-mtab: By default, all mount block device operations are automatically recorded in the/etc/mtab file, and if the-N,--no-mtab option is used, the mount information is not recorded in the/etc/mtab file even if the mount is successful

-T,--types vfstype: Indicates the type of the target file system when the file system is mounted, and if omitted, the Mount command uses the Blkid command to determine the type of target file system to mount;

-L,--label label: Mounts the target file system via the specified file system's volume label;

-U,--uuid UUID: Mount the target file system with the UUID of the specified file system;

-A,--all: automatically mount according to the file system specified in the/etc/fstab file;

-O,--options opts: The mount parameter option can be adjusted when the target file system is mounted;

Loop: Use the loopback device to mount the image file as a file system to the specified mount point;

-B,--bind: Binds an already mounted file system to another mount point;

Example: # Mount-b|--bind Mount_point1 Mount_point2


Example:

Mount/dev/sdb1/mnt/sdb1

Mount-o REMOUNT,RO/MNT/SDB1


2. Uninstalling the mounted file system: Umount command

Umount-a

Uninstalls all unmounted file systems in the currently mounted file system;

umount {Dir|device} ...

uninstalling a specified device by specifying a mount point or device file name;


3. Mount the disc:

In the virtual machine, you need to ensure that the disc image file is placed in the virtual machine's CD-ROM drive, and that the virtual machine's optical drive is in a "connected" state; you need to implement create mount point (/mnt/cdrom);

Mount-r/dev/sr0/mnt/cdrom


4. Mount/unload Swap partition:

Swapon/swapoff


X./etc/fstab file

During system startup, all file systems that are correctly listed are automatically mounted on the file.


A total of six fields:

1. The name of the device or file system to be mounted, or it may be a volume label or UUID;

If you use a volume label you must use: label= "LABEL"

If using UUID must use: uuid= "UUID"

2. Mount point:

swap device or file without mount point, write swap in this field;

3. File System type:

4. Default File system Mount option: Use a comma-delimited list when you want to specify multiple options;

Defaults,ro,sync

5. Dump Frequency:

Use the dump command to automatically back up the frequency of partitioned data;

0: No Backup

1: Backup Once a day

2: Backup every two days, that is: backup every other day;

...

6. Self-Test order:

0: not self-test;

1: Priority self-test, usually only set on the root file system;

2: Secondary self-test;

    ...

9: Minimum priority self-test;



File systems in Linux

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.