A. View disk devices
/proc/partitions
Question 1: how to add a new hard disk
virt-manager
Question 2: how to find files in the file system
find /mnt/ -name "*westos*" find /mnt/ -name westosfile1
Question 3: set the depth to find the file
find /mnt -maxdepth 1 -name westosfile1 #The depth of the lookup file is 1 layer find /mnt -mindepth 2 -maxdepth 2 -name westosfile1 #Find only the second layer
find -name -user -group -type f a s b l -perm 222 /222 -222 -exec -maxdepth 1 -mindepth 2 -cmin 1 -1 +1 #time -size +| -| 1M -o #perhaps -a #also -not #no
find /mnt -user jin -o -user westos #User jin or user westos find /mnt -user jin -a -group jin #If the user is jin and the group is jin -a, you can not write find /mnt -user jin -not -group jin #The user is a jin group, not a jin group
Question 4: how to make a file of a specified size
dd if=/dev/zero of=/mnt/westosfile1 bs=1M count=10 #if inputfile ; of outputfile ; bs blocksize ; count quantity du -sh westosfile1 du -sh westosfile{1..3} #View file size
Question 5: find files of the specified size
find /mnt -size 20M #Find files of size 20M find /mnt -size -20M #Find files smaller than 20M find /mnt -size +20M #Find files larger than 20M
Question 6: find files modified at a specified time
This function is used to quickly find the modified files when the system has problems
find /mnt -cmin 1 #Find files modified in one minute find /mnt -cmin -1 #Find files that have been modified in one minute find /mnt -cmin +1 #Find files that have been modified for more than a minute
Question 7: find files with specified permissions
ls -l #Permissions to find sub files in the current directory find /mnt -perm 444 #Find files with r bits find /mnt -perm -444 #Find the file containing r in ugo bit - indicates that the permissions must be met find /mnt -perm /444 #Find the file with r in u or g or o / 755. There are several conditions for a few letters
Question 8: processing files found by the find command
find /mnt -perm -002 -exec o-w {} \; # {} represents all the files found by the find command; It means to separate the front from the back when the command is executed, but in this command; It has its own special meaning. Only one or "" can be escaped if the \ escape character is used
Question 9: viewing of devices
Condition of equipment
(1) The equipment is real, but the system does not recognize it
(2) The equipment is identified by the system but not utilized
(3) The equipment is identified by the system and used
View device information
fdisk -l #It's hard to say whether the system can recognize the real equipment
View devices in the system
lsblk #Equipment usage #System identification available or cat /proc/partitions #System identification available
View devices used by the system
df #Equipment utilized by the system df -h #The display unit is n azimuth units of 2 df -H #In n azimuth units of 10 blkid #Equipment management mode and equipment id #System identification available
Question 10: device mount
umount equipment #uninstall mount Device mount point mount #Find mount information
Question 11: setting up a read-only mount
mount -o ro /dev/sdb1 /mnt/ #ro read-only
Question 12: when some devices are mounted read-only, how can they be changed to read-write state when mounted
mount -o remount,rw /dev/sdb1 #If a new file cannot be created, uninstall the device first and then mount it again umount /dev/sdb1 mount -o rw /dev/sdb1 /mnt/
Question 13: when / mnt / is occupied by another shell of the system, / mnt cannot be unloaded.
lsof /dev/sdb1 #View busy information on the device fuser -kvm /dev/sdb1 #That is, you can end the viewing command
When the at crontab is executed, it has output and will be sent to the initiator of the task by mail.
dnf install postfix mailx -y systemctl enable --now postfix mail
B disk partition
legacy (MBR) 32 64byte 4 primary partitions 2.2TB 16 all partitions
UEFI (GPT) 64 128byte theoretically unlimited 8ZiB windows 128
MBR partition mode:
Primary 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
Advantages of logical partitioning: it does not occupy the partition table
Disadvantages: when the extended partition is hung, all the logical partitions are broken
Partition command: fdisk interactive parted non interactive
Question 14: set non interactive partition mode
parted /dev/vdb mklabel gpt #Set the partition mode of / dev/vdb to gpt parted /dev/vdb mklabel msdos #Set the partition mode of / dev/vdb to MBR parted /dev/vdb mkpart primary 1 1000 parted /dev/vdb rm 2 #2 means the second
Question 15: setting the interaction mode
fdisk /dev/vdb #Enter the interactive interface
Question 16: how to synchronize the partition table on the device with the partition table on the kernel
fdisk /dev/vdb #Enter the interactive interface udevadm settle cat /proc/partitions #At this time, the partition cannot be used. Only several devices are divided, but there is no file system on the device. File management software is called file system
C file system
File system FAT16 FAT32 NTFS EXT3 EXT4 XFS
Maximum volume 2GB 4GB 256TB 32TB 1EB 16EB # supported single device size
Maximum single file 4GB 8TB 16TB 2TB 16TB 8EB
Maximum number of files 65536 4177920 4294967295 32000 subdirectories unlimited subdirectories unlimited subdirectories
On behalf of the system DOS/Win95 Win98 Win2000 later RHEL5 RHEL6 RHEL7~
To make the system support NTFS system, install an NTFS plug-in, NTFS-3G
rpm -ivh link
mkfs.xfs /dev/vdb1 mkfs.vfat /dev/vdb2 #format mkfs.xfs -K /dev/vdb5 #K means that there is no data cleaning process without processing empty data blocks. It is suitable for formatting a new and large disk
Question 17: achieve permanent mount
The mount command can be written to / etc / RC d/rc. Local, but the contents of this file will be executed in the last step only after the system is started.
Disk mount policy file
vim /etc/fstab #When this document does not take effect immediately mount -a #Let the devices in etc be mounted immediately
Question 18: how to delete a mounted device
First delete the line just written in / etc/fstab, and then
umount /mnt fdisk /dev/vdb p d 1
Question 19: how to quickly clean up the entire disk
Destroy partition table
dd if=/dev/zero of=/dev/vdb bs=1M count=1
Dswap partition: acts as a repository of memory
The reading and writing speed of hard disk is slow
/dev/shm memory
/mnt hard disk
When the memory is full, the CPU stops running
swap is an important part of computer optimization. It can prevent the computer from crashing
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 swap partition, the kernel will return the data in swap partition to the memory process for processing
When HIBERNATEX is powered off, it will store the data in the memory in the hard disk. When it is powered on, it will be loaded from the hard disk again.
swap partition size recommendations
Memory size swap partition recommended size when HIBERNATE is allowed
Twice the memory below 2GiB and 3x the memory
2-8GiB is equal to twice the physical memory
8-64gib 4gib 1.5x physical memory
4GiB HIBERNATE above 64GiB is not on
Question 19: swap partition
swapon -s #View swap partition fdisk /dev/vdb #Enter the interface n p t l#type 82#Select swap partition wq udevadm settle #In this way, swap is divided mkswap /dev/vdb1 #Format swap blkid swapon -a /dev/vdb1 #Activate swap partition swapoff /dev/vdb1 #Switch swap from active state to stopped state swapon -a /dev/vdb1 -p 1 #Change priority to 1 fdisk /dev/vdb d p
E disk quota
Question 20: there are restrictions on asking someone to write into the device
Step 1: activate the restricted functions on this device
umount /westos mount -o usrquota /dev/vdb1 /westos/ #Activate quota parameters mount edquota -u westos #Quota pin for device
Change only at the first hard, 20480
Start at startup
vim /etc/fstab #write in /dev/vdb1 /westos xfs default,usrquota 0 0
I don't want it anymore
The first method: delete the data written in / etc/fstab
quotaoff -uv /dev/vdb1 #v display process u user
The second method: uninstall directly and mount again
umount /westos mount /dev/vdb1 /westos/ mount