Server hard disk mount

1. fdisk command

fdisk -l

insert image description here

  • dev/sda: block device name
  • 1000.2 GB: the size of the device
  • dev/sda1: sdaA primary partition of the hard disk

2. Basic concepts

  • PV(Physical Volume)- 物理卷

​ The physical volume is at the bottom of the logical volume management. It can be a partition on the actual physical hard disk, or the entire physical hard disk, or a raid device.

  • VG(Volumne Group)- 卷组

​ Volume groups are built on top of physical volumes. A volume group must include at least one physical volume. After the volume group is established, physical volumes can be dynamically added to the volume group. A logical volume management system project can have only one volume group or multiple volume groups.

  • LV(Logical Volume)- 逻辑卷

​ Logical volumes are built on top of volume groups, and the unallocated space in the volume group can be used to create new logical volumes. After the logical volumes are created, the space can be dynamically expanded and reduced. Multiple logical volumes in the system can belong to the same volume group or to different volume groups.

3. Mount multiple hard disks to the same directory

3.1 Create a physical volume

# 新建物理卷
pvcreate /dev/nvme0n1 /dev/sdb
# 查看现有物理卷信息
pvdisplay

3.2 Create a new volume group

# 新建物理卷
vgcreate work_vg /dev/nvme0n1 /dev/sdb
# 查看现有物理卷信息
pvdisplay
# 扩展卷组
vgextend vg_name /dev/sdc

3.3 Create a new logical volume

# 新建逻辑卷
lvcreate -n work_lv -l 100%FREE work_vg
# 查看磁盘分区
fdisk -l

3.4 Format partition ext4

mkfs.ext4 /dev/mapper/work_vg-work_lv

3.5 Mount to directory

mount /dev/mapper/work_vg-work_lv /media/lo/work
# 查看
df -h

3.6 Automatic mount

/etc/fstabAdd mount information at the end to realize automatic mount:

# /media/lo/work is on /dev/mapper/work_vg-work_lv 
# This is a Logical Volume containing two SSD
# SanDisk SSD 480GB and Samsung SSD 500GB
# Physical Volume: /dev/nvme0n1 and /dev/sdb are created
# Volume Group work_vg is created
# Logical Volume work_lv is created
/dev/mapper/work_vg-work_lv /media/lo/work ext4 defaults 0 0

3.7 Change the user of the mount point

sudo chown -R lo:lo /media/lo/work

Guess you like

Origin blog.csdn.net/cacique111/article/details/128043943
Recommended