发布时间:2015-11-06 16:48:28作者:知识屋
[root@www ~]# pvcreate /dev/sdb1 /dev/sdb2//创建PV Physical volume "/dev/sdb1" successfully created Physical volume "/dev/sdb2" successfully created
[root@www ~]# pvs//查看PV PV VG Fmt Attr PSize PFree /dev/sda2 vg0 lvm2 a-- 59.99g 7.99g /dev/sdb1 lvm2 --- 2.01g 2.01g /dev/sdb2 lvm2 --- 3.01g 3.01g[root@www ~]# pvdisplay /dev/sdb[0-9]//可以看到详细信息 --- Physical volume --- PV Name /dev/sdb1 VG Name myvg PV Size 2.01 GiB / not usable 3.16 MiB Allocatable yes PE Size 4.00 MiB Total PE 513 Free PE 513 Allocated PE 0 PV UUID rA5Vdy-j2rr-b9Vf-zo8I-sjFD-1z23-VhHAgI --- Physical volume --- PV Name /dev/sdb2 VG Name myvg PV Size 3.01 GiB / not usable 2.79 MiB Allocatable yes PE Size 4.00 MiB Total PE 770 Free PE 770 Allocated PE 0 PV UUID GVtLyK-Ugd1-DKHo-3wHS-oia1-lbpz-PA4oma [root@www ~]#
[root@www ~]# pvcreate /dev/sdb3 //创建pv Physical volume "/dev/sdb3" successfully created[root@www ~]# pvs //查看pv PV VG Fmt Attr PSize PFree /dev/sda2 vg0 lvm2 a-- 59.99g 7.99g /dev/sdb1 myvg lvm2 a-- 2.00g 0 /dev/sdb2 myvg lvm2 a-- 3.01g 2.01g /dev/sdb3 lvm2 --- 3.01g 3.01g[root@www ~]# pvremove /dev/sdb3 //删除pv /dev/sdb3 Labels on physical volume "/dev/sdb3" successfully wiped[root@www ~]# pvs PV VG Fmt Attr PSize PFree /dev/sda2 vg0 lvm2 a-- 59.99g 7.99g /dev/sdb1 myvg lvm2 a-- 2.00g 0 /dev/sdb2 myvg lvm2 a-- 3.01g 2.01g
[root@www ~]# vgcreate myvg /dev/sdb{1,2} Volume group "myvg" successfully created
[root@www ~]# vgs VG #PV #LV #SN Attr VSize VFree myvg 2 0 0 wz--n- 5.01g 5.01g vg0 1 4 0 wz--n- 59.99g 7.99g[root@www ~]# vgdisplay --- Volume group --- VG Name myvg System ID Format lvm2 Metadata Areas 2 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 2 Act PV 2 VG Size 5.01 GiB PE Size 4.00 MiB //PE 块大小 Total PE 1283 Alloc PE / Size 0 / 0 Free PE / Size 1283 / 5.01 GiB VG UUID llSGpO-Bk51-KVBB-llAZ-AA9E-aBYq-sUrnPL
# vgremove VGNAME...[root@www ~]# vgs VG #PV #LV #SN Attr VSize VFree myvg 2 0 0 wz--n- 5.01g 5.01g vg0 1 4 0 wz--n- 59.99g 7.99g[root@www ~]# vgremove myvg//删除vg Volume group "myvg" successfully removed[root@www ~]# vgs VG #PV #LV #SN Attr VSize VFree vg0 1 4 0 wz--n- 59.99g 7.99g[root@www ~]#
[root@www ~]# vgcreate myvg /dev/sdb{1,2} Volume group "myvg" successfully created[root@www ~]# vgdisplay --- Volume group --- VG Name myvg System ID Format lvm2 Metadata Areas 2 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 2 Act PV 2 VG Size 5.01 GiB//大小为5G PE Size 4.00 MiB Total PE 1283 Alloc PE / Size 0 / 0 Free PE / Size 1283 / 5.01 GiB VG UUID Iz9bc0-Sw38-H916-TAg3-abNh-iUJW-hjuRoB------------------------------------------------------------------------------
[root@www ~]# pvmove /dev/sdb2 // 将/sdb2中的数据移动到其他pv上 No data to move for myvg[root@www ~]# vgreduce myvg /dev/sdb2//移除/dev/sdb2 Removed "/dev/sdb2" from volume group "myvg"[root@www ~]# vgdisplay myvg --- Volume group --- VG Name myvg System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 2 VG Access read/write VG Status resizable MAX LV 0 Cur LV 0 Open LV 0 Max PV 0 Cur PV 1 Act PV 1 VG Size 2.00 GiB// 大小变为2G PE Size 4.00 MiB Total PE 513 Alloc PE / Size 0 / 0 Free PE / Size 513 / 2.00 GiB VG UUID Iz9bc0-Sw38-H916-TAg3-abNh-iUJW-hjuRoB
[root@www ~]# vgs VG #PV #LV #SN Attr VSize VFree myvg 1 0 0 wz--n- 2.00g 2.00g//扩展前大小为2G vg0 1 4 0 wz--n- 59.99g 7.99g[root@www ~]# vgextend myvg /dev/sdb2//向myvg中添加/dev/sdb2 Volume group "myvg" successfully extended[root@www ~]# vgs VG #PV #LV #SN Attr VSize VFree myvg 2 0 0 wz--n- 5.01g 5.01g//大小变为5G vg0 1 4 0 wz--n- 59.99g 7.99g
[root@www ~]# lvcreate -L 4G -n mylv myvg//创建大小为4G的LV 名字为mylv Logical volume "mylv" created[root@www ~]# lvs//查看LV LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert mylv myvg -wi-a----- 4.00g //大小为4G root vg0 -wi-ao---- 20.00g swap vg0 -wi-ao---- 2.00g usr vg0 -wi-ao---- 10.00g var vg0 -wi-ao---- 20.00g [root@www ~]# lvdisplay --- Logical volume --- LV Path /dev/myvg/mylv LV Name mylv VG Name myvg LV UUID i3tDAL-GdB4-TVIf-Efun-vVmg-Ig00-cSCdKk LV Write Access read/write LV Creation host, time www.w1.com, 2015-08-16 05:05:40 +0800 LV Status available # open 0 LV Size 4.00 GiB Current LE 1024 Segments 2 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:4
[root@www ~]# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert mylv myvg -wi-a----- 4.00g //查看lv root vg0 -wi-ao---- 20.00g swap vg0 -wi-ao---- 2.00g usr vg0 -wi-ao---- 10.00g var vg0 -wi-ao---- 20.00g [root@www ~]# lvremove /dev/myvg/mylv//移除mylvDo you really want to remove active logical volume mylv? [y/n]: y Logical volume "mylv" successfully removed[root@www ~]# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert root vg0 -wi-ao---- 20.00g //已经不存在mylv swap vg0 -wi-ao---- 2.00g usr vg0 -wi-ao---- 10.00g var vg0 -wi-ao---- 20.00g [root@www ~]#
[root@www ~]# lvcreate -L 2G -n mylv myvg Logical volume "mylv" created[root@www ~]# lvdisplay /dev/myvg/mylv --- Logical volume --- LV Path /dev/myvg/mylv LV Name mylv VG Name myvg LV UUID yZE2SK-G9J9-dFdH-uJvK-Lln6-AS2G-UqHMjU LV Write Access read/write LV Creation host, time www.w1.com, 2015-08-16 05:12:04 +0800 LV Status available # open 0 LV Size 2.00 GiB Current LE 512 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:4
[root@www ~]# mke2fs -t ext4 /dev/myvg/mylvmke2fs 1.41.12 (17-May-2010)Filesystem label=OS type: LinuxBlock size=4096 (log=2)Fragment size=4096 (log=2)Stride=0 blocks, Stripe width=0 blocks131072 inodes, 524288 blocks26214 blocks (5.00%) reserved for the super userFirst data block=0Maximum filesystem blocks=53687091216 block groups32768 blocks per group, 32768 fragments per group8192 inodes per groupSuperblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912Writing inode tables: done Creating journal (16384 blocks): doneWriting superblocks and filesystem accounting information: doneThis filesystem will be automatically checked every 38 mounts or180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@www ~]# mkdir /nyist//创建挂载点[root@www ~]# mount /dev/myvg/mylv /nyist//挂载[root@www ~]# df -h//查看大小Filesystem Size Used Avail Use% Mounted on/dev/mapper/vg0-root 20G 18G 908M 96% /tmpfs 565M 0 565M 0% /dev/shm/dev/sda1 190M 33M 148M 18% /boot/dev/mapper/vg0-usr 9.8G 2.4G 6.9G 26% /usr/dev/mapper/vg0-var 20G 294M 19G 2% /var/dev/sda3 59G 4.7G 52G 9% /usr/soc/dev/mapper/myvg-mylv 2.0G 3.0M 1.9G 1% /nyist
[root@www ~]# cat /nyist/fstab ## /etc/fstab# Created by anaconda on Thu Mar 26 20:01:38 2015## Accessible filesystems, by reference, are maintained under '/dev/disk'# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info#/dev/mapper/vg0-root / ext4 defaults 1 1UUID=0d0698ff-1645-4ff8-af27-fc6e73573941 /boot ext4 defaults 1 2/dev/mapper/vg0-usr /usr ext4 defaults 1 2/dev/mapper/vg0-var /var ext4 defaults 1 2/dev/mapper/vg0-swap swap swap defaults 0 0tmpfs /dev/shm tmpfs defaults 0 0devpts /dev/pts devpts gid=5,mode=620 0 0sysfs /sys sysfs defaults 0 0proc /proc proc defaults 0 0/dev/sda3 /usr/soc ext4 defaults 0 0[root@www ~]#
[root@www ~]# vgs VG #PV #LV #SN Attr VSize VFree myvg 2 1 0 wz--n- 5.01g 3.01g//还有3G 我们要扩展到4G 容量足够 vg0 1 4 0 wz--n- 59.99g 7.99g
[root@www ~]# lvs /dev/myvg/mylv LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert mylv myvg -wi-a----- 2.00g //目前大小为2G [root@www ~]# lvextend -L 4G /dev/myvg/mylv //扩展LV 也可以写为: lvextend -L +2G /vev/myvg/mylv Size of logical volume myvg/mylv changed from 2.00 GiB (512 extents) to 4.00 GiB (1024 extents). Logical volume mylv successfully resized[root@www ~]# lvs /dev/myvg/mylv查看mylv大小 LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert mylv myvg -wi-a----- 4.00g //扩展为4G [root@www ~]# [root@www ~]# lvdisplay /dev/myvg/mylv --- Logical volume --- LV Path /dev/myvg/mylv LV Name mylv VG Name myvg LV UUID yZE2SK-G9J9-dFdH-uJvK-Lln6-AS2G-UqHMjU LV Write Access read/write LV Creation host, time www.w1.com, 2015-08-16 05:12:04 +0800 LV Status available # open 0 LV Size 4.00 GiB //已经扩展为4G Current LE 1024 Segments 2 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:4
[root@www ~]# df -hFilesystem Size Used Avail Use% Mounted on....../dev/sda3 59G 4.7G 52G 9% /usr/soc/dev/mapper/myvg-mylv 2.0G 3.1M 1.9G 1% /nyist//依然为2G[root@www ~]#
[root@www ~]# resize2fs /dev/myvg/mylv//扩展逻辑边界resize2fs 1.41.12 (17-May-2010)Filesystem at /dev/myvg/mylv is mounted on /nyist; on-line resizing requiredold desc_blocks = 1, new_desc_blocks = 1Performing an on-line resize of /dev/myvg/mylv to 1048576 (4k) blocks.The filesystem on /dev/myvg/mylv is now 1048576 blocks long.[root@www ~]# df -hFilesystem Size Used Avail Use% Mounted on/dev/mapper/vg0-root 20G 18G 908M 96% /tmpfs 565M 0 565M 0% /dev/shm/dev/sda1 190M 33M 148M 18% /boot/dev/mapper/vg0-usr 9.8G 2.4G 6.9G 26% /usr/dev/mapper/vg0-var 20G 294M 19G 2% /var/dev/sda3 59G 4.7G 52G 9% /usr/soc/dev/mapper/myvg-mylv 3.9G 4.0M 3.7G 1% /nyist//大小已经为3.9G 成功扩展[root@www ~]#
[root@www ~]# umount /nyist[root@www ~]# e2fsck -f /dev/myvg/mylve2fsck 1.41.12 (17-May-2010)Pass 1: Checking inodes, blocks, and sizesPass 2: Checking directory structurePass 3: Checking directory connectivityPass 4: Checking reference countsPass 5: Checking group summary information/dev/myvg/mylv: 12/262144 files (0.0% non-contiguous), 33871/1048576 blocks[root@www ~]# resize2fs /dev/myvg/mylv 3G//缩减逻辑边界resize2fs 1.41.12 (17-May-2010)Resizing the filesystem on /dev/myvg/mylv to 786432 (4k) blocks.The filesystem on /dev/myvg/mylv is now 786432 blocks long.[root@www ~]# lvreduce -L 3G /dev/myvg/mylv//缩减物理边界 WARNING: Reducing active logical volume to 3.00 GiB THIS MAY DESTROY YOUR DATA (filesystem etc.)Do you really want to reduce mylv? [y/n]: y Size of logical volume myvg/mylv changed from 4.00 GiB (1024 extents) to 3.00 GiB (768 extents). Logical volume mylv successfully resized[root@www ~]#
[root@www ~]# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert mylv myvg -wi-a----- 3.00g //大小3G root vg0 -wi-ao---- 20.00g swap vg0 -wi-ao---- 2.00g usr vg0 -wi-ao---- 10.00g var vg0 -wi-ao---- 20.00g [root@www ~]# mount /dev/myvg/mylv /nyist[root@www ~]# df -hFilesystem Size Used Avail Use% Mounted on/dev/mapper/vg0-root 20G 18G 908M 96% /tmpfs 565M 0 565M 0% /dev/shm/dev/sda1 190M 33M 148M 18% /boot/dev/mapper/vg0-usr 9.8G 2.4G 6.9G 26% /usr/dev/mapper/vg0-var 20G 294M 19G 2% /var/dev/sda3 59G 4.7G 52G 9% /usr/soc/dev/mapper/myvg-mylv 2.9G 3.1M 2.8G 1% /nyist//大小2.9G [root@www ~]#
linux一键安装web环境全攻略 在linux系统中怎么一键安装web环境方法
Linux网络基本网络配置方法介绍 如何配置Linux系统的网络方法
Linux下DNS服务器搭建详解 Linux下搭建DNS服务器和配置文件
对Linux进行详细的性能监控的方法 Linux 系统性能监控命令详解
linux系统root密码忘了怎么办 linux忘记root密码后找回密码的方法
Linux基本命令有哪些 Linux系统常用操作命令有哪些
Linux必学的网络操作命令 linux网络操作相关命令汇总
linux系统从入侵到提权的详细过程 linux入侵提权服务器方法技巧
linux系统怎么用命令切换用户登录 Linux切换用户的命令是什么
在linux中添加普通新用户登录 如何在Linux中添加一个新的用户
2012-07-10
CentOS 6.3安装(详细图解教程)
Linux怎么查看网卡驱动?Linux下查看网卡的驱动程序
centos修改主机名命令
Ubuntu或UbuntuKyKin14.04Unity桌面风格与Gnome桌面风格的切换
FEDORA 17中设置TIGERVNC远程访问
StartOS 5.0相关介绍,新型的Linux系统!
解决vSphere Client登录linux版vCenter失败
LINUX最新提权 Exploits Linux Kernel <= 2.6.37
nginx在网站中的7层转发功能