8. Disk partitioning, formatting, mounting and RAID

Partition, format, mount

fdisk: Create partition
fdisk -l [-u] [device...]

  • List the partitions on the specified disk device
    fdisk [-uc] [-b sectorsize] [-C cyls] [-H heads] [-S sects] device
  • disk provides an interactive interface to manage partitions. It has many sub-commands for different management functions; all operations are completed in memory and not directly synchronized to the disk; until the w command is
    used to save to the disk; commonly used command:
  • n: create a new partition
  • d: Delete existing partition
  • t: modify the partition type
  • l: View all IDs
  • w: save and exit
  • q: Exit without saving
  • m: View help information
  • p: Display existing partition information.
    Note: A new partition created on a disk device that has been partitioned and one of the partitions has been mounted may not be recognized directly by the kernel after the creation is complete;
    check the kernel partition table
  • cat /proc/partitions
    informs the kernel to force reread the disk partition table:
  • CentOS 5:partprobe [device]
  • CentOS 6,7: partx -a [device] or kpartx -af [device]
    mkfs: create file system
    mkfs [options] [-t type] [fs-options] device [size]
    options
  • -type:ext2/3/4、btrfs、xfs

  • fs-options:

  • -b {1024|2048|4096}: Specify the block size of the file system;

  • -L LABEL: specify the label;

  • -i #: bytes-per-inode, indicating the ratio of inode to byte; that is, how many bytes to create an Indode;

  • -N #: Directly specify the number of inodes to be created for this file system;

  • -m #: Specify the reserved space, percentage;

  • -O [^]FEATURE: Create the target file system with the specified characteristics;

  • Note: Each FS has its own fs-options options, but basically there are several options above
    mount: mount file system
    mount [-fnrsvw] [-t vfstype] [-o options] device dir
    options
    --r : Readonly, read-only mount;
  • -w: read and write, read-write mount;
  • -n: By default, device mounting or unmounting operations will be updated to the /etc/mtab file; -n is used to disable this feature;
  • -t vfstype: Specify the type of file system on the device to be mounted; in most cases it can be omitted, at this time mount will use blkid to determine the file system type of the device to be mounted;
  • -L LABEL: Specify the device as a volume label when mounting;
  • mount -L LABEL dir
  • -U UUID: specify the device by UUID when mounting;
    mount -U UUID dir
    -o options: additional mount options
  • sync/async: synchronous/asynchronous operation;
  • atime/noatime: Whether to update the access timestamp of a file or directory when it is accessed;
  • diratime/nodiratime: Whether to update the access timestamp when the directory is accessed;
  • remount: remount;
  • acl: support the use of facl function;
  • ro: Free
  • rw: read and write
  • dev/nodev: Whether device files are allowed to be created on this device;
  • exec/noexec: Whether to allow running the program files on this device;
  • auto/noauto: Whether to allow mount -a to achieve automatic mounting
  • user/nouser: Whether to allow ordinary users to mount this file system;
  • suid/nosuid: Whether to allow the suid and sgid special permissions on the program file to take effect;
  • defaults:Use default options: rw, suid, dev, exec, auto, nouser, async, and relatime.
  • _netdev: Mounting of iSCSI and other devices to avoid errors in mounting before network startup.
    umount: Unmount the file system
    umount [-dflnrv] {dir|device}...
    Note: The mount point being accessed by the process cannot be unmounted;
  • Check which process or processes are occupied:
    lsof MOUNT_POINT
    fuser -v MOUNT_POINT
  • Terminate all processes that are accessing a mount point:
    fuser -km MOUNT_POINT
    /etc/fstab: static information of the file system, set the file system to be automatically mounted when booting.
    Each line defines a file system to be mounted and related attributes. A total of 6 fields:
    (1) The device to be mounted: device file, LABEL, UUID, pseudo file system: such as sysfs, proc, tmpfs, etc.
    (2) Mount point: The mount point of the swap type device is swap;
    (3) File system type;
    (4) Mount options: defaults: use default mount options; if you want to specify multiple mount options at the same time, they are separated by things; defaults, acl, noatime, noexec, _netdev
    (5) Dump frequency: 0: never backup; 1: daily backup; 2: every other day backup;
    (6) self-check sequence: 0: no self-check; 1: first self-check, usually only the root file system is available 1 ; 2: Secondary self-check...
    mkswap: create swap partition file system
    mkswap [options] device [size]
    swapon/swapoff: enable/disable swap partition
    swapon [-d] [-f] [-p priority] [- v] specialfile...

    RAID

    RAID technology combines multiple hard disk devices into a disk array with larger capacity and better security, and cuts the data into multiple segments and stores them on different physical hard disk devices, and then uses scattered read and write technology To improve the overall performance of the disk array, and to synchronize multiple copies of important data to different physical hard disk devices at the same time, it has played a very good data redundancy backup effect.
    There are at least a dozen existing RAID disk array schemes. The most common schemes are RAID 0, RAID 1, RAID 5 and RAID 10.

  • RAID 0: fast speed, low cost, low security
  • 8. Disk partitioning, formatting, mounting and RAID
  • RAID 1: unchanged speed, high cost, high security
  • 8. Disk partitioning, formatting, mounting and RAID
  • RAID 5: The speed is slightly improved, the cost is not much, and the security is slightly higher
  • 8. Disk partitioning, formatting, mounting and RAID
  • madam[-Cv] (create array group and display process), [-Q] can view detailed information

[-f]<disk>- Notify the system that the disk is damaged
[-D]-Device information
[-r]-Remove
[-a]-Add the hard disk back to the array

Damaged disk array and repair

  • Use the mdadm command to remove it and check that the status of the RAID disk array group has been changed
    mdadm /dev/md0 -f /dev/sdb The device is damaged
  • Remove the damaged device
    mdadm /dev/md0 -r /dev/sdb
  • View
    mdadm -D /dev/md0
  • After inserting the new hard disk, execute this step
    umount /RAID
    mdadm /dev/md0 -a /dev/sdb
    mdadm -D /dev/md0 and then check it is normal.

    Disk array + hot backup

  • Create a RAID 5 disk array + backup disk. The parameter -n 3 represents the number of hard disks required to create this RAID 5 disk array, the parameter -l 5 represents the RAID level, and the parameter -x 1 represents a backup disk. When viewing the /dev/md0 (namely the name of the RAID 5 disk array) disk array, you can see that there is a backup disk waiting.
    mdadm -Cv /dev/md0 -n 3 -l 5 -x 1 /dev /sdb /dev/sdc /dev/sdd /dev/sde
    can also be written as: /dev/sd[be] The
    deployed RAID 5 disk array is formatted as ext4 file format, and then mounted to the directory, and then you can Used
    mkfs.ext4 /dev/md0
    echo "/dev/md0 /RAID ext4 defaults 0 0" >> /etc/fstab
    mkdir /RAID
    mount -a

    LVM creates a logical layer on the hard disk partition to facilitate the system to manage the hard disk partition system.

    Difference:
    LVM: Flexible management of disk capacity, with certain redundancy and performance functions, but it is very weak.

RAID: Pay more attention to performance and data security.

Comparison of advantages and disadvantages between RAID levels

The commonly used RAID levels in the operation and maintenance production environment are RAID0, RAID1, RAID5, RAID10
8. Disk partitioning, formatting, mounting and RAID
8. Disk partitioning, formatting, mounting and RAID
8. Disk partitioning, formatting, mounting and RAID

Guess you like

Origin blog.51cto.com/14846455/2608874