当前位置:网站首页>Disk space, logical volume
Disk space, logical volume
2022-06-30 07:30:00 【My deep blue】
Linux Disks in
disk
- MBR-Main Boot Record ( Master boot record ) : Tell the hard disk how to
Partition , Write it in the... Of the disk - In one sector .
characteristic :
- The primary partition has at least 1 individual , most 4 individual ,
- The extended partition may not have , most 1 individual . And the main partition + The total number of extended partitions cannot exceed 4 individual .
- Logical partitions can have several .
- The maximum partition and disk size allowed is 2T
- View available memory and virtual memory space
free -m
- Look at the size of a directory or file
du
Parameters
-a: Display the disk usage of each sub file . By default, only the disk usage of subdirectories is counted
-h: Use custom units to display disk usage , Such as KB,MB or GB etc.
-s: Count the total consumption , The usage of subdirectories and sub files is not listed
- View the details of the current normal disk
df
Parameters
-ht: Use custom units to display capacity , Such as KB,MB or GB Etc. to display the file system type
-a: Show all file system information , Including special file systems , Such as /proc、 /sysfs
-m: With MB Show capacity in units
-K: With KB Show capacity in units . Default is to KB In units of
/dev/mapper/cl -root : The root directory is stored , Logic volume
/dev/sda1: yes sda The first partition of the disk , Put the startup file
tmpfs: Disk driver
- df and du The difference between
- df Commands are considered from the file system , It's not just about the space the file takes up , Also count the space occupied by commands or programs ( The most common is that the file has been deleted , But the program doesn't release space )
- du The command is file oriented , Only the space occupied by a file or directory is calculated
Swap space swap
Swap space = Virtual memory .
- Store inactive information in memory
- When memory is full , Use
- If the virtual memory is full , that Linux It's going to be very stuck , Even collapse
- How much virtual space should we divide
Physical memory | Swap partition (SWAP) |
---|---|
<=4G | At least 4G |
4G~16G | At least 8G |
16G~64G | At least 16G |
64G~256G | At least 32G |
Disk partition
Disk partition : Divide the hard disk into logical storage units .
Logical storage unit : Partition
The benefits of partitioning :
1、 Limit the available space for applications or users
2、 Allow the same - The hard disk is installed with different operating systems
3、 You can give virtual memory a separate partition
4、 Improve the performance of hard disk
step 1、 Partition
fdisk /dev/sdb
// Yes sdb Partition the disk ,
// Prompt partition operation
n: New normal partition
T: Change partition ,82 yes swap
w: Save the created partition and exit
d: Delete partition
p: see
Partition changes will stay in memory , If you need to write to disk , You need to save the operation
step 2、 Reread the new partition table
partprobe /dev/sdb
step 3、 Create file system
Create file system = format
linux A lot of support file system ,ext4 and xfs
windows Support ,NTFS、FAT32
- format Normal partition
mkfs.ext4 /dev/sdb1
// Format partition sdb1 Not disk sdb
- format Virtual partition
mkswap /dev/sdb2
step 4、 mount
Mount the file system 、 Connect to the directory structure
Hook the directory to a disk
- Create mount point
mkdir /mnt/mkd
// Create mount point
- Manual mount
The system will fail after restart . Used to detect formatted devices
mount /dev/sdb1 /mnt/mkd/
// take Catalog and file system mount
- Permanently mount
You are about to add the device to /etc/fstab In the
vim /etc/fstab
First step :
- The equipment to be used can be used UUID,
- You can also use device files blkid Check the... Of the device UUID Number ,
The second part :
- Write the mount point , Direct write already exists , There is no use mkdir To create
The third part
- File system type (ext4、xfs)
The fourth part
- When mounting , Custom options applied to the device ,defaults yes necessary
The fifth part
- Redeposit flag
Redeposit flag : Used to generate a backup of device content ,
0: Indicates that backup is not required
1: Indicates the need for backup
The sixth part
- fsck The order
fsck: When there are multiple file systems to check , The order of inspection .
0 Indicates no need to check , Boot and mount directly
1 Indicates the first mount after the check
2 Indicates the second mount after the check
- Common partition mount results
/dev/sdb1 /mnt/mkd ext4 defaults 0 0
- Virtual partition mount results
/dev/sdb2 swap swap defaults 0 0
Virtual partition , You don't need a mount point
Save exit written /etc/fstab Use mount -a Command to check whether the writing format is correct .
If the document is incorrectly written ,Linux You will not be able to power on
step 5、 Activate zone space
Normal partitions do not need to be activated
The virtual partition needs to be activated
swapon View the activated virtual partitions
swapon /dev/sdb2 Activate virtual partition
Logic volume
Physical volume (PV) : Used to register basic physical devices , Mapping to physical devices
The volume group (VG): Storage pool , Consists of one or more physical volumes
Logic volume (LV): Allocate the free physical space according to the volume lease
Logical volume and logical partition are not the same concept
The role of logical volumes :
- If the normal partition is full , We can import the data to a larger disk , Very heavy workload , And very dangerous .
- Logical volume manager (LVM) You can manage disk space more easily , To solve a problem easily .
- lvm Better than traditional hard disk storage
1、 Flexibility capacity - Allow multiple disks or partitions to be made into a logical volume
2、 Scalable storage pool one - You can modify logical volumes with commands , Without formatting
3、 Online data can be moved online after distribution , Hot swappable disks can be exchanged with
4、 Equipment naming is convenient
5、 The mirrored volume is very convenient for data mirroring
6、 Volume snapshot a snapshot saves all the contents of the logical volume
- View command
- View physical volume information
pvdisplay /dev/sdc1
- View volume group information
vgdisplay lewis1
- View logical volume information
Ivdisplay /dev/lewis1/lewis2
Create logical volumes
step 1、 Create partitions
fdisk /dev/sdc
T: Change to logical partition ,8e yes Linux LVM
step 2、 Reread the new partition table
partprobe /dev/sdc
step 3、 Create a physical volume
pvcreate /dev/sdc1
step 4、 Create a volume group
vgcreate lewis1 /dev/sdb1
// Volume groups are also called storage pools
// Create the name of the volume group lewis1
// hold /dev/sdc1 Of capacity into The volume group lewis1
step 5、 Create logical volumes
lvcreate -n lewis2 -L 1G lewis1
// establish lewis2 The logical volume The size is 1G Size source volume group Lewis1
step 6、 Create file system
mkfs.ext4 /dev/lewis
step 7、 Create permanent mount
- Create mount point
mkdir /mnt/mkd2
// Create mount point
/dev/lewis1/lewis2 /mnt/mkd2 ext4 defaults 0 0
- Check
mount -a
Delete logical volume
Cancel the mount
umount /dev/lewis1/lewis2
At the same time, delete /etc/fstable Contents of the fileRemove logical volumes
lvremove /dev/lewis1/lewis2
- Remove volume group
vgremove lewis1
- Delete physical volume
pvremove /dev/sdc1
pvremove /dev/sdc2
Logical volume expansion
- Yes ETX4 File system logical volume expansion
- If the volume group still has space , Increase the size of the logical volume directly
increase 20M
lvextend -L +20M /dev/lewis1/lewis2
Effective operation
resize2fs /dev/lewis1/lewis2
- If the volume group does not have enough space , You need to increase the volume group space first ,
fdisk /dev/sdc
partprobe /dev/sdc
pvcreate /dev/sdc2
vgextend lewis1 /dev/sdc2 // Add capacity to the original volume group
- Yes xfs File system logical volume expansion
The operation takes effect differently
xfs_growfs /dev/lewis1/lewis2
边栏推荐
- Video player (II): video decoding
- DXP software uses shortcut keys
- STM32 control LED lamp
- 网络安全-抓包和IP包头分析
- 手机开户股票开户安全吗?开户需要准备什么?
- DS1302 digital tube clock
- Implementation of double linked list in C language
- How to determine the size of the platform byte order?
- How to quickly delete routing in Ad
- Video player (I): process
猜你喜欢
[most complete] install MySQL on a Linux server
Final review -php learning notes 9-php session control
Minecraft 1.16.5模组开发(五十) 书籍词典 (Guide Book)
Raspberry pie 4B Getting Started Guide
TC397 QSPI(CPU)
Local unloading traffic of 5g application
Use of ecostruxure (3) creating composite function blocks
Can introduction
What if I don't know what to do after graduating from university?
Parameter calculation of deep learning convolution neural network
随机推荐
[resolved] MySQL exception: error 1045 (28000): unknown error 1045, forgetting the initial password
手机开户股票开户安全吗?开户需要准备什么?
Calculation and parameter quantity of neural network
Thread network
将本地电脑文件复制到虚拟机系统中详细方法
C language implementation of chain stack (without leading node)
ADC basic concepts
Application of stack -- using stack to realize bracket matching (C language implementation)
STM32 infrared communication 2
[implemented] server jar package startup script and shell script
Introduction to go project directory structure
The class imported by idea import clearly exists, but it is red?
28 rounds of interviews with 10 companies in two and a half years
Can introduction
Resolution: div failed to get keyboard event
Resolved: initialize specified but the data directory has files in it Aborting
实验一、综合实验【Process on】
STM32 register
期末複習-PHP學習筆記6-字符串處理
Matter protocol