Basic Linux disk partitioning tutorial
Introduction
Linux disk partitions are divided into physical partitions and logical partitions. physical partitions are directly partitioned on a specified physical disk, which is convenient but weak in expansion; on the contrary, the logic can be combined into a large Logical Disk by multiple physical disks sharing a few pieces of space, and then partitioned. This operation is troublesome but highly scalable. In Linux, everything is a file, and users can access data through partitioning and mounting directories.
Physical Partition
Reduce/home space to 100 GB, add physical partition sda3, expand space to 129 GB, and mount to/ddhome directory
1. View partitions
Df-h
2. Detach a mount Partition
Umount/home
If the message "device is busy" is displayed, this directory is being used by some users.
Lsof/home: Find the process and kill it.
3. Check for errors in vg_ddz-lv_home files
E2fsck-f/dev/mapper/vg_ddz-lv_home
4. Adjust/home to 100 GB
Resize2fs-p/dev/mapper/vg_ddz-lv_home 100G
5. Reduce physical boundaries
Lvreduce-L 100G/dev/mapper/vg_ddz-lv_home
Enter y
6. view the remaining space of "Free PE/Size"
Vgdisplay
7. Add a partition
Fdisk/dev/sda
P
N
P
3
W
8. Effective
Partprobe (or reboot)
9. Extended Space to/dev/sd3
Lvextend-L + 129G/dev/sda3
10. disk formatting
Mkfs-t ext3/dev/sda3
11. Disk Inspection
Fsck-C-f-t ext3/dev/sda3
12. Sector Bad Track Test
Badblocks-sv/dev/sda3
13. Mount directory
Rm-rf/ddhome & mkdir/ddhome
Mount/dev/sda3/ddhome
14. view results
Df-h
Logical Partition
Add a logical volume lv_ddhome, assign a GB space, and mount it to the/ddhome directory.
1. view the process in use/home
Fuser-l/home
Ps-ef | grep xxx
Kill-9 pid
2. Uninstall the Mount directory
Umount/home
3. Check for errors in vg_ddz-lv_home files
E2fsck-f/dev/mapper/vg_ddz-lv_home
4. Adjust/home to 100 GB
Resize2fs-p/dev/mapper/vg_ddz-lv_home 80G
5. Reduce physical boundaries
Lvreduce-L 80G/dev/mapper/vg_ddz-lv_home
Enter y
6. Remount/home
Mount/home
7. view the available space of the volume group vg
Vgs
8. New logical volume
Lvcreate-L 150G-n lv_ddhome vg_ddz
9. format the logical volume
Mke2fs-t ext3/dev/mapper/vg_ddz-lv_ddhome
10. Mount directory
Rm-rf/ddhome & mkdir/ddhome
Mount/dev/mapper/vg_ddz-lv_ddhome/ddhome
11. view results
Df-h
Logical Volume Expansion
Add Disk/dev/sdc, add to logical volume group vg_ddz, and resize to logical partition/dev/mapper/vg_ddz-lv_ddhome
Umount is required for capacity reduction, and resizing is not required
1. display new disk information without restarting
Ls/sys/class/scsi_host/
Echo "---">/sys/class/scsi_host/host0/scan
Echo "---">/sys/class/scsi_host/host1/scan
Echo "---">/sys/class/scsi_host/host2/scan
2. Check whether the new disk is displayed.
Fdisk-l
3. Add the new disk to the volume group.
Vgextend vg_ddz/dev/sdc
4. 500 GB added
Lvextend-L + 500G/dev/mapper/vg_ddz-lv_ddhome
5. Synchronize the File System
Resize2fs/dev/mapper/vg_ddz-lv_ddhome
This article permanently updates link: https://www.bkjia.com/Linux/2018-03/151325.htm