当前位置:网站首页>lvm creates logical volumes
lvm creates logical volumes
2022-08-08 07:33:00 【stars293】
创建物理卷
pvcreat /dev/sd{b,c} //建立物理卷
创建物理卷组
vgcreate vg1 /devsdb /dev/sdc //创建物理卷组vg1
创建逻辑卷
lvcreate -L 10G -n ggg vg1 //在vg0卷组上创建名为ggg,大小为10G的逻辑卷
(-L指定创建的LV大小,-l指定创建的LV的PE数量,-n是LV的名字)The logical volume was created successfully but cannot be used yet,需要建立文件系统
建立文件系统
mkfs.xfs /dev/vg1/ggg //建立文件系统
挂载
mount /dev/vg1/ggg /mnt //It can be used after the installation is successful
创建步骤

1.建立物理卷
[[email protected] ~]# pvcreate /dev/sd{b,c}
// 命令 设备名(物理卷名)
2.建立卷组
![]()
3. 建立逻辑卷

[[email protected] ~]# lvcreate -L 23G -n ky22 vg1
//创建逻辑卷命令 指定逻辑卷大小 创建逻辑卷名 Which volume group to take frompe
4.建立文件系统
mkfs.xfs /dev/vg1/ky22
//建立文件系统 vg1The name of the volume group obtained by yourself ky22 The name of the logical volume taken by yourself

5.挂载
mount /dev/vg1/ky22 /mnt
It can be used after the mount is successful
如何扩容:
xfsExpansion in the system:
情况一:vgenough to expand lvextend -L +3G /dev/vg1/ky22

xfs_growfs /dev/vg1/ky22
情况二:vgNot stretched enough,You have to expand the equipment first and then expand the system
Expand equipment: pvcreate /dev/vdd //创建物理卷/dev/vdd
vgextend vg1 /dev/vdd ##Insert the new physical volumevddAdd to an existing volume groupvg1
扩展逻辑卷
lvextend -L +3G /dev/vg1/ky22
xfs_growfs /dev/vg1/ky22
ext4System expansion
[[email protected] ~]# umount /mnt ##先卸载
[[email protected] ~]# mkfs.ext4 /dev/vg0/lv0 ##格式化逻辑卷 ,And change the system toext4
[[email protected] ~]# mount /dev/vg0/lv0 /mnt/ ##挂载
[[email protected] ~]# lvextend -L 1800M /dev/vg0/lv0 ##Increase logical volume space
Extending logical volume lv0 to 1.76 GiB Logical volume lv0 successfully resized
[[email protected] ~]# resize2fs /dev/vg0/lv0 ##更新逻辑卷信息
缩减逻辑卷空间
[[email protected] ~]# umount /mnt ##先卸载
[[email protected] ~]# e2fsck -f /dev/vg0/lv0 ##Scan for free space on logical volumes
[[email protected] ~]# resize2fs /dev/vg0/lv0 1000M ##Device files are reduced to 1000M
[[email protected] ~]# lvreduce -L 1000M /dev/vg0/lv0 ##将逻辑卷减少到1000M
[[email protected] ~]# mount /dev/vg0/lv0 /mnt ##挂载
缩减vg:(Migrate to an idle device)
[[email protected] ~]# pvmove /dev/vdb1 /dev/vdb2 ##将vdb1The spatial data is transferred tovdb2
/dev/vdb1: Moved: 88.0%
/dev/vdb1: Moved: 100.0% ##Data transfer succeeded
[[email protected] ~]# vgreduce vg0 /dev/vdb1 ##将/dev/vdb1分区从vg0卷组中移除
Removed "/dev/vdb1" from volume group "vg0"
[[email protected] ~]# pvremove /dev/vdb1 ##把/dev/vdb1The partition is removed from the system
Labels on physical volume "/dev/vdb1" successfully wiped
注意:将vdb1The spatial data is transferred tovdb2时,要确保vdb2enough space to be able tovdb1的数据转移,Otherwise, it needs to be set firstvdb1缩减.
磁盘配额
[[email protected] ~]# xfs_quota -x -c 'limit -u bsoft=20M bhard=30M isoft=5 ihard=6 zhangsan' /opt/log/
[[email protected] ~]# chmod 777 /opt/log/
[[email protected] ~]# su zhangsan
[[email protected] log]$ touch file{1..10}.txt
touch: 无法创建"file7.txt": 超出磁盘限额
touch: 无法创建"file8.txt": 超出磁盘限额
touch: 无法创建"file9.txt": 超出磁盘限额
touch: 无法创建"file10.txt": 超出磁盘限额
[[email protected] log]$ ls
file1.txt file2.txt file3.txt file4.txt file5.txt file6.txt
[[email protected] log]$ dd if=/dev/zero of=/opt/log/test.txt bs=1M count=20
记录了20+0 的读入
记录了20+0 的写出
[[email protected] log]$ dd if=/dev/zero of=/opt/log/test1.txt bs=1M count=20
dd: 写入"/opt/log/test1.txt" 出错: 超出磁盘限额
记录了11+0 的读入
记录了10+0 的写出
10485760字节(10 MB)已复制,0.00546079 秒,1.9 GB/秒
[[email protected] log]$ touch file{1..10}.txt
touch: 无法创建"file1.txt": 超出磁盘限额
touch: 无法创建"file2.txt": 超出磁盘限额
touch: 无法创建"file3.txt": 超出磁盘限额
touch: 无法创建"file10.txt": 超出磁盘限额
[[email protected] log]$ ls
test1.txt test.txt
[[email protected] log]$ rm -rf *
[[email protected] log]$ touch file{1..10}.txt
touch: 无法创建"file7.txt": 超出磁盘限额
touch: 无法创建"file8.txt": 超出磁盘限额
touch: 无法创建"file9.txt": 超出磁盘限额
touch: 无法创建"file10.txt": 超出磁盘限额
[[email protected] log]$ ls
file1.txt file2.txt file3.txt file4.txt file5.txt file6.txt
边栏推荐
猜你喜欢
随机推荐
用平衡二叉搜索树解决硬木种类问题
seata内部是使用redisson的分布式锁来实现的吗?
超大Excel文件的写入
在String类型的前提前下:使用“==“ 与equals的区别
idea big data tools 提交flink任务
用栈模拟队列
基于FTP协议的文件上传与下载
HCIA --- VLAN实验报告
Day39------网络相关
论文解读:《PST-PRNA:使用蛋白质表面地形和深度学习对RNA结合位点的预测》
数据链路层------基于TCP/IP五层模型
环形数据缓冲区的实现 --C语言版本
动手学数理统计(1)
FileInputStream & BufferedInputStream之间的区别
教你实现多线程案例定时器
jupyter notebook处理文件导致IOPub data rate exceeded
论文解读:《Mouse4mC-BGRU:用于预测小鼠基因组中DNA N4-甲基胞嘧啶位点的深度学习》
从不同角度分析几种IO类型
【Android安全】手机Root、刷机、救砖常用命令
动手学线性代数









