Linux-based disk and file system Management (II)

Source: Internet
Author: User
Tags readable reserved uuid inode usage

Disk and File System management


File System Management Tools:

Tools for creating file systems

Mkfs

Mkfs.ext2, Mkfs.ext3, MKFS.EXT4, MKFS.XFS, Mkfs.vfat, ...

Tools for detecting and repairing file systems

Fsck

Fsck.ext2, Fsck.ext3, ...

Tools to view their properties

DUMPE2FS, TUNE2FS

To adjust file system features:

Tune2fs

Components of the kernel-level file system:

File system driver: provided by the kernel

File System 箮 Tool: Provided by user-space Applications

Ext series File System Management tools:

Mkfs.ext2, MKFS.EXT3, MKFS.EXT4

Mkfs-t ext2 = mkfs.ext2

Ext Series File system dedicated management tool: MKE2FS

MKE2FS [OPTIONS] Device

-t {EXT2|EXT3|EXT4}: Indicates the type of file system to be created

MKFS.EXT4 = mkfs-t Ext4 = mke2fs-t Ext4

-B {1024|2048|4096}: Indicates the block size of the file system;

-L LABEL: Indicates the volume label;

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

Mke2fs-j = mke2fs-t Ext3 = mkfs-t ext3 = mkfs.ext3

-I #:bytes-per-inode, which indicates the ratio of the inode to the byte, that is, each number of bytes creates a indode;

-N #: Directly indicates the number of inode to be created for this file system;

-M #: Specifies the reserved space, percentage;

-O [^]feature: Creates the target file system with the specified attributes;

E2label command: Checking and setting of volume label

View: E2label Device

Setting: E2label Device LABEL

TUNE2FS command: View or modify some properties of the EXT series file system

Adjust tunable filesystem parameters on EXT2/EXT3/EXT4 filesystems;

NOTE: Block size cannot be modified after creation;

TUNE2FS [OPTIONS] Device

-L: View the contents of the Super block;

To modify the properties of the specified file system:

-j:ext2-ext3;

-L LABEL: Modify the volume label;

-M #: Adjust the percentage of reserved space;

-O [^]feather: Turn on or off a feature;

-O [^]mount_options: Turn on or off a default mount option

Cc.

^acl

DUMPE2FS command: Displays the properties information for the EXT series file system

DUMPE2FS [-h] Device

Tools to implement file system detection

The file system should be detected and repaired when the final operation is terminated abnormally due to unexpected process abort or system crash, and the filesystem should be checked and fixed.

Special tools for the EXT series file system:

E2fsck:check a Linux ext2/ext3/ext4 file system

e2fsck [OPTIONS] Device

-Y: Answer all questions automatically for Yes;

-F: Force detection even if the file system is in clean state;

Fsck:check and repair a Linux file system

-T Fstype: Indicates the file system type;

Fsck-t EXT4 = Fsck.ext4

-A: Automatically fix all errors without interaction;

-R: Interactive repair;

CentOS 6 How to use the Xfs file system:

# yum-y Install Xfsprogs

Prior:

# cd/etc/yum.repos.d/

# wget Http://172.16.0.1/centos6.7.repo

# MV Centos-base.repo Centos-base.repo.bak

Created: MKFS.XFS

Detection: FSCK.XFS

Blkid command:

Blkid Device

Blkid-l Label: Locate the device according to the label

Blkid-u UUID: Locating the device according to the UUID

Swap file System:

The swap partition on Linux must use a separate file system;

and the system ID of the filesystem must be 82;

Create swap device: Mkswap command

Mkswap [OPTIONS] Device

-L LABEL: Indicates the volume label

-F: Mandatory

Windows does not recognize the Linux file system, so when the storage device requires cross-use between the two systems, it should use a file system supported by both Windows and Linux: FAT32 (VFAT);

# Mkfs.vfat Device

Use of File systems:

The first thing to "mount": Mount Command and Umount command

A file system other than the root filesystem, to be accessible, must be implemented by "associating" to a directory on the root filesystem, which is "mounted", which is the "Mount point";

Mount point: Mount_point, used as the access entry for another file system;

(1) prior existence;

(2) Directories that are not or will not be used by other processes should be used;

(3) The existing files under the mount point will be hidden;

Mount Command:

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

Command options:

-r:readonly, read-only mount;

-w:read and write, read-write Mount;

-N: By default, the device mount or unload operation is updated synchronously to the/etc/mtab file; n is used to prohibit this feature;

-T Vfstype: Indicates the type of file system on the device to be mounted, and in most cases can be omitted, at which point mount will determine the file system type of the device to be mounted by blkid;

-L LABEL: Specifies the device as a volume label when mounted;

Mount-l LABEL dir

-U UUID: Specifies the device as a UUID when mounted;

Mount-u UUID dir

-O Options: Mount options

Sync/async: synchronous/asynchronous operation;

Atime/noatime: Whether a file or directory updates its access timestamp when it is accessed;

Diratime/nodiratime: Whether the directory updates its access timestamp when it is accessed;

Remount: Re-mount;

ACL: Support the use of FACL function;

# mount-o ACL device dir

# Tune2fs-o ACL Device

RO: Read-only

RW: Read and Write

Dev/nodev: Whether to allow the creation of device files on this device;

Exec/noexec: Whether the program files on this device are allowed to run;

Auto/noauto:

User/nouser: Whether to allow ordinary users to mount the file system;

Suid/nosuid: Allow suid and Sgid special permissions on program files to take effect;

Defaults:use default OPTIONS:RW, suid, Dev, exec, auto, nouser, async, and Relatime.

One use technique:

Can be implemented to bind the directory to another directory, as its temporary access to the portal;

Mount--bind Source Directory destination Directory

To view all mounted devices on the current system:

# mount

# Cat/etc/mtab

# cat/proc/mounts

To mount a disc:

Mount-r/dev/cdrom Mount_point

Disc device file:/dev/cdrom,/dev/dvd

Mount USB drive:

Pre-identification of the USB flash drive device files;

To mount a local loopback device:

# Mount-o Loop/path/to/some_loop_file Mount_point

Umount command:

Umount Device|dir

Note: The mount point that is being accessed by the process cannot be uninstalled;

To see which or which processes are being fought by:

# lsof Mount_point

# fuser-v Mount_point

To terminate all processes that are accessing a mount point:

# fuser-km Mount_point

Enabling and disabling of swap partitions:

command to create swap partition: Mkswap

Enabled: Swapon

Swapon [OPTION] [DEVICE]

-A: All swap devices defined in the/etc/fstab file;

Disabled: Swapoff

Swapoff DEVICE

Set a file system other than the root file system to mount automatically when booting:/etc/fstab file

Each row defines a file system and related properties to mount:

6 fields:

(1) device to be mounted:

equipment files;

LABEL

Uuid

Pseudo file systems: such as SYSFS, Proc, TMPFS, etc.

(2) Mount point

Swap is the mount point of a device of type swaps;

(3) file system type;

(4) Mount option

Defaults: Use the default mount option;

If you want to specify multiple mount options at the same time, separate things from each other;

Defaults,acl,noatime,noexec

(5) Dump frequency

0: Never back up;

1: daily backup;

2: Backup every other day;

(6) Self-Test order

0: not self-test;

1: First self-test, usually only the root file system available 1;

2: Secondary self-test

...

Mount-a: Automatically mounts the supported devices that are defined in this file;

Two commands: DF and Du

DF Command:

DF [OPTION] ... [FILE] ...

-L: Displays only information about local files;

-h:human-readable

-I: Display inode usage status instead of blocks

Du command:

Du [OPTION] ... [FILE] ...

-s:sumary

-h:human-readable

Practice:

1, create a 10G partition, and format the Ext4 file system;

(1) The block size is 2048, the reserved space is 2%, the volume is marked as MyData;

(2) Mount to the/mydata directory, require the mount to prohibit the program to run automatically, and do not update the file access time stamp;

(3) can be automatically mounted on the boot;

2. Create a swap partition with a size of 1G and start it;


Linux-based disk and file system 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.