每天学五分钟 Liunx 101 | 存储篇:LVM
LVM
[root@test:/home/robot/test]
# dd if=/dev/zero of=/home/robot/test/lvm1 bs=1M count=512
512+0 records in
512+0 records out
536870912 bytes (537 MB, 512 MiB) copied, 0.474638 s, 1.1 GB/s
[root@test:/home/robot/test]
# dd if=/dev/zero of=/home/robot/test/lvm2 bs=1M count=512
512+0 records in
512+0 records out
536870912 bytes (537 MB, 512 MiB) copied, 0.49283 s, 1.1 GB/s
[root@test:/home/robot/test]
# dd if=/dev/zero of=/home/robot/test/lvm3 bs=1M count=512
512+0 records in
512+0 records out
536870912 bytes (537 MB, 512 MiB) copied, 0.48691 s, 1.1 GB/s
[root@test:/home/robot/test]
#
[root@test:/home/robot/test]
# losetup /dev/loop1 /home/robot/test/lvm1
[root@test:/home/robot/test]
# losetup /dev/loop2 /home/robot/test/lvm2
[root@test:/home/robot/test]
# losetup /dev/loop3 /home/robot/test/lvm3
[root@test:/home/robot/test]
# ll
total 1572876
-rw-r--r-- 1 root root 536870912 Mar 16 12:28 lvm1
-rw-r--r-- 1 root root 536870912 Mar 16 12:28 lvm2
-rw-r--r-- 1 root root 536870912 Mar 16 12:28 lvm3
[root@test:/home/robot/test]
# pvdisplay
[root@test:/home/robot/test]
# pvcreate /dev/loop1
Physical volume "/dev/loop1" successfully created.
[root@test:/home/robot/test]
# pvcreate /dev/loop2
Physical volume "/dev/loop2" successfully created.
[root@test:/home/robot/test]
# pvcreate /dev/loop3
Physical volume "/dev/loop3" successfully created.
[root@test:/home/robot/test]
# pvdisplay
"/dev/loop3" is a new physical volume of "512.00 MiB"
--- NEW Physical volume ---
PV Name /dev/loop3
VG Name
PV Size 512.00 MiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID PpWfyJ-1lSY-iNZY-MU0K-wQfz-zrh0-n9YnCF "/dev/loop1" is a new physical volume of "512.00 MiB"
--- NEW Physical volume ---
PV Name /dev/loop1
VG Name
PV Size 512.00 MiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID 9cUDS8-9VGN-cvnS-8tCF-prIy-eRYS-Y83es9 "/dev/loop2" is a new physical volume of "512.00 MiB"
--- NEW Physical volume ---
PV Name /dev/loop2
VG Name
PV Size 512.00 MiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID fi632i-W46C-dvfw-9YCt-Z08g-rUZB-Hmakox
[root@test:/home/robot/test]
# vgdisplay
[root@test:/home/robot/test]
# vgcreate -s 4M lianhuasheng /dev/loop{1,2,3}
Volume group "lianhuasheng" successfully created
[root@test:/home/robot/test]
# vgdisplay
--- Volume group ---
VG Name lianhuasheng
System ID
Format lvm2
Metadata Areas 3
Metadata Sequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 3
Act PV 3
VG Size <1.49 GiB
PE Size 4.00 MiB
Total PE 381
Alloc PE / Size 0 / 0
Free PE / Size 381 / <1.49 GiB
VG UUID Y4l3Ad-bdIJ-7V5A-3FI1-kR74-QwDg-DbRdJ0
[root@test:/home/robot/test]
# lvcreate -l 50 -n lv1 lianhuasheng
Logical volume "lv1" created.
[root@test:/home/robot/test]
# lvdisplay
--- Logical volume ---
LV Path /dev/lianhuasheng/lv1
LV Name lv1
VG Name lianhuasheng
LV UUID jQU1SV-tIzt-SRet-L5XK-rk1K-YC3h-o7YT7Q
LV Write Access read/write
LV Creation host, time test, 2020-03-16 22:27:14 +0800
LV Status available
# open 0
LV Size 200.00 MiB
Current LE 50
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 252:8
[root@test:/home/robot/test]
# mkfs -t ext4 /dev/lianhuasheng/lv1
mke2fs 1.45.5 (07-Jan-2020)
Discarding device blocks: done
Creating filesystem with 204800 1k blocks and 51200 inodes
Filesystem UUID: 39a25411-b81c-42c0-b1d4-cb7dd1119e87
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729 Allocating group tables: done
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done [root@test:/home/robot/test]
# ls
lvm1 lvm2 lvm3
[root@test:/home/robot/test]
# mkdir mountPoint
[root@test:/home/robot/test]
# mount /dev/lianhuasheng/lv1 /home/robot/test/mountPoint/
[root@test:/home/robot/test]
# df -hT
Filesystem Type Size Used Avail Use% Mounted on
/dev/vda1 ext4 40G 8.9G 29G 24% /
/dev/mapper/lianhuasheng-lv1 ext4 190M 1.6M 175M 1% /home/robot/test/mountPoint
[root@test:/home/robot/test/mountPoint]
# lvdisplay
--- Logical volume ---
LV Path /dev/lianhuasheng/lv1
LV Name lv1
VG Name lianhuasheng
LV UUID jQU1SV-tIzt-SRet-L5XK-rk1K-YC3h-o7YT7Q
LV Write Access read/write
LV Creation host, time test, 2020-03-16 22:27:14 +0800
LV Status available
# open 1
LV Size 200.00 MiB
Current LE 50
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 252:8
[root@test:/home/robot/test/mountPoint]
# df -hT
Filesystem Type Size Used Avail Use% Mounted on
/dev/vda1 ext4 40G 8.9G 29G 24% /
/dev/mapper/lianhuasheng-lv1 ext4 190M 1.6M 175M 1% /home/robot/test/mountPoint
[root@test:/home/robot/test/mountPoint]
# touch test.log
[root@test:/home/robot/test/mountPoint]
# ll -hi
total 12K
11 drwx------ 2 root root 12K Mar 16 22:31 lost+found
12 -rw-r--r-- 1 root root 0 Mar 16 22:43 test.log [root@test:/home/robot/test/mountPoint]
# lvresize -l +50 /dev/lianhuasheng/lv1 [root@test:/home/robot/test/mountPoint]
# lvdisplay
--- Logical volume ---
LV Path /dev/lianhuasheng/lv1
LV Name lv1
VG Name lianhuasheng
LV UUID jQU1SV-tIzt-SRet-L5XK-rk1K-YC3h-o7YT7Q
LV Write Access read/write
LV Creation host, time test, 2020-03-16 22:27:14 +0800
LV Status available
# open 1
LV Size 400.00 MiB
Current LE 100
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 252:8
[root@test:/home/robot/test/mountPoint]
# df -hT
Filesystem Type Size Used Avail Use% Mounted on
/dev/vda1 ext4 40G 8.9G 29G 24% /
/dev/mapper/lianhuasheng-lv1 ext4 190M 1.6M 175M 1% /home/robot/test/mountPoint
[root@test:/home/robot/test/mountPoint]
# resize2fs /dev/mapper/lianhuasheng-lv1
resize2fs 1.45.5 (07-Jan-2020)
Filesystem at /dev/mapper/lianhuasheng-lv1 is mounted on /home/robot/test/mountPoint; on-line resizing required
old_desc_blocks = 2, new_desc_blocks = 4
The filesystem on /dev/mapper/lianhuasheng-lv1 is now 409600 (1k) blocks long. [root@test:/home/robot/test/mountPoint]
# df -hT
Filesystem Type Size Used Avail Use% Mounted on
/dev/vda1 ext4 40G 8.9G 29G 24% /
/dev/mapper/lianhuasheng-lv1 ext4 384M 2.3M 360M 1% /home/robot/test/mountPoint
[root@test:/home/robot/test/mountPoint]
# ll -hi
total 12K
11 drwx------ 2 root root 12K Mar 16 22:31 lost+found
12 -rw-r--r-- 1 root root 0 Mar 16 22:43 test.log
卸载 LVM
[root@test:/home/robot/test/mountPoint]
# df -hT
Filesystem Type Size Used Avail Use% Mounted on
/dev/vda1 ext4 40G 8.9G 29G 24% /
/dev/mapper/lianhuasheng-lv1 ext4 384M 2.3M 360M 1% /home/robot/test/mountPoint
[root@test:/home/robot/test/mountPoint]
# cd ..
[root@test:/home/robot/test]
# umount /home/robot/test/mountPoint/
[root@test:/home/robot/test]
# lvremove /dev/lianhuasheng/lv1
Do you really want to remove active logical volume lianhuasheng/lv1? [y/n]: y
Logical volume "lv1" successfully removed
[root@test:/home/robot/test]
# vgremove lianhuasheng
Volume group "lianhuasheng" successfully removed
[root@test:/home/robot/test]
# pvremove /dev/loop{1,2,3}
Labels on physical volume "/dev/loop1" successfully wiped.
Labels on physical volume "/dev/loop2" successfully wiped.
Labels on physical volume "/dev/loop3" successfully wiped.
[root@test:/home/robot/test]
# ll -hi
total 1.4G
656227 -rw-r--r-- 1 root root 512M Mar 16 22:58 lvm1
656229 -rw-r--r-- 1 root root 512M Mar 16 22:58 lvm2
656230 -rw-r--r-- 1 root root 512M Mar 16 22:58 lvm3
[root@test:/home/robot/test]
# rm -rf lvm{1,2,3}
[root@test:/home/robot/test]
# ll -hi
LVM 命令
pvcreate 创建实体 partition 为 PV
pvscan 搜寻系统磁盘是否有 PV
pvdisplay 显示 PV 状态
pvremove 移除 PV 移除,partition 不具有 PV 属性
vgcreate 创建 VG
vgscan 搜寻系统是否有 VG
vgdisplay 显示 VG 状态
vgextend 在 VG 内添加额外的 PV
vgreduce 在 VG 内移除 PV
vgchange 配置 VG 是否启动 (active)
vgremove 移除 VG
lvcreate 创建 LV
lvscan 查询系统是否有 LV
lvdisplay 显示 LV 状态
lvextend 扩展 LV 容量
lvreduce 缩小 LV 容量
lvremove 删除 LV
lvresize 调整 LV 容量大小
每天学五分钟 Liunx 101 | 存储篇:LVM的更多相关文章
- 如何从40亿整数中找到不存在的一个 webservice Asp.Net Core 轻松学-10分钟使用EFCore连接MSSQL数据库 WPF实战案例-打印 RabbitMQ与.net core(五) topic类型 与 headers类型 的Exchange
如何从40亿整数中找到不存在的一个 前言 给定一个最多包含40亿个随机排列的32位的顺序整数的顺序文件,找出一个不在文件中的32位整数.(在文件中至少确实一个这样的数-为什么?).在具有足够内存的情况 ...
- 五分钟学Java:如何才能学好Java Web里这么多的技术
原创声明 本文作者:黄小斜 转载请务必在文章开头注明出处和作者. 系列文章介绍 本文是<五分钟学Java>系列文章的一篇 本系列文章主要围绕Java程序员必须掌握的核心技能,结合我个人三年 ...
- 零元学Expression Blend 4 - Chapter 42 五分钟快速完成扇形变圆形动画
原文:零元学Expression Blend 4 - Chapter 42 五分钟快速完成扇形变圆形动画 零元学Expression Blend 4 - Chapter 42 五分钟快速完成扇形变圆形 ...
- 《sed的流艺术之一》-linux命令五分钟系列之二十一
本原创文章属于<Linux大棚>博客,博客地址为http://roclinux.cn.文章作者为rocrocket. 为了防止某些网站的恶性转载,特在每篇文章前加入此信息,还望读者体谅. ...
- 五分钟搭建一个基于BERT的NER模型
BERT 简介 BERT是2018年google 提出来的预训练的语言模型,并且它打破很多NLP领域的任务记录,其提出在nlp的领域具有重要意义.预训练的(pre-train)的语言模型通过无监督的学 ...
- GC算法精解(五分钟让你彻底明白标记/清除算法)
GC算法精解(五分钟让你彻底明白标记/清除算法) 相信不少猿友看到标题就认为LZ是标题党了,不过既然您已经被LZ忽悠进来了,那就好好的享受一顿算法大餐吧.不过LZ丑话说前面哦,这篇文章应该能让各位彻底 ...
- zookeeper-架构设计与角色分工-《每日五分钟搞定大数据》
本篇文章阅读时间5分钟左右 点击看<每日五分钟搞定大数据>完整思维导图 zookeeper作为一个分布式协调系统,很多组件都会依赖它,那么此时它的可用性就非常重要了,那么保证可用性的同 ...
- 「每日五分钟,玩转JVM」:线程共享区
前言 上一篇中,我们了解了JVM中的线程独占区,这节课我们就来了解一下JVM中的线程共享区,JVM中的线程共享区是跟随JVM启动时一起创建的,包括堆(Heap)和方法区()两部分,而线程独占区的程序计 ...
- Python专题——五分钟带你了解map、reduce和filter
本文始发于个人公众号:TechFlow,原创不易,求个关注 今天是Python专题第6篇文章,给大家介绍的是Python当中三个非常神奇的方法:map.reduce和filter. 不知道大家看到ma ...
- 一门能让你五分钟学会的语言-Brainfuck
看到标题,不出意外的话,你肯定开始骂我了:**标题党,什么编程语言五分钟就能学会? 其实我本来也是不相信的,但是学过了才知道这是真的. 1.Brainfuck 看到这个小标题,不要误会,我没有骂人. ...
随机推荐
- Transformer在量化投资的应用
导语 RNN.LSTM和GRU网络已在序列模型.语言模型.机器翻译等应用中取得不错的效果.循环结构(recurrent)的语言模型和编码器-解码器体系结构取得了不错的进展. 但是,RNN固有的顺序属性 ...
- bash shell笔记整理——head命令
作用 我直接搬运官方英文了,这英文真的简单直白了,我英语辣鸡...毕竟我学历不行,觉得翻译不好就直接自己来吧.. Print the first 10 lines of each FILE to st ...
- Alpha-Beta剪枝的原理的深入理解(无图预警)
转载请注明 原文链接 :https://www.cnblogs.com/Multya/p/17929261.html 考虑一个树: 一棵树上只有叶子节点有值,有确定的根节点的位置 根据层数来划分叶子节 ...
- selenium之鼠标键盘操作
鼠标操作 1.引入ActionChains类 2.定位相关元素 3.在ActionChains().调用相关鼠标操作方法 from selenium.webdriver.common.action_c ...
- 2023年最后一个工作日,当 hr总监找上我协商赔偿
今天是2023年最后一个工作日,hr 总监找上我协商赔偿一事,忆往昔三年前,公司刚融资1个亿,意气风发,博主入职即为公司巅峰,高级开发岗,14薪,各种福利,加班另算加班费,业务主要服务于众多500强集 ...
- Java:字符串(String)类型转成整型(int)的方法
Java:字符串(String)类型转成整型(int)的方法 使用 Integer.parseInt() 或 Integer.valueOf() 将 String 转换为 int. 其中: Integ ...
- Python趣味入门12:初遇类与实例
小牛叔用轻松有趣的故事,带你进入Python的编程世界. 1.类 一提到类大神们就经常说封装.说白了,封装即把围绕同一个对象相同的代码.数据整合在一起.比如在某段游戏代码中(比如熊猫厨房),有一个&q ...
- Python——第五章:模块(Module)、自定义模块、第3方开源模块、包(Package)
什么是模块(Module)? 在计算机程序的开发过程中,随着程序代码越写越多,在一个文件里代码就会越来越长,越来越不容易维护. 为了编写可维护的代码,我们把很多代码按功能分组,分别放到不同的文件里,这 ...
- 年底了,网站被挂马了,关于IIS被陌生DLL劫持(新人发帖,写的不好的地方,请多多担待)
一上班被分到两个需要杀毒的站点,情况是SEO被劫持 出现一些博彩信息,但是打开确实正常内容,使用站长工具的网站被黑检测功能,发现网站的HEAD前面加载一对加密的东西 一开始我使用D盾扫描网站,删除了一 ...
- windows 和 Linux 下 git status 结果不一致
解决该问题 运行一下命令即可 git config core.autocrlf true 解释 git config core.autocrlf true 这个命令是在任何支持的操作系统上都可以运行的 ...