云盘构建LVM并挂载
- 查看当前磁盘使用情况
当前有一块/dev/vdb是未使用的磁盘
- 生成一个物理卷
[yingjian@iZwz9b8x8l2oe511fss4qfZ data]$ sudo pvcreate /dev/vdb
Physical volume "/dev/vdb" successfully created.
查看pv物理卷详细信息
- 生成一个卷组
[yingjian@iZwz9b8x8l2oe511fss4qfZ data]$ sudo vgcreate elk_vg /dev/vdb
Volume group "elk_vg" successfully created
查看卷组详细信息
- 生成一个逻辑卷
[yingjian@iZwz9b8x8l2oe511fss4qfZ data]$ sudo lvcreate -l 25599 -n lv_elk elk_vg
Logical volume "lv_elk" created.
- 创建文件系统
[yingjian@iZwz9b8x8l2oe511fss4qfZ data]$ sudo mkfs.xfs /dev/elk_vg/lv_elk
meta-data=/dev/elk_vg/lv_elk isize=512 agcount=4, agsize=6553344 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=26213376, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=12799, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
- 迁移挂载目录数据并挂载
sudo mkdir /databackup
sudo cp -ar /data/* /databackup
sudo mount /dev/elk_vg/lv_elk /data
[yingjian@iZwz9b8x8l2oe511fss4qfZ data]$ df -Th
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 16G 0 16G 0% /dev
tmpfs tmpfs 16G 0 16G 0% /dev/shm
tmpfs tmpfs 16G 1.1M 16G 1% /run
tmpfs tmpfs 16G 0 16G 0% /sys/fs/cgroup
/dev/vda1 ext4 99G 6.5G 88G 7% /
tmpfs tmpfs 3.1G 0 3.1G 0% /run/user/0
tmpfs tmpfs 3.1G 0 3.1G 0% /run/user/1000
/dev/mapper/elk_vg-lv_elk xfs 100G 33M 100G 1% /data
sudo cp -ar /databackup/* /data
- 永久挂载
[yingjian@iZwz9b8x8l2oe511fss4qfZ data]$ sudo tail -n 1 /etc/fstab
/dev/elk_vg/lv_elk /data xfs defaults 0 0
本文参考:https://blog.csdn.net/yunqiinsight/article/details/91364007
新加云盘并扩展LVM
|