Third, Linux disk and file system management

Source: Internet
Author: User
Tags bz2 file copy uuid disk usage

Disk partition formatting:

/bin,/sbin: binary programs, the operating system itself is required to run the program.

/usr/bin,/usr/sbin: Binary program, basic system Management tools, commands.

/usr/local/bin,/usr/local/sbin: Third-party programs, commands.

/lib: Provides interface services for the core communication with the bin, sbin, and/usr/, and Sbin.

/etc: Provides configuration file commands for/bin and/sbin.

/tmp

/var: provides a directory that changes frequently, like log, mail, cache

/proc: The representation of the kernel data, which can change the kernel performance by modifying the parameters.

/sys: Hardware Information

/dev: Device type:

B: Random Device

C: Linear device

HDD Device: Random access device

I/O: Controller

I/o:adapter

In general, the parallel interface is faster than the serial interface, but when the rate increases, there will be crosstalk, so the current serial interface devices higher than the parallel interface such as SATA interface is much faster than the previous SCSI.

For the most part, the integrated chip is called the controller, and the non-integrated chip is called the adapter.

Disk Hardware parameters:

Track, sector sector, cylinder: a set of identical tracks on different disks is called a cylinder.

Average seek time: The time the machine arm moves to the sector and waits for the data on the disk to be read is called the average wait time

IDE (Parallel Transport Interface) ata:,133m/s------------>>SCSI:SAMLL Computer system Interface 320mb/s------>>sas (serial port):

SATA (serial port): 300mb/s-6gb/s

Solid-State Drive Ssd:sata interface

Linux labeling methods for different hard disk interfaces:

IDE, ATA:/dev/hd[a-z]

SCSI, SAS, SATA, Usb:/dev/sd[a-z]

Formatting a disk is the process of creating a file system called Advanced formatting

Mbr:master boot Record master boot records, 512byte, are excluded when partitioning.

Include: 446byte is bootloader, the remaining 64byte is used to create the partition table, each partition table is represented by 16 bytes, so the default maximum of 4 partitions.

Extended partition: It needs to be divided into logical partitions again. In fact, the logical partition table is partitioned separately by another partition, with the MBR not being together.

To create a partition:

Fdisk, Sfdisk, parted

To view the disks available to the system: fdisk-l

View disk usage in detail: fdisk-l/dev/sd[a-z]

The FDISK command is detailed

-D: Delete a partition

-N: Create a partition

-P: Disk partition information

-W: Save exit

-Q: Do not save exit

-L: View the system ID for each partition


Fidisk-l/dev/[sh]d[a-z]

To see if the system kernel already recognizes the hard disk partition: Cat/proc/partitions,

Normally a restart is required after partitioning, and you can use Partprobe [device] to achieve the same goal. (CentOS 6 is not supported and can be done using partx-a parttition)

Format system (create partition)

Mkfs:make File System

Blkid:block ID view partition information, including UUID, file system type.

Points:

1, the file system must be kernel Linux supported file system, EXT3, NFS, CIFS and so on.

2, to have the corresponding file system creation tool, usually refers to Mkfs.fstype. You can see which tools are supported by MKFS's completion method.

Mkfs-t ext4 =MKFS.EXT4 =mke2fs-t ext4

Mkfs-t XFS =MKFS.XFS

Mkfs-t ext3=mkfs.ext3=mke2fs-j =mke2fs-t ext3

650) this.width=650; "src=" http://note.youdao.com/src/CB19A6EAD06A41F7BF846F81103BBF12 "style=" MARGIN-TOP:8PX; Line-height:1.5;width:800px;height:auto; "alt=" Cb19a6ead06a41f7bf846f81103bbf12 "/>

MKE2FS: function is more powerful than MKFS, also can realize all functions of MKFS.

-L: Set volume label

-B: Specifies the block size. {1024/2048.4096} block size depends on CPU support for memory page frame size, x86 default support 4k (4096)

-M: By default, when the system is formatted, 5% blocks (block) will be reserved for the system (reserved blocks count), which will cause some waste and can be adjusted by this parameter.

Example: Mke2fs-l system-b 1024-t ext4-m 3/dev/sdb1

TUNE2FS: Ultra-detailed display partition, block information, is the adjustment of MKE2FS settings, similar to Useradd and usermod relationship.

-O: Set mount default options

-O: Set file system default attributes

-R: Adjust the number of blocks reserved for administration to use, not as much as-M.

-E: Adjusting extended properties of a file

-L: View block information.


E2lable: Sets the volume label. Functions are the same as tune2fs-l.


Configuration file:/etc/mke2fs.conf, which sets the default attributes, as well as the unique properties of the file system.

Mount: Mount Drive and device

-O: Used to specify mount options, common mount options:

DEFAULT:RW, suid, Dev, exec, auto, nouser, async, Relatime.

RO: Mount Read-only

RW: Read and write, default options.

Noatime: Turn off update access time

Auto: Whether it can be mounted automatically by ' mount-a '.

Sync: Synchronous Write

Async: Asynchronous Write

NOEXEC: This option is typically selected when mounting a strange disk.

Remount: Re-mount. Mount-o Remount,ro noexec/dev/sdb1/mnt

Loop: Image File ISO

-N: The/etc/mtab file is not updated when the system is mounted, that is, the contents of Mount Mount are associated with the mTAB

-R: Equivalent to "-O-Ro" read-only Mount

Fuser:file user to see which users are using a file, the main view of the process.

-KM: Forcibly kills the process that is accessing this file.

-VM: You can see which processes, users, and commands a file is being invoked by.

Multiple options are separated by ",".

Cdrom-->sr0

Cdrom-->hdc

Simply say the difference between synchronous and asynchronous, first of all, when the user writes the file to the disk, the disk will be the file into memory, and then edit, when the need to save, if saved to the memory and also saved to the hard disk, this is called Sync Sync, If you save the data temporarily in memory, and the memory is unified management, determine the time to write data to disk, this operation is called asynchronous Async.

The asynchronous way of reading and writing is fast, the general situation is the asynchronous way, you can write the disk by the policy to determine the frequency of memory written to the disk.

When uninstalling, ensure that no process is accessing the mounted device, and the user can no longer need to uninstall the device directory.

/etc/fstab: File system configuration file that is automatically mounted on system boot.

FileSystem: A software, (fdisk, MKE2FS, MKFS) that requires the kernel to implement

Windows:ntfs, Fat

LINUX:VFS (virtual file system)

EXT, XFS

iso9600

NFS, CIFS

EXT4 series, JFS, Reiseerfs, VFAT

GFS Series

/etc/fatab Explanation:

Mounted devices: You can use device files, labels, UUID

Mount point: Location to mount

File System Type: EXT Series

Mount options: Default, multiple options are separated by commas.

Dump frequency: Backup frequency, dump backup, you need to write the plan with dump first.

0: Never Back up

1: Daily backup, 1 days a standby

2: Backup every other day. 2 Days of preparation

Self-Test order: Boot system disk check (0 recommended, no disk check)

Mount-a: Represents the mounted device that is defined in the Fstab file, and the device set to auto in the option is automatically mounted.

Interactive partitioning of Linux: Swap

View Memory: Free, Ll/proc/meminfo

-M: Displayed in megabytes

-G: Displayed in GB

Buffer: Can erase data to increase speed buffer

Cache: Caching

If the swap partition is not enough, how do I create a new partition for swap use?

Fdisk/dev/sdb

N

T 82 adjust the partition type to swap

W Save exit

Partx-a/DEV/SDB5 (not necessarily successful)

DUMPE2FS: Output ext file system information.

-H: Displays information about the Super block.

Du: View file Usage disk usage

-s:summary Displays the sum of the sizes of all files under a specified path

-H: Displayed in human mode

DF: Shows the use of disk mount points, space size

-H: Displayed in human mode

-l:local, displays local disk usage.

-p:posix-compatible style display

-I: Displays information about the inode for the disk, not the block information.

Delete, move, copy

Thinking

Link file:

Hard Links: two files of different paths point to the same inode number, meaning that the content is the same. Deleting any file does not delete the inode, that is, it does not affect the existence of the original data, but if the link is the last link, the original data for the Inode link is deleted.

Ls-l the number shown in the second paragraph is the number of hard links.

Characteristics: 1, the inode point is not to cross-partition.

2, hard links can not point to the directory, that is, you can not create a directory link.

3. The inode link file is the same as the source file.

Soft Connect: Symbolic link, symbolic link,

Ls-l: File content type is displayed as ' l '

If the test file is a symbolic link in bash, use-l or-H

Features: 1, not restricted by the partition.

2. Ability to create links to directories

3, delete the original file, the linked file cannot be used, but delete the linked file, the source file is not affected.

4, the link file content display includes '--'

5. inode link file and source file are different

6, the size of the linked file is actually the number of source file name string.

-S: Creates a soft connection.

-V: Displays the Create detailed procedure.

LSATTR: Show file extension properties

Chattr: Modify file extension properties (+-, add delete attribute)

-I: Set file properties as read-only properties

-A: You can only append content, you can not modify the original content

-U: cannot be deleted

File compression, decompression, and archiving.

Gzip/bizp2/xz, compression ratio in ascending order, that is, XZ compression ratio is maximum.

1, the default compression after the source file disappears.

2, Compression ratio: 1-9, the default is 6, the smaller the compression ratio consumes less CPU.

3. Cannot compress directory

Gzip:.gz

Decompression: Gunzip =zip-d

-#: Setting the compression ratio

-C File>dfile: Redirect The compressed file to the destination file gzip-c gongbing >123.gz

Zcat: No pressure to view the contents of the file.

bzip2:*.bz2

-D: Unzip

-K: Keep source files

Bzcat: Viewing Compressed file contents

Xz:xz

Decompression: Unxz = xz-d

Xzcat: Viewing Compressed file contents

Archive: Archive,

Putting a class of files together (disk, tape, partition, folder) for management is called archiving, and the archive itself is not compressed, and multiple files become a file after being archived.

Tar

-C: Create an archive

-X: Expands the archive and, when expanded, restores the archive to the current directory.

-F: Specifies the file name after the archive, typically with. tar as the suffix.

-T: Do not expand the archive to view file list information.

-C: Specifies the location to restore the archive file.

-Z: Call gzip, with-C with the expression compression, with-X with the expression decompression.

-j: Call bzip2, with- C with the expression compression, with-X with the expression decompression .

-j: Call XZ, with the- C with the expression compression, with-X with the expression decompression .

-P: Lowercase, leaving the backup data with the same permissions and attributes as the original data.

-P: Uppercase, reserved absolute path, cautious use, usually when the decompression will be restored to the original location, if the/etc is archived, when the restoration will overwrite the original file, resulting in loss.

--exclude=path/file: Exclude certain files or directories

--newer: Back up a new file than a file

--newer-mtime: A new file is backed up when a file is modified.

Example: 1. Create an archive file

Tar-c-F Rinit.tar init/r*

2. Archive file expands to the specified directory

Tar-x-F 123.tar-c/tmp/

3. Archive and Compress files

Tar-zc-f 123.tar.gz/tem/*

4. Unlock the file specified in the archive

Tar-ztvh-f/root/etc.tar.bz2 |grep "Shadow"

Identify files that need to be decompressed

Tar-zxvh-f/root/etc.tar.bz2 Etc/shadow

5. Package a directory, but exclude some files from the directory

Tar-jcv-f/root/back-etc.tar.bz2--exclude=/etc/sysnet*/etc

6, just back up a new file than at some point

Tar-jcv-f/root/etc.newer.then.pass.tar.bz2--newer-mtime= "2015/09/11"/etc/

Zip: file suffix. zip For example: Zip init.zip/tmp/*

Unzip: Decompression

Hdparm:ide/sata Hard Drive Properties view the Settings tool.

DD: File Copy command, unlike CP, commonly used for virtual disks

-if: Source file

-of: Destination file

Count: Specify the block size

Bs:block size block sizes K, m, g represent bytes

DD IF=/DEV/SDA of=/root/sda_mbr.back bs=512 count=1 (backup MBR file)

DD If=/root/sda_mbr.back OF=/DEV/SDA bs=512 count=1 (restore MBR file)

/dev/zero:0 generator, used to generate countless 0

/dev/null: File Black hole

To create an interactive partition:

Mkswap Device

To start an interactive partition:

Swapon device Specifies the interactive partition to start

Swapon-a Start all interactive partitions

Swapoff-a closing an interactive partition

Boot auto-Start interactive partition, you can define/etc/fstab

Device swap swap default 0 0

SYSV Network Service Script

Service Network Restart =/etc/rc.d/init.d/network Restart =/etc/init.d/network restart

650) this.width=650; "src=" http://note.youdao.com/src/1D526209E9704156BC91071C4B0644D1 "style=" MARGIN-TOP:8PX; Line-height:1.5;height:auto; "alt=" 1d526209e9704156bc91071c4b0644d1 "/>


Third, 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.