Advanced Linux disk and file system management

Source: Internet
Author: User
Tags uuid inode usage

Directory

1.MKFS Introduction 2. File system mount use (Mount) 3. Practice 4.fuser Usage

1.MKFS Introduction: MKFS.EXT2/DEV/SDB1

[Email protected] ~]# MKFS.EXT2/DEV/SDB1

MKE2FS 1.42.9 (28-dec-2013)

File System label =

OS Type:linux

Block size =4096 (log=2)

Chunked size =4096 (log=2)

Stride=0 blocks, Stripe width=0 blocks

655360 inodes, 2621440 blocks

131072 blocks (5.00%) reserved for the Super User//In order for the administrator to leave room to move the data when the partition is stained, to achieve management

First block of data =0

Maximum filesystem blocks=2684354560

Block groups

32768 blocks per group, 32768 fragments per group

8192 inodes per group

Superblock backups stored on blocks://Location of Super block backup

32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

Allocating group tables: complete

Writing Inode table: complete

Writing Superblocks and FileSystem accounting information: Complete


2. File System mount Usage

Use of File systems:

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

Any other fs other than the root file system, to be accessible, must be implemented through an "association" to a directory on the root FS, which is "mounted"

Mount point: Used as access entry for another file system

(1) Realization of existence

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

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


Mount [-LHV]

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

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

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

Umount Device|dir

Mount points that are being accessed by the process cannot be uninstalled

-L is the default option, List

-n-notmab//Do not write/etc/mtab, mount point log file

The default device mounts or uninstalls the action, and the update is synchronized/etc/mtab

-R read-only//optical drive can only be mounted on read-only

-W Read-write//default

-V Verbose

-t specifies that the FS type can be omitted, and mount will determine the type by using the Blkid command

/etc/filesystems

-L label//Mount by volume label

Mount-l Mydata/tmp/test

-U uuid//mount with UUID indication device

-A//Mount all/etc/fstab

Displays all of the FS that have been mounted without parameters

What is Cgroup?

-O Options Mount Properties

Note: Some options can only be used in the/etc/fstab file

Async Async Write

Sync Synchronous Write

-atime/noatime update timestamp as soon as a file or directory is accessed

Close better

Whether the Diratime/nodiratime directory updates the timestamp when it is accessed

Remount Re-mount

-O ACL supports the use of the Facl feature

Default mount is not supported for FACL

Tune2fs-o ACL/DEV/SDB1//ACL is enabled on the device, and when you mount again, you can use ACLs even if you do not specify-o,acl

Tune2fs-l/DEV/SDB1//view options

Mount/dev/sdb1/mnt

Mount//will show, no ACL

But setfacl-m u:wolf:rw--can still use

RO Read Only

RW Read/write

Dev/nodev//Whether to allow device files to be created on this device

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

Prevent illegal programs, run automatically

Auto/noatuto//Whether to allow Mount-a to mount automatically

User/nouser//Whether to allow ordinary users to mount this FS

Defaults: Default//

Rw,suid,dev,exec,auto,nouser,async,relatime

Suid: Allow suid and Sgid permissions on program files to take effect, nosuid disable

Relatime: Whether a bureau mtime and CTime to modify Atime

One use technique:

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

Mount--bind/etc/mnt

View devices that are already mounted on the current system

Mount

Cat/etc/fstab

Cat/etc/mtab

Cat/proc/mounts

Mount Optical Devices

Mount-r/dev/cdrom/mnt-o iso9660

/dev/sr0 is CDROM.

Mount USB flash Drive: Implement device file to identify U disk

Forced Uninstall: Device

LSOF/MNT//show the process that occupies the directory

Yum Install Psmisc

Www.rpmfind.net

RPM-QL Psmisc

FUSER-KM/MNT//Delete the process to

Fuser-v Mount_point//See who is occupying

To mount a local loopback device:

Mount-o Loop/path/to/some_loop_file

Img,iso file

Swap partition:

Create Swap partition: Mkswap

Swapon [OPTION] [DEVICE]

-A//all swap devices defined in the/etc/fstab file

Swapoff

Set Root FS to accidentally mount the other FS boot automatically, using the/etc/fstab file

A script is run when it is powered on, and the script calls Fstab

/dev/mapper/centos-swap swap swap defaults 0 0

1. Mount the device:

Device files, Label,uuid, pseudo FS:SYSFS proc TMPFS

2. Mount point:the swap type's mount point is swap

3.fs_type:

4. Mount Options:

Defaults, using the default Mount option

Multiple use, divider: defaults,acl,noatime

5. Dump Frequency

0 never back up

1 Backup once a day

2 Backup once every other day

6. Self-Test order

0 not self-test

1 First self-test, usually root FS available 1

2 Secondary self-test

...

Label=mydata/mydata EXT4 Defaults 0 0

Uuid= ...//can also be

DF and Du

DF command

-H humanized Display

-L displays only local FS, otherwise all include network FS

-I inode usage instead of blocks

Du display file size

-S summary Total size

-H human-readable

3. Practice :

1. Create a 10G partition and format the FS as Ext4

(1) block size is 2048, reserved space is 2%, volume label is MyData

mkfs.ext4-b 2048-m 2-l mydata/dev/sdb1

(2) Mount the/mydata directory, requiring the program to be automatically run when mounted, without updating the file's access timestamp

Mount/dev/sdb1/tmp/test-o Noexec,noatime

or use TUNE2FS

2. Create a 1G swap partition, boot automatically mount

Vim/etc/fstab

The use of 4.fuser is detailed:

-c|-m for POSIX support

-K Kill the process of accessing the file

-I ask the user before killing the process

-U Display user

-V Show More information

What to display:

Advanced Linux 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.