《RedHatLinux逻辑卷的管理》——一条龙服务
首先建2分区
[root@localhost ~]# partx -d /dev/sdb
error deleting partition 4: BLKPG: No such device or address error deleting partitions 7-256: BLKPG: No such device or address
[root@localhost ~]# partx -a /dev/sdb 同步分区表也可以使用partprobe来刷新分区,力度没有partx大
[root@localhost ~]# cat /proc/partitions 这里面会显示我们当前系统的分区
major minor
#blocks name
8 0 41943040 sda 8 1 307200 sda1 8 2 4161536 sda2 8 3 37473280 sda3 8 16 8388608 sdb 8 17 204800 sdb1 8 18 204800 sdb2 8 19 1024 sdb3 8 21 307200 sdb5 8 22 102400 sdb6
[root@localhost ~]# pvcreate /dev/sdb5
Writing physical volume data to disk "/dev/sdb5"
Physical volume "/dev/sdb5" successfully created
[root@localhost ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sdb5 lvm2 a-- 300.00m 300.00m
[root@localhost ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sdb5 lvm2 a-- 300.00m 300.00m
[root@localhost ~]# pvdisplay
"/dev/sdb5" is a new physical volume of "300.00 MiB"
--- NEW Physical volume ---
PV Name /dev/sdb5
VG Name
PV Size 300.00 MiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID 4YtDA6-RKEC-Nnh0-u2Qg-fSjv-q9bK-TaHsZJ
[root@localhost ~]# vgcreate vg0 /dev/sdb5
Volume group "vg0" successfully created
[root@localhost ~]# vgs
VG #PV #LV #SN Attr VSize VFree
vg0 1 0 0 wz--n- 296.00m 296.00m
[root@localhost ~]# lvcreate -L 100M -n lv0 /dev/vg0
Logical volume "lv0" created
[root@localhost ~]# lvs
LV VG Attr LSize Pool Origin Data% Move Log Copy% Convert
lv0 vg0 -wi-a--- 100.00m
逻辑卷的扩展
比如当前的lv不够用了,我们得扩展,怎么办?
[root@localhost ~]# lvextend -L +30M /dev/vg0/lv0
Rounding size to boundary between physical extents: 32.00 MiB
Extending logical volume lv0 to 132.00 MiB
Logical volume lv0 successfully resized
[root@localhost ~]# lvs
LV VG Attr LSize Pool Origin Data% Move Log Copy% Convert
lv0 vg0 -wi-a--- 132.00m
or
[root@localhost ~]# lvextend -L 200M /dev/vg0/lv0
Extending logical volume lv0 to 200.00 MiB
Logical volume lv0 successfully resized
[root@localhost ~]# lvs
LV VG Attr LSize Pool Origin Data% Move Log Copy% Convert
lv0 vg0 -wi-a--- 200.00m
如果我们的卷组不够用了怎么办?
[root@localhost ~]# pvcreate /dev/sdb6
Writing physical volume data to disk "/dev/sdb6"
Physical volume "/dev/sdb6" successfully created
[root@localhost ~]# vgextend /dev/sdb6
Please enter a physical volume path
Run `vgextend --help' for more information.
[root@localhost ~]# vgextend /dev/sdb6 /dev/vg0
Volume group "sdb6" not found
[root@localhost ~]# vgextend vg0 /dev/sdb6
Volume group "vg0" successfully extended
[root@localhost ~]# vgs
VG #PV #LV #SN Attr VSize VFree
vg0 2 1 0 wz--n- 392.00m 192.00m
下面我们来玩在线拉伸就是在线扩展,还不损坏文件系统
[root@localhost ~]# mkfs.ext4 /dev/vg0/lv0
mke2fs 1.41.12 (17-May-2010) Filesystem label= OS type: Linux Block size=1024 (log=0) Fragment size=1024 (log=0) Stride=0 blocks, Stripe width=0 blocks 51200 inodes, 204800 blocks 10240 blocks (5.00%) reserved for the super user First data block=1 Maximum filesystem blocks=67371008 25 block groups 8192 blocks per group, 8192 fragments per group 2048 inodes per group Superblock backups stored on blocks: 8193, 24577, 40961, 57345, 73729
Writing inode tables: done
Creating journal (4096 blocks): done Writing superblocks and filesystem accounting information: done
[root@localhost ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda3 36885072 9376624 25634784 27% /
tmpfs 255524 264 255260 1% /dev/shm
/dev/sda1 297485 35202 246923 13% /boot
/dev/sr0 3027366 3027366 0 100% /media/RHEL_6.3 i386 Disc 1
[root@localhost ~]# mount /dev/vg0/lv0 /mnt/
[root@localhost ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda3 36885072 9376624 25634784 27% /
tmpfs 255524 264 255260 1% /dev/shm
/dev/sda1 297485 35202 246923 13% /boot
/dev/sr0 3027366 3027366 0 100% /media/RHEL_6.3 i386 Disc 1
/dev/mapper/vg0-lv0 198337 5646 182451 4% /mnt
[root@localhost ~]#
[root@localhost ~]# e2fsck -f /dev/vg0/lv0
e2fsck 1.41.12 (17-May-2010) /dev/vg0/lv0 is mounted.
WARNING!!! The filesystem is mounted. If you continue you ***WILL*** cause ***SEVERE*** filesystem damage.
Do you really want to continue (y/n)? yes
/dev/vg0/lv0: recovering journal Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 4: Checking reference counts Pass 5: Checking group summary information /dev/vg0/lv0: 11/51200 files (0.0% non-contiguous), 12109/204800 blocks
[root@localhost ~]# lvextend -L +30M /dev/vg0/lv0
Rounding size to boundary between physical extents: 32.00 MiB
Extending logical volume lv0 to 232.00 MiB
Logical volume lv0 successfully resized
[root@localhost ~]# df -H
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 38G 9.7G 27G 27% /
tmpfs 262M 271k 262M 1% /dev/shm
/dev/sda1 305M 37M 253M 13% /boot
/dev/sr0 3.2G 3.2G 0 100% /media/RHEL_6.3 i386 Disc 1
/dev/mapper/vg0-lv0 204M 5.8M 187M 4% /mnt
root@localhost ~]# resize2fs /dev/vg0/lv0
resize2fs 1.41.12 (17-May-2010) Filesystem at /dev/vg0/lv0 is mounted on /mnt; on-line resizing required old desc_blocks = 1, new_desc_blocks = 1 Performing an on-line resize of /dev/vg0/lv0 to 237568 (1k) blocks. The filesystem on /dev/vg0/lv0 is now 237568 blocks long.
[root@localhost ~]# df -H
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 38G 9.7G 27G 27% /
tmpfs 262M 271k 262M 1% /dev/shm
/dev/sda1 305M 37M 253M 13% /boot
/dev/sr0 3.2G 3.2G 0 100% /media/RHEL_6.3 i386 Disc 1
/dev/mapper/vg0-lv0 236M 6.4M 218M 3% /mnt
逻辑卷的压缩
[root@localhost ~]# df -H
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 38G 9.7G 27G 27% /
tmpfs 262M 271k 262M 1% /dev/shm
/dev/sda1 305M 37M 253M 13% /boot
/dev/sr0 3.2G 3.2G 0 100% /media/RHEL_6.3 i386 Disc 1
/dev/mapper/vg0-lv1 102M 5.8M 91M 7% /mnt
[root@localhost ~]# umount /mnt/
[root@localhost ~]# e2fsck -f /dev/vg0/lv1
e2fsck 1.41.12 (17-May-2010) Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 4: Checking reference counts Pass 5: Checking group summary information /dev/vg0/lv1: 11/25688 files (9.1% non-contiguous), 8896/102400 blocks [root@localhost ~]# resize2fs /dev/vg0/lv1 30M
resize2fs 1.41.12 (17-May-2010) Resizing the filesystem on /dev/vg0/lv1 to 30720 (1k) blocks. The filesystem on /dev/vg0/lv1 is now 30720 blocks long.
[root@localhost ~]# df -H
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 38G 9.7G 27G 27% /
tmpfs 262M 271k 262M 1% /dev/shm
/dev/sda1 305M 37M 253M 13% /boot
/dev/sr0 3.2G 3.2G 0 100% /media/RHEL_6.3 i386 Disc 1
[root@localhost ~]# mount /dev/vg0/lv1 /mnt/
[root@localhost ~]# df -H
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 38G 9.7G 27G 27% /
tmpfs 262M 271k 262M 1% /dev/shm
/dev/sda1 305M 37M 253M 13% /boot
/dev/sr0 3.2G 3.2G 0 100% /media/RHEL_6.3 i386 Disc 1
/dev/mapper/vg0-lv1 31M 5.0M 24M 18% /mnt
[root@localhost ~]# lvreduce -L 30M /dev/vg0/lv1
Rounding size to boundary between physical extents: 32.00 MiB WARNING: Reducing active and open logical volume to 32.00 MiB THIS MAY DESTROY YOUR DATA (filesystem etc.) Do you really want to reduce lv1? [y/n]: y
Reducing logical volume lv1 to 32.00 MiB Logical volume lv1 successfully resized
[root@localhost ~]# df -H
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 38G 9.7G 27G 27% /
tmpfs 262M 271k 262M 1% /dev/shm
/dev/sda1 305M 37M 253M 13% /boot
/dev/sr0 3.2G 3.2G 0 100% /media/RHEL_6.3 i386 Disc 1
/dev/mapper/vg0-lv1 31M 5.0M 24M 18% /mnt
现在有2快pv,一块大的用的很少,一块小的有没用,而我们现在想用那块大的,资源紧张时,我们该怎么节省空间
[root@localhost ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sdb5 vg0 lvm2 a-- 296.00m 264.00m
/dev/sdb6 vg0 lvm2 a-- 96.00m 96.00m
[root@localhost ~]# pvmove /dev/sdb5 /dev/sdb6
/dev/sdb5: Moved: 0.0%
/dev/sdb5: Moved: 100.0%
[root@localhost ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sdb5 vg0 lvm2 a-- 296.00m 296.00m
/dev/sdb6 vg0 lvm2 a-- 96.00m 64.00m
最后我们来移除逻辑卷
[root@localhost ~]# umount /mnt/
[root@localhost ~]# lvremove /dev/vg0/lv1
Do you really want to remove active logical volume lv1? [y/n]: y
Logical volume "lv1" successfully removed
[root@localhost ~]# lvs
[root@localhost ~]# vgs
VG #PV #LV #SN Attr VSize VFree
vg0 2 0 0 wz--n- 392.00m 392.00m
[root@localhost ~]# vgremove /dev/vg0
Volume group "vg0" successfully removed
[root@localhost ~]# vgs
No volume groups found
[root@localhost ~]# pvremove /dev/sdb5
Labels on physical volume "/dev/sdb5" successfully wiped
[root@localhost ~]# pvremove /dev/sdb6
Labels on physical volume "/dev/sdb6" successfully wiped
[root@localhost ~]# pvs
到此我们的逻辑卷就完了
《RedHatLinux逻辑卷的管理》——一条龙服务的更多相关文章
- 自学Linux Shell8.2-linux逻辑卷LVM管理
点击返回 自学Linux命令行与Shell脚本之路 8.2-linux逻辑卷LVM管理 Linux逻辑卷管理器软件包用来通过将另外一个硬盘上的分区加入已有文件系统,动态地添加存储空间. 1. 逻辑卷L ...
- centos6下的lvm逻辑卷的管理
LVM:Logical Volume Manager 将多块设备组合成一个来使用 dm:device mapper 设备映射 设备文件 /dev/卷组名/逻辑卷名 /dev/mapp ...
- LVM逻辑卷的管理和使用
本篇将从头到尾演示一遍逻辑卷的管理. 主要步骤 1.创建lv逻辑卷步骤 前提:先创建3个磁盘分区,类型为8e: 1.PV创建 pvcrete /dev/ ...
- LINUX逻辑卷(LVM)管理与逻辑卷分区
LINUX之逻辑卷管理与逻辑卷扩展 LVM是逻辑卷管理(Logical Volume Manager)的简称,他是建立在物理存储设备之上的一个抽象层,允许你生成逻辑存储卷,和直接使用物理存储在管理上相 ...
- Linux LVM Logical Volume Management 逻辑卷的管理
博主是一个数据库DBA,但是一般来说,是不做linux服务器LVM 逻辑卷的创建.扩容和减容操作的,基本上有系统管理员操作,一是各司其职,专业的事专业的人做,二是做多了你的责任也多了,哈哈! 但是li ...
- LVM逻辑卷创建管理
首先添加三块硬盘 结构关系图 相关命令 查看磁盘 #fdisk -l 分区 #fdisk /dev/sda/ #n新建 ProMary主分区 extended扩展分区 #p查看 #q不保存退出 #w保 ...
- Linux中逻辑卷(LVM)管理基本操作
1.创建逻辑卷 原文:https://linux.cn/article-3965-1.html
- 【转载】Linux磁盘管理:LVM逻辑卷管理
Linux学习之CentOS(二十五)--Linux磁盘管理:LVM逻辑卷基本概念及LVM的工作原理 这篇随笔将详细讲解Linux磁盘管理机制中的LVM逻辑卷的基本概念以及LVM的工作原理!!! 一. ...
- LVM逻辑卷管理
一.LVM简介 LVM(Logic Volume Manager)逻辑卷管理,简单理解就是将一块或多块硬盘的分区在逻辑上集合,当一块大硬盘来使用. 其特点是: 1.可以实现在线动态扩展,也可以缩减 2 ...
随机推荐
- yii user 组件
yii/web/user enableAutoLogin:如果未登录,则会从cookie中登录 autoRenewCookie: 如果登录了,则会使用renewIdentityCookie更新cook ...
- [原创]经历:asp.net oracle 部署问题以及解决方法
精简的美丽...... 一.环境 开发环境 win7 64bit Vs2010 Oracle 11g r2 64bit <inst ...
- focusky
Focusky,是一款新型多媒体幻灯片制作软件,操作便捷性以及演示效果超越PPT,主要通过缩放.旋转.移动动作使演示变得生动有趣.传统PPT单线条时序,只是一张接一张切换播放,而Focusky打破常规 ...
- BFS-hdu-1226-超级密码
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1226 题目意思: 给一个N,给nn个jj进制的数字,问最小的不超过500位的由这些数字组成的jj进制 ...
- MySQL中的WITH ROLLUP
MySQL中的WITH ROLLUP MySQL的扩展SQL中有一个非常有意思的应用WITH ROLLUP,在分组的统计数据的基础上再进行相同的统计(SUM,AVG,COUNT…),非常类似于Orac ...
- Fedora下载地址
http://fedoraproject.org/zh_CN/get-fedora-all
- PHP读书笔记(5)-结构语句
PHP结构语句 顺序结构 顺序结构就像一条直线,按着顺序一直往下执行.我们编写的代码默认都是按照顺序结构执行的. 条件结构之if…else… 条件结构就像一个岔路口,可以向左走,也可以向右走.比如上洗 ...
- vs2010 调试C++程序 快捷键
命令名 快捷键 说明 调试.应用代码更改 Alt + F10 启动生成操作,利用它可以通过“编辑并继续”功能应用对正在调试的代码所作的更改. 调试.自动窗口 Ctrl + D,Ctrl + A 显示“ ...
- AT-PagerAdapter
关于PagerAdapter的粗略翻译 英文版api地址:PagerAdapter(自备梯子) PagerAdapter 已知直接子类:FragmentPagerAdapter.Fra ...
- 终于又可以用WLW了.
前面有一段时间没有写博客,然后过完年想继续用WLW的时候,出现问题了. An unexpected error occurred while attempting to detect weblog s ...