Linux Basic Management--Disk Management

Source: Internet
Author: User
Tags uuid

1. Equipment Files


I/O ports:i/o device address.


Use of device files:

By associating a file to a device driver, you can communicate with the corresponding hardware device. Everything is file, so the disk is also based on the device file to communicate with it: open (), read (), write (), close ()


Device number:

Main device number: Major numbers, identifies device type, secondary device number: Minor numbers, identifies different devices under the same type.


HDD Interface type:

Parallel: ide:133mb/s scsi:640mb/s serial: sata:6gbps sas:6gbps usb:480mb/s Rpm:rotati ONS per minute



Device file name for disk device:

/dev/dev_file SCSI, SATA, SAS, Ide,usb:/dev/sd; virtual disks:/DEV/VD; different disk identities: A-Z,AA,AB.../DEV/SDA,/dev/sdb, ... Different partitions on the same device:/DEV/SDA1,/dev/sda5;



2. Disk structure


2.1, Mechanical hard disk (HDD)




2.2, solid-state drives (SSDs) and mechanical hard drives (HDD)




2.3, hard disk storage terminology and sector structure


Head: Head;
Track: Tracks;
Cylinder: cylinder surface;
Sector: Fan area, 512bytes;


(1) Early sector structure



(2) Location record disk sector structure: ZBR (Zoned Bit recording)



2.4, CHS and LBA


CHS:

24bit bit addressing, maximum addressing space 8GB;

LBA (Logical Block Addressing)

LBA uses 48 bit-bit addressing maximum addressing space of 128PB


Attention:

Since the address space of CHS is within approximately 8GB, it is possible to use CHS addressing or LBA addressing when disk capacity is less than about 8GB, and only LBA addressing can be used when disk capacity is greater than about 8GB.



2.5. Use partition space


Device identification, device partitioning, creation of file systems, marking of file systems, creation of entries in/etc/fstab files, mounting of new file systems;


2.5, the meaning of disk partitioning and partition type


Disk Partitioning Significance:

Optimize I/O performance achieve disk space quota limits improve repair speed isolation systems and programs install multiple OS with different file systems



Two ways of partitioning: mbr,gpt


2.5.1, MBR


Mbr:

Master Boot record,1982 year, using 32 bits to represent the number of sectors, partitions not exceeding 2T; by cylinder


MBR partition structure:

HDD Master boot Record The MBR consists of 4 parts: the Master Boot program (offset address 0000h--0088h): It is responsible for loading from the active partition and running the system boot program.        Error message Data area: Offset address 0089h--00e1h is an error message, 0e2h--01bdh is all 0 bytes.    Partitioned tables (Dpt,disk Partition table): With 4 partition entries, offset address 01BEH--01FDH, 16 bytes per partition table entry, 64 bytes, partition entry 1, partition item 2, partition item 3, partition Item 4 End Glyph: The 2-byte value of the offset address 01fe--01ff is the end flag of 55AA.



2.5.2, GPT partitioning

Gpt:

GUID (Globals Unique Identifiers) partition table, supports 128 partitions, uses 64 bits, supports 8Z (512byte/block), 64Z (4096byte/block), uses 128 Bit uuid (universally Unique Identifier) represents disk and partition, GPT partition table is automatically backed up in head and tail two parts, and CRC check bit UEFI; (Unified extension Firmware interface) hardware supports GPT, enabling the operating system to boot


3. Partition Management


3.1. Graphic

Graphical Disk Management tool: Click "Applications", "System Tools", "Disk"; Execute command gnome-disks


3.2. Partition Management


List block devices: LSBLK; Create partitions using: Fdisk to create MBR partitions, gdisk to create GPT partitions, parted advanced partition operations, partprobe-to reset kernel partition table versions in memory;


3.3. Parted command


Note: The operation of parted is in real-time, use carefully

Grammar:

parted [options] ... [Device [command [parameters] ...] ...]

Example:

Parted/dev/sdb Mklabel gpt|msdos parted/dev/sdb print Parted/dev/sdb Mkpart Primary 1 200 (default m) parted/dev/sd b RM 1 Parted-l


3.3. Partitioning tools: Fdisk & Gdisk


GDISK/DEV/SDB: GPT partitioning tool for class Fdisk; fdisk-l [-u] [device ...] view partition; Fdisk/dev/sdb manage partition;


Sub-command:

P Partition list t change partition type N Create new partition d Delete partition v check partition u convert unit w save and exit Q do not save and exit



To see if the kernel has identified a new partition: Cat/proc/partations


Synchronization partition Table:

CENTOS6 notify kernel to re-read hard disk partition table: New partition by: Partx-a/dev/device kpartx-a/dev/device-f: Force Delete partition by: Partx -D--nr m-n/dev/devicecentos 5, 7: Using Partprobe partprobe [/dev/device]



4. File System Management


4.1. File system Type

Linux file systems: ext2 (Extended file system), EXT3,EXT4, XFS (SGI), Btrfs (Oracle), ReiserFS, JFS (AIX), swap discs: iso9660 Window S:fat32, Exfat,ntfs unix:ffs (FAST), UFS (Unix), JFS2 Network File system: NFS, CIFS cluster file system: GFS2, OCFS2 (Oracle) Distributed File system: F Astdfs,ceph, Moosefs, Mogilefs,glusterfs, Lustre RAW: Non-processed or unformatted file system


Pre-check supported file systems: Cat/proc/filesystems


4.2. Create File system

MKFS command: (1) mkfs. Fs_type/dev/device ext4 xfs btrfs vfat (2) mkfs-t fs_type/dev/device-l ' LABEL ': Setting the label


To create the Ext file system:

Mke2fs:ext Series file system dedicated management tool;-T {EXT2|EXT3|EXT4}-b {1024|2048|4096}-l ' LABEL '-j: equivalent to-t ext3; mkfs.ex T3 = mkfs-t ext3 = mke2fs-j = Mke2fs-t Ext3-i #: Creates an inode for each number of bytes in the data space, which should not be less than the size of the Block; N #: Specifies how many of the partitions are created Inode;-I an INODE record consumes disk space, 4096---;-M #: Default 5%, the percentage of total space reserved for administrative staff;-O feature[,...] : Enables the specified attribute;-o ^feature: Turns off the specified attribute;


File System Tags:

Another method of pointing to a device is device Independent


Blkid: Block device property Information view; syntax: Blkid [OPTION] ... [Device]-U UUID: finds the corresponding device according to the specified UUID-L label: finds the corresponding device according to the specified LABEL
E2label: Label E2label DEVICE that manages the EXT series file system [Label]


Findfs: Find partition Findfs [options] label=<label> Findfs [options] uuid=<uuid>



Tune2fs

Reset the Ext Series file system to adjust the values of the parameters;-L: View the specified file system super block information; Super block-l ' LABEL ': Modify the volume label-M #: Fix the percentage of space reserved for administrators-j: Upgrade ext2 to Ext3 -O: File System Properties enabled or disabled, –O ^has_journal-o: Adjust default mount options for file system, –O ^acl-u UUID: Modify UUID number


DUMPE2FS:

Block group management, 32768-H: View Super block information, do not display grouping information


4.3. File system detection and Repair

Often occurs after a crash or abnormal shutdown; mount the file system labeled "No clean"; Note: do not fix it in a mounted state;
Fsck:file System checkfsck.fs_typefsck-t fs_type-p: Auto Fix error-r: Interactive fix error fs_type must be the same as the file type on the partition;


E2fsck:ext series file-specific detection repair tool-y: Auto answer for YES-F: Forced repair



5. Mounting


Mount:

Establish an association between an additional file system and an existing directory of the root filesystem, thus making this directory a gateway to other file accesses


Attention:

The existing file under mount point will be temporarily hidden after the mount is completed, the mount point directory is generally empty, pre-existing, the recommended empty directory, the process is in use of the device cannot be uninstalled;


Grammar:

Mount DEVICE Mount_pointmount [-FNRSVW] [-t vfstype] [-O options] DEVICE dir
-T Vsftype: Specifies the file system type-r:readonly on the device to be mounted, read-only Mount-w:read and write, read-write mount-N: Do not update/etc/mtab,mount invisible-A: Automatically mount all supported automatic         Mounted device (defined in/etc/fstab file with auto function in Mount option)-l ' LABEL ': Specify mount Device as volume label-u ' UUID ': Specify device to mount with UUID-B,--bind: Bind directory to another directory View all mounted devices tracked by the kernel cat/proc/mounts



-O Options: (option to mount file system), multiple options separated by commas

Async: Asynchronous Mode Sync: Synchronous mode, memory change, simultaneous write disk Atime/noatime: Include directory and file diratime/nodiratime: Directory Access timestamp Auto/noauto: Whether auto mount is supported, yes No support for-a option exec/noexec: Support for running application Dev/nodev on file system: support for using device files on this file system Suid/nosuid: Support Suid and Sgid permissions remount: Re-mount R O: Read-only RW: Read-write User/nouser: whether to allow ordinary users to mount this device,/etc/fstab use ACLs: Enable the ACL feature on this file system loop: Using the loop device
Defaults: Equivalent to RW, suid, dev, exec, auto, nouser, async



6. Uninstall command


viewing mount conditions

Findmnt Mount_point|device


To view the process that is accessing the specified file system

Lsof mount_pointfuser-v Mount_point


Terminates all processes that are accessing the specified file system

fuser-km Mount_point


Unloading

Umount Deviceumount Mount_point




7. File Mount configuration file


Note: Use the mount-a command to mount all file systems in the/etc/fstab

/etc/fstab each row defines a file system to mount: 1) The device or pseudo-file system to be mounted;    equipment files;    Label:label= "";    Uuid:uuid= "";    Pseudo file system name: Proc, sysfs;2) mount point; 3) file system type; 4) mount option: defaults;5) Dump frequency: 0: Do not do backup 1: Dump every day 2: Dump every other day, 6) self-test: 0: not self-checking; 1: First self-test, usually only rootfs 1;




8. Processing Exchange files and partitions


Swap partitions are a complement to system RAM.


8.1. Basic settings

Create swap partition or file use Mkswap Write special signature Add appropriate entry in/etc/fstab file use swapon-a to activate swap space




Enable and disable the swap partition:

Enabled: Swapon
Swapon [OPTION] ... [DEVICE]-A: Activates all swap partitions;-P Priority: Specifies the precedence/etc/fstab:pri=value
Disabled: Swapoff [OPTION] ... [DEVICE]


8.2. Priority of Swap



You can specify the priority of the swap partition 0 to 32767, the higher the value the higher the priority, if the user is not specified, then the core will automatically assign a priority to the swap, starting from 1, each added a new no user-specified priority swap, will give this priority to one; The default priority of the first added swap is higher, unless the user specifies a priority, and the user-specified priority (positive) is always higher than the core default (negative); optimized performance: Distributed storage, high-performance disk storage;



Linux Basic Management--Disk Management

Related Article

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.