Linux System Management----Storage Management (II)

Source: Internet
Author: User
Tags uuid

Create file system----Partition formatting
Formatting
Low-level format: disk initialization, track division;
Advanced formatting: Creates or rebuilds a file system, dividing the entire partition into small logical addressing units of the same size, each of which is called a block, according to a specific standard; window is called a cluster
Standard for dividing blocks:
In Linux file systems, the main block partitioning criteria are: Each block includes 2^1 or 2^2 or 2^3 sectors, i.e. the block size can be 1024 bytes, 2048 bytes, 4096 bytes;

Note: 1. The blocks are divided, each block can only hold the contents of one file, a file can be stored on multiple blocks;
2. If in a partition, to create a large number of small files, the block size is set smaller, conversely, in a partition to create a large file, the block is set to a larger number;
3. If the partition space is large, you can set the block larger;

Hierarchical standard for fhs--file systems

For the management of data:
1. Plane classification management: traversing data
2. Spatial classification Management (hierarchical):
Logical addressing: Creating a file system is actually a logical addressing of the storage space of the partition;
Features: only need to pass the limited time and the effective search can locate the target file;


To create a file system in a partition:
1. First, the file system divides the partition into several data blocks of equal size;
Metadata block: The main file attribute information includes: File size, permissions, ownership, timestamp data block pointers (direct, indirect 、... )
A fixed storage space for storing metadata for each file, called index node, or inode;
In Linux file systems, each inode size is typically 128 bytes, and each inode has its corresponding inode number;
Data BLOCK: The contents of the streaming data contained in the file;

Special files:
Occupies only the inode in the metadata block, and does not occupy the data block; There are two kinds:
Equipment files: Block special, character special;
Such files are saved by replacing the data block pointer in the inode with the device number;
Symbolic connection file: Symbolic link
This type of file is the access path to replace the data block pointer in the inode with another file;

With more and more disk space, the number of rapid division is also more and more, management is more difficult, by dividing block groups to solve the problem;
Block groups:
Each block group has independent metadata blocks and data blocks;
When the data is stored, the data in block group is preferred, if the number of blocks within the block is not enough, the file system can use the storage policy to request multiple block group cooperative storage;
Super BLOCK:
It mainly defines how many block groups are 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;
In order to prevent data inconsistency (transmission of data, such as power loss, such as the completion of data transmission, inode, not the completion of transmission), in the file system to introduce the concept of log blocks;
Log Block: A block of log records for data write operations;
Inconsistent data is usually caused by unclean shutdown, unclean power failure;


A complete Linux file system:
Super block, Inode,inode Bitmap (bitmap), Block Bitmap (block bitmap), data block, Journal block (log block)

Procedures for locating files:
Directory: Content is the file name;
Each filename is a file-specific identity, and each file name corresponds to an inode; (looking back and forth between the inode and DataBlock, eventually pointing to the original data file)


Linux Supported file systems:
File system drivers located in kernel space:
ls/usr/lib/modules/Kernel version number/kernel
The file system can be a part of the kernel, or it can be a kernel module;

File System Management program in user space:
Management command;

Linux Supported file systems:
1.Linux Proprietary file system: (CENTOS7 before default file system)
EXT Series: Ext, ext (2, 3, 4)
EXT4 characteristics: Maximum 50TB for a single partition;
Single File Max 64EB *
Can be set on the root partition;
Can be set on the boot partition;
2.XFS:
Maximum Partition 500TB, ... (Default file system after Centos7)
3.reiserfs:
4.btrfs: (Google development)
5.iso9660: Disc File system
6.FAT:VFAT (FAT32)
7.NTFS: (not supported by default, can be supported by tuning 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 ...
11.Unix file system: 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;

For different distributions of Linux, there is a default file system to use;
Rhel or CentOS series: 5:ext3 6:EXT4 7:XFS


Managing File Systems:
Create a file system;
Use file System (mount file system);
Stop using the file system (unmount the file system);
File system detection and repair;

Tools to create user space for the file system:
MKFS command
Create a file system
MKFS [-v] [-t file system type] [fs-options] File system [block]
Common options:
-T: Select File system type
Mkfs-t Ext4/dev/sdb = = Mkfs.ext4/dev/sdb
In Rhel or CentOS series, a file system can be created using tools such as the second method (Eg:mkfs.ext3 MKFS.XFS, etc.)

Attention:
1. Do not use the disk device name or extended partition device name as the parameter of the MKFS command, and if the disk device or extended partition device name is used as the MKFS command parameter, all partitions will be deleted;
2. Only primary and logical partitions can be used to create file systems using the MKFS command;
3. If the target file system to be created is the EXT series file system, you can use the MKE2FS command;
Mke2fs-create an EXT2/EXT3/EXT4 filesystem
Common options:
-B: Specifies the size of each block when the file system is created; The default value is 4096 bytes; When adjusted, only 1024,2048,4096 bytes are written;
-I: When creating the file system, specify the ratio of inode to byte, i.e.: How many bytes create an inode, the default value of 16384 bytes;
-j: Create a file system with log function, i.e.: ext3 and later
-L: In creating file system Yes, specify volume label;
-M: Specifies the percentage of disk space reserved for administrators when creating the file system; Default: 5 (5%)
-N: Does not create a file system, but displays the process of creating the file system;
-N: When creating a file system, directly indicate how many inode is created;
-O [^]feature[,...] : Turn off or turn on file system features when creating a file system;
-T: Specifies the file system type when creating the file system;

To modify the volume label of the Ext series file system:
E2label command:
E2label-change the label on an EXT2/EXT3/EXT4 filesystem
E2label device [New-label]
If the New-label parameter is not added, the volume label of the specified device is viewed, and if the parameter is added, its volume label is modified;
To modify the properties of the Ext series file system:
TUNE2FS command:
Tune2fs-adjust tunable filesystem Parameters on Ext2/ext3/ext4 filesystems (adjust the parameters that can be adjusted on the Ext2/3/4 file system)
Common options:
-L: Displays the contents of the Super block;
-j: Modify ext2 to Ext3 file system (join log function)
-M: Adjusts the percentage of reserved space in the file system;
-R: Adjusts the number of blocks of disk space reserved in the file system;
-L: Modify the volume label;
-O [^]feature[,...] : Modify file system features to open;

File system detection and repair tools:
fsck command
Check and repair the Linux file system
fsck [-ar] [-t fstype] [Filesys ...]
Common options:
-T: Specifies the type of file system to detect;
-A: Automatically fix all detected issues without interaction;
-R: Interactive repair of detected problems;

Ext Series File system-specific detection repair tool:
E2FSCK command
Check a Linux ext2/ext3/ext4 file system

Common options:
-Y: All the questions in the interactive process have been answered "yes";
-F: Force detection and repair, even if the file system is in clean state;

Blkid command
Locate/print Block Device attributes
Common options:
-L Label: block device locating according to the developed volume label;
-U UUID: Block device locating based on specified UUID;

Findfs command
Find a filesystem by label or UUID
Findfs [Label=<label>] [Uuid=<uuid>]



Swap file system: (can be referred to as the Swap partition, which is the role of the memory is not running enough or problems, the partial waiting for the execution of the file into the swap partition, has achieved the role of freeing memory, improve operational efficiency)
Premise: The partition type must be a swap type, that is: The system ID of the partition must be 82;
Modify the method: in the interactive mode of Fdisk, use the T command to modify the specified partition type to 82;

To create a swap file system:
Mkswap command
Build a Linux swap zone
Common options:
-F: Enforcement;
-L LABEL: Set the Swap partition volume label;
-U UUID: Specifies the swap partition UUID;


Create a swap partition with a large file:
Example:
~]# DD If=/dev/zero of=/tmp/swapfile bs=1024 count=1024000
~]# Mkswap/tmp/swapfile


Mount with file system----
Mount:
For Linux systems, the file system can only be accessed by 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 file system or to a subdirectory of the root filesystem, which is known as Mount ; directories used to correlate the root file system and other file systems are called mount points;

Mount point:
Mount point, usually a directory that, after becoming a mount, 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, it must be an idle directory;
3. As a directory of Mount points, once the other file system is mounted, the original file system features are lost; Simply put, if there is a file name in a directory, the original file name is not visible once it is attached to the other filesystem, so the new content in the directory is the file name in the new filesystem. This process continues until the new file system is uninstalled;

To complete the mount operation:
Mount command
Mount a filesystem
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: Mount the target file system as read-only; (usually for CD-ROM mount)
-W: Mount the file system in a readable and writable manner, usually by default;
-N: By default, all mounted block devices are automatically recorded in the/etc/mtab file, and if the-n option is used, the mount information is not recorded in this file, even if the mount is successful;
-T: Indicates the type of the target file system when mounting the file system, and if omitted, the Mount command determines the type of target file system to mount by using the Blkid command;
-L: Mount the target file system through the specified file system's volume label;
-U: Mount the target filesystem with the UUID of the specified file system; (ensure the uniqueness of the file system being hung)
-A: Automatically mounts according to the file system specified in the/etc/fstab file;
-O: The mount parameter option can be adjusted when the target file system is mounted;
FILESYSTEM Independent MOUNT OPTIONS
Sync/async: Synchronous/Asynchronous Mount options: (whether to immediately synchronize modified content to disk: Immediate synchronization will greatly consume IO performance)
Atime/noatime: Whether the access timestamp is updated when the file is accessed or not (for files that are too large to be accessed Atime)
Diratime/nodiratime: Whether the access timestamp is updated when the directory is accessed, (for directories that are too large to be accessed Diratime)
RO/RW: The file system is mounted in a read/read-only writable manner; the equivalent of the-R/-W option;
Dev/nodev: Whether to allow the creation of device files in this file system;
Exec/noexec: Whether the program files (including various binaries and script files) are allowed to run in this file system;
Auto/noauto: When mounting this file system, can be mounted using the-a option;
User/nouser: Whether to allow ordinary users to mount the file system;
Suid/nosuid: Does this file system allow special permissions such as Suid and sgid to take effect on program files;
Relatime/norelatime: Whether to refer to the Inode access time in this file system to modify the timestamp and change the timestamp;
Remount: You can apply the new Mount option for the target file system without uninstalling it;
ACL: (used only in the EXT series file system or XFS file system) can use the Facl function of the file system;
Defaults: The default option, which includes Rw,suid,dev,exec,auto,nouser,async.
Loop: Use the loopback device, mount the image file as a file system to the specified mount point;
-B: Bind a file system that is already mounted to another directory;
Eg:mount-b|--bind Mount_point1 Mount_point2

eg
Mount/dev/sdb1/mnt/sdb1
Mount-o REMOUNT,RO/DEV/SDB1

To uninstall a file system that is already mounted:
Umount command
Umount-a unmount all unmounted file systems in the currently mounted file system;
unmount {Dir|device} Uninstalls the specified device by specifying a mount point or device name;

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


Mount Swap partition:
Swapon command
To unload a swap partition:
Swapoff command

Options
-A: Automatically mount/unload all swap partitions that are correctly defined in the/etc/fstab file;




Format of/etc/fstab file: (interview)
A total of 6 fields, by default using white space characters (tabs) as the field separator;
The six fields mean:
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 (if you want to add default options, use "," separate; Eg:defaults,ro, ...) )
5. Dump Frequency
Use the dump command to automatically back up the frequency of partitioned data; (if it is 0, it means no backup, if it is #, it is backed up once per # day)
6. Self-Test order:
0: No self-test
1: Priority self-test (usually only on the root file system)
2: Secondary self-test
...
9: Minimum priority self-test;

/etc/fstab file function:
All file systems that are correctly listed in the file are automatically mounted during system startup;

Linux System Management----Storage Management (II)

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.