Linux Disk Management

Source: Internet
Author: User
Tags readable uuid inode usage

Disk Management

Device files

Block device: Equivalent to a sector of 512 bytes

Parallel interface: (there may be interference during transmission, the serial port is used at present)

ide:133mb/s

SCSI:640MB/S (Server Interface)

Serial:

sata:6gbps (Home Drive interface)

sas:6gbps (most server interfaces now)

usb:480mb/s


RPM: Mechanical hard disk speed, the faster the speed, the better performance


Mechanical HDD If the data is lost, there is a chance to recover some of the data, and the solid-state disk loses the data.


Device file name for disk device:/dev/dev_file

Regardless of the interface, the last name is/DEV/SD: Except for the virtual disk named/DEV/VD

Scsi,sata,sas,ide,usb:/dev/sd

Centos7 using Gnome-disks to view the status of disk partitions in a graphical interface

CENTOS6 uses Palimpsest to view the graphical interface

Different disk identities: A-Z, if you break 26 disks it will show Aa,ab

/dev/sda,/dev/sdb ....

Different partitions on the same device: ...

MBR partition primary partition up to 4, device name 1-4, extended partition Plus primary partition up to 4, one computer on at least one primary partition

/dev/sda1,/dev/sda5

Hard disk storage Terminology

Head: Head, number of heads = Number of discs, support 256 heads

Track: tracks (the position of a lap to which the head is to point, 1024 laps)

Cylinder: Column Name

Sector: sector, with 63 sectors in one lap, 512bytes bytes per sector

Calculate Disk size = sector (up to) x lap (x1024x256) The result is a number of bytes. Early Calculation formula


Purpose of partitioning

Optimizing I/O performance

Limit the amount of space a user occupies in a few partitions by implementing disk space quota limits

Improved repair speed

Isolate systems and programs to prevent a bad all-bad

Install multiple OS

Use a different file system


Pali

Two methods of partitioning: MBR,GPT

MBR: Master boot record, using 32 bits to represent the number of sectors, 2 of the total capacity of 32 sector sectors, 2T, by cylinder partitioning

0 Tracks 0 Sectors: storage of partition information about the hard disk, 0 tracks of 0 sectors called MBR


GPT Partition

Uuidgen generating random UUID numbers

UUID128 bit, 8-bit followed by 3 4-bit, followed by 12-bit, uniquely identifies the resource


Manage partitions:

List blocks device: LSBLK (viewing disk information in memory cache)

How to view partitions

(1) ls/dev/sd* (the number after SD indicates partition success)

(2) Cat/proc/partitions (see also in-memory disk information)

(3) Lsblk (see also in-memory disk information)

(4) Fdisk-l (see Partition table on disk)


When the in-memory disk information is not the same as the disk information above the device, use the following solution

Partprobe "Device Name" synchronizes a partition table for a device

CTENOS6 above sync

Adding partitions causes different steps to use partx-a "device name"

Deleting a partition causes the partx-d--nr "missing partition number" "Device name" to be used in a different step


To create a partition using:

Fdisk ' device name ' created to manage MBR partition (the partition table in the disk after creation is not synchronized with the partition table in memory)

Sync with partx-a ' device name ' on CENTOS6 if not synchronized after adding partitions

Deleting a partition causes unsynchronized synchronization on CENTOS6 using partx-d ' device name '--NR ' deleted partition number '

Centos 7 is synchronized using Partprobe

Fdisk-l [-u] [device ...] viewing partitions

Fdisk "Device name" management partition

Sub-command:

P Partition List

t change the partition type

n Create a new partition

D Delete Partition

V-Check Partition

U Conversion Unit

W Save and exit

When you want to define the partition size, the first line is usually the default, and the following last cylinder can be followed by the size to be partitioned, using +size{g| M} format

Gdisk "Device Name" to create a GPT partition, interactive operation

Parted advanced partitioning operations


Swap partition coded to 8200

Parted usage: parted [options] ... [Device [command [parameters] ...] ...]

Parted "Specify a hard Disk" Mklabel "Msdos (MBR) |gpt (GPT)" Specifies whether to create an MBR format or a GPT format

Parted "Device name" print prints the specified device information

Parted "Specify a hard disk" Mkpart Primay 1 1000 default to m (create a primary partition size of 999M)

Parted-l View information for all devices


File system: To build a file system after separating the points, there is no file system without directories and files

Blkid to view the device's file system

Linux file System: EXT4 (Extended file system abbreviation), XFS (support for larger files), Btrfs (Oracle's file system), SWAP (used when physical memory is insufficient)

Disc: iso9660

Network File system: Nfs,cifs

View supported file system types: ls/lib/modules/"native kernel"/kernel/fs/

RAW: Optical Partitioning does not format the resulting file system


Create file system Centos6 Default file system for EXT4,CENTOS7 default file system for XFS

Ext2 and ext3 difference: ext2 No log function, Ext3 has a log function, ext3 and EXT4 no essential difference

An extended partition is a file system that cannot be created directly


MKFS command:

Mkfs. " File system type "device Partition"

-B {1024|2048|4096} ' device name ' divides the target device into individual block sizes

-N Number ' device name ' Set device name inode number

Mke2fs-j ' Device name ' (Partition ext2 file system type for target device and log function)

-L (Label): The partition is labeled, that is, the description of the partition, the mount point directory is called What, this is suggested what to call

E2label the "Device Partition" label, and then add the volume label after dividing the file system type.

Tune2fs-l "Device Partition": View a series of descriptive information for the partition (for the EXT series file system to view)

-O ' property name ': Change the file system properties;

-O Change mount options, and delete to precede the Mount option after-o plus ^

Fsck ' Device name ': Check the status of the device is intact, damaged or repaired, some data may be lost during the repair process

-U change the device's UUID number


Blkid viewing the device that created the file system

-U find device based on UUID

-L Find device based on volume label name

Uuidgen generating Random UUID

DUMPE2FS ' device name ' to see the grouping in one device

-H Display only metadata information does not display grouping information

Findmnt to determine if the target is a mount point


The/etc/mtab file is updated as the mount is mounted

Cat/proc/mounts will display more detailed mount information

Mount Mount Method: Mount DEVICE mount_point (mount point)

Use lsof ' device name ' to query the status of the target device if the directory you are uninstalling is in use and you want to uninstall it.

Mount: Displays all devices that are currently mounted by viewing the/etc/mtab file

Mount-n do not update/etc/mtab file mount, Mount command is not visible

-R takes a read-only way to mount (default is to have RW permissions)

-l ' label ': Specify the Mount device ' label ' as the volume label name

-U ' UUID ': Specifies the device to be mounted with the UUID

-B or--bind: Mount directory to directory (example: Mount-b/mnt/sdb2/app/sdb2) folder of two directories is the same

-a reads and mounts rows that are not mounted in the/etc/fstab


Mount Common Command Options

-O Options: (option to mount file system), multiple options with comma-separated

Async: Asynchronous mode, which writes data to the buffer area first, and writes the data to the hard disk when the system is not busy, the efficiency is higher (default)

Buffer: When writing data, temporary storage of data written to disk

Caching cache:

Sync: Synchronous mode to write data directly to the hard drive

Atime/noatime: You can cancel your device's Atime update and turn on Atime updates

Diratime/nodiratime: Atime update and not update of directory

Auto/noauto: Whether to turn on automatic mounting

Exec/noexec: Whether the program on the file system can run

Dev/nodev: Whether to support the use of device files on this file system

Suid/nosuid: Whether Suid and Sgid permissions are supported

Remount: Re-mount, immediate effect (more commonly used)

RO: Read-only

RW: Read and write (default mount will have read and write permissions)

User/nouser: Whether to allow ordinary users to mount the device, use the/etc/fstab file

ACL/NOACL: Enable ACL functionality for this file system

Loop: Using the loop device, you can set the file as a mount point (you can manually create a loop device file, mknod/dev/loop[number] B device number


Preparation: MKNOD/DEV/LOOP8 B 7 8,losetup: Man-made device associated with the file Losetup/dev/loop8/app/partfile2 losetup-a Show All devices


Correspondence to the file)

Defaults: equivalent to Rw,suid,dev,exec,auto,nouser,async


File Mount configuration file

/etc/fstab each row defines a file system to mount, enabling auto-mount

File format: (compare the recommended device name to write the device's UUID number, use Blkid to view, can also write device volume label, no file system write none)

Device name mount point file system mount option (a series of options after Mount-o) backup tag file system check (first few checks)

/DEV/SDB2/MNT/SDB2 ext4 Defaults,ro 0 0


Processing swap partitions

Create a swap partition, numbered 82

Mkswap device name target device divided into swap file system

Swapon-a the swap mount that does not work in the/etc/fstab is turned on

Swapon-s View the information of the swap partition, adjust the priority of the swap partition, change the defaults to pri= ' big priority ' swapoff in/etc/fstab and then swapon take effect


Mobile devices

Eject: Eject optical drive

-T bounces into the optical drive

Create an ISO file

Cp/dev/cdrom/root/centos7.iso (Copy the disc file from the/dev/cdrom to/root and named Centos7.iso)

Package a catalog as an ISO file

Mkisofs-r-o "File storage location after package" "Directory Name to package"

To synthesize two discs into one disc step:

Go to wiki.centos.org search mkdvdiso.sh Click the first result to download this script


Free View Memory

-M in megabytes, by default, in K units

-G as a unit

-H human Readable mode display

DF to view the disk space utilization being mounted

-I view inode usage

-T File system type

-P output in POSIX-compatible format

Du view directory overall space consumption status

-sh display results in a human readable manner

--max-depth Max Depth Catalog statistics

Tool DD

DD Command: Reads the specified source to the target

Usage:

DD if= Source Path of= Destination Path

Bs= Size: Block size, per read

count=#: How many BS do you copy?

Of=file writes to the named file instead of to the standard output

If=file read from the named file instead of the standard input

Bs=size the specified block size (both IBS and OBS)

Ibs=size read size byte at a time

Obs=size write a size byte at a time

Cbs=size One conversion size a byte

Skip=blocks ignores blocks of IBS-sized blocks from the beginning, while reading

Seek=blocks from the beginning to ignore the blocks of the size of the OBS block, when writing

Count=n Copy only N records


Conv

Conversion parameters:

Notrunc output file is not truncated

UCase Convert lowercase to uppercase

LCase Convert uppercase to lowercase

Nocreat does not create an output file, the of file does not exist and does not create

NoError does not stop when an error occurs

Sync fills each input block into IBS bytes, and the less part is padded with empty characters


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