#Basic management of Linux storage

1, Equipment identification

After the equipment is connected to the system, it exists in the form of files

Equipment file name:
SATA/SAS/USB /dev/sda,/dev/sdb 
     #s means SATA or SAS or USB,; d is hard DISK; a represents the first block, b represents the second block
     /dev/sda1 express SATA The first partition of the first hard disk,
     /dev/sdb3 express SATA The third partition of the second hard disk
IDE /dev/hd0,/dev/hd1 
    #h= hard, old hard drive
    /dev/hd0 Indicates the first hard disk;/dev/hd1 Indicates the second hard disk
VIRTIO-BLOCK /dev/vda,/dev/vdb
    #v=virtio, virtual hard disk
M two(SSD) /dev/nvme0,/dev/nvme1 
    #nvme=m2, SSD with M2 interface
SD/MMC/EMMC(card) /dev/mmcblk0,/dev/mmcblk1 
    #mmcblk=mmc card
 CD drive /dev/cdrom,/dev/sr0,/dev/sr1
    #/dev/sr0 represents the first optical drive and / dev/sr1 represents the second optical drive

Device view

fdisk -l ##View disk partition
lsblk ##Equipment usage
blkid ##Device management mode and device ID (you may not see the device being used, and the unused device does not have an id)
df ##View devices being mounted by the system (devices being used by the system)
cat /proc/partitions ##View system identification device


To view the disk partition:


View system identification device:

2, Device mount

Devices with device id in the system can be used by the system

Mount command:
mount -o Mount parameters device Mount point
umount equipment|Mount point
mount ##View mount information
mount -o ro /dev/usb /media ##Mount / dev/usb to / media, read-only mount
mount -o remount,rw /media ##The conversion mount parameter changes from read-only to read-write
mount -o remount,rw /dev/usb  ##The conversion mount parameter changes from read-only to read-write

/dev/loop0 should actually be / mnt/usb
Just because / mnt/usb is a virtual device and a simulated USB drive, it is mapped as a loopback device.


When the device is busy during uninstall:
fuser -kvm equipment|Mount point #-k end process, - v reality details - m display process

"Note: the above equipment mounting is temporary"

Permanent attachment of equipment

vim /etc/fstab ##Device mount policy file
 Device mount point file system type mount parameter backup detection
/dev/usb /media xfs defaults 0 0

/The error in writing the contents of the etc/fstab device mount policy file will cause the system to fail to start
Follow the prompts to enter the super user password in the operation interface
Comment error line
Just restart the system

vim /etc/fstab:



3, Finding files in devices

Experimental materials:

find
  -name
  -user
  -group
  -type f d s b l
  -perm 222 /222 -222
  -exec
  -maxdepth 1-mindepth 1
  -cmin 1 -1 +1
  -size +|-| 1M
  -o
  -a
  -not









4, Partition

Partition mode     Digit partition table size pays for the number of partitions. It supports the size of a single partition and the maximum number of partitions
legacy (MBR) 32   64byte    4 main partitions       2.2TB        16 for all partitions

UEFI (GPT)   64   128byte   Theoretically unlimited     8ZiB        windows 128

MBR partition mode:
Main partition
The main partition table records partition information and can be used directly
Extended partition
The partitions recorded in the primary partition table cannot be used directly. They are just logical partition containers
Logical partition
A partition divided above an extended partition is called a logical partition

MBR partition diagram:

GPT partition diagram:

1. Use of zoning commands

Interactive partition

MBR partition mode:




GPT partition mode:


Non interactive partition mode


2. Method of deploying file system and deleting device

Comparison of common file systems

file system FAT16 FAT32 NTFS EXT3 EXT4 XFS
 Max Volume 2 GB 4GB 256TB 32TB 1EB 16EB
 Maximum single file 4 GB 8TB 16TB 2TB 16TB 8EB
 Maximum number of files 65536 4177920 4294967295 32000 subdirectories unlimited subdirectories
 Representative system DOS/Win95 Win98 Win2000 in the future RHEL5 RHEL6 RHEL7~
man 5 fs






5, swap partition

effect:
When the program is running, all data is in RAM.
When RAM usage exceeds the limit,
In order to make the system more stable,
We divide part of the space on the hard disk for memory buffer swap.
When the memory usage exceeds the limit, the kernel will store the idle data in memory in swap.
When the program needs the data in the swap partition, the kernel returns the data in the swap partition to the memory process for processing.

swap partition size recommendations:

Memory size  swap Recommended partition size when allowed HIBERNATE
2GiB following    Double memory            Memory 3x
2-8GiB     Equal to physical memory       2X physical memory
8-64GiB       4GiB          1.5 Times physical memory
64GiB above     4GiB           HIBERNATE Not open

Function of HIBERNATE: when the system suddenly loses power, store the data in the memory in the swap partition on the hard disk

1. Create swap partition





2. Delete swap partition


6, Disk quota

Function: set the maximum amount that the user can write to the specified device



Permanently open quota

vim /etc/fstab
/dev/vdb1    /westos      xfs    defaults;usrquota  0 0


Accordingly, to close the quota, you need to delete the configuration information in vim /etc/fstab.

Keywords: Linux Operation & Maintenance IDE

Added by T_Hayden on Mon, 21 Feb 2022 09:46:00 +0200