RHEL6-17-LOGICAL
VOLUME MANAGER (LVM)-4
LVM OPERATIONS:
How to resize the logical volume with “lvresize”…?
How to rename the volume group (vgrename)…?
How to rename the logical volume (lvrename)…?
How to make the changes effective after
vgrename and lvrename…?
[root@rhel6-client1 ~]# pvcreate /dev/sdb4
Physical volume
"/dev/sdb4" successfully created
[root@rhel6-client1 ~]# vgextend vg01 /dev/sdb4
Volume group "vg01"
successfully extended
[root@rhel6-client1 ~]# lvextend --size +500M
/dev/vg01/mylv
Extending logical volume mylv
to 2.09 GiB
Logical volume mylv
successfully resized
[root@rhel6-client1 ~]# lvs |grep mylv
mylv01 myvg01 -wi-a---- 200.00m
mylv vg01
-wi-ao--- 2.09g
mylv2 vg01
-wi-a---- 3.39g
[root@rhel6-client1 ~]# df -kh
Filesystem Size Used Avail Use% Mounted on
/dev/sda6 15G 6.3G
7.4G 46% /
tmpfs 937M 76K
937M 1% /dev/shm
/dev/sda1 485M 37M
423M 8% /boot
/dev/sda3 1008M 34M
924M 4% /home
/dev/sda2 2.9G 69M
2.7G 3% /opt
/dev/mapper/vg01-mylv
1.6G 35M
1.5G 3% /mylv ççç
[root@rhel6-client1 ~]#
[root@rhel6-client1 ~]# resize2fs /dev/vg01/mylv
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/vg01/mylv is mounted on /mylv; on-line resizing
required
old desc_blocks = 1, new_desc_blocks = 1
Performing an on-line resize of /dev/vg01/mylv to 546816 (4k) blocks.
The filesystem on /dev/vg01/mylv is now 546816 blocks long.
[root@rhel6-client1 ~]# df -kh
Filesystem Size Used Avail Use% Mounted on
/dev/sda6 15G 6.3G
7.4G 46% /
tmpfs 937M 76K
937M 1% /dev/shm
/dev/sda1 485M 37M
423M 8% /boot
/dev/sda3 1008M 34M
924M 4% /home
/dev/sda2 2.9G 69M
2.7G 3% /opt
/dev/mapper/vg01-mylv
2.1G 35M
2.0G 2% /mylv ççç
Good, The command “lvresize” is similar to “lvextend”.
Can I reduce size with “lvresize”…?
[root@rhel6-client1 ~]# lvextend --size -800M
/dev/vg01/mylv
Negative argument not
permitted - use lvreduce
Run `lvextend --help' for
more information.
[root@rhel6-client1 ~]# lvextend --size 1G /dev/vg01/mylv
New size given (256 extents)
not larger than existing size (334 extents)
Run `lvextend --help' for
more information.
Means I cannot reduce size.
[root@rhel6-client1 ~]# lvreduce -L -800M /dev/vg01/mylv
WARNING: Reducing active and
open logical volume to 1.30 GiB
THIS MAY DESTROY YOUR DATA
(filesystem etc.)
Do you really want to reduce mylv? [y/n]: y
Reducing logical volume mylv
to 1.30 GiB
Logical volume mylv
successfully resized
[root@rhel6-client1 ~]# lvs |grep "mylv"
mylv01 myvg01 -wi-a---- 200.00m
mylv vg01
-wi-ao--- 1.30g
mylv2 vg01
-wi-a---- 3.39g
[root@rhel6-client1 ~]# lvextend --size 1200M
/dev/vg01/mylv
New size given (300 extents)
not larger than existing size (334 extents)
Run `lvextend --help' for
more information.
Why this error…?
This is why because I am again reducing the size.
Now I will try to resize with greater size than existing.
[root@rhel6-client1 ~]# lvextend --size 1500M
/dev/vg01/mylv
Extending logical volume mylv
to 1.46 GiB
Logical volume mylv
successfully resized
Done.
Being super talented, I can reduce size with some arguments, but do
it on your own risk.
[root@rhel6-client1 ~]# lvresize --resizefs --size -500M
/dev/vg01/mylv
Do
you want to unmount "/mylv"? [Y|n] y ç
fsck
from util-linux-ng 2.17.2
/dev/mapper/vg01-mylv:
The filesystem size (according to the superblock) is 546816 blocks
The
physical size of the device is 384000 blocks
Either
the superblock or the partition table is likely to be corrupt!
/dev/mapper/vg01-mylv:
UNEXPECTED INCONSISTENCY; RUN fsck MANUALLY.
(i.e., without -a or -p options)
resize2fs
1.41.12 (17-May-2010)
Please
run 'e2fsck -f /dev/mapper/vg01-mylv' first.
fsadm:
Resize ext4 failed
mount:
wrong fs type, bad option, bad superblock on /dev/mapper/vg01-mylv,
missing codepage or helper program, or
other error
In some cases useful info is found in syslog
- try
dmesg | tail or so
fsadm failed: 1
Filesystem resize failed.
[root@rhel6-client1 ~]# e2fsck -ff /dev/vg01/mylv
e2fsck
1.41.12 (17-May-2010)
The
filesystem size (according to the superblock) is 546816 blocks
The
physical size of the device is 384000 blocks
Either
the superblock or the partition table is likely to be corrupt!
Abort<y>?
yes
[root@rhel6-client1
~]# e2fsck -y /dev/vg01/mylv
e2fsck
1.41.12 (17-May-2010)
The
filesystem size (according to the superblock) is 546816 blocks
The
physical size of the device is 384000 blocks
Either
the superblock or the partition table is likely to be corrupt!
Abort?
yes
[root@rhel6-client1 ~]# resize2fs /dev/vg01/mylv
resize2fs 1.41.12 (17-May-2010)
Please run 'e2fsck -f /dev/vg01/mylv' first.
[root@rhel6-client1 ~]# e2fsck -f /dev/vg01/mylv
e2fsck
1.41.12 (17-May-2010)
The
filesystem size (according to the superblock) is 546816 blocks
The
physical size of the device is 384000 blocks
Either
the superblock or the partition table is likely to be corrupt!
Abort<y>?
no
Pass
1: Checking inodes, blocks, and sizes
Error
reading block 425986 (Invalid argument) while getting next inode from
scan. Ignore error<y>? yes
Force
rewrite<y>? yes
Error
writing block 425986 (Invalid argument) while getting next inode from
scan. Ignore error<y>? yes
Error
reading block 425987 (Invalid argument) while getting next inode from
scan. Ignore error<y>? yes
Force
rewrite<y>? yes
Error
writing block 425987 (Invalid argument) while getting next inode from
scan. Ignore error<y>? yes
Error
reading block 425988 (Invalid argument) while getting next inode from
scan. Ignore error<y>? yes
Force
rewrite<y>? yes
Error
writing block 425988 (Invalid argument) while getting next inode from
scan. Ignore error<y>? yes
Error
reading block 425989 (Invalid argument) while getting next inode from
scan. Ignore error<y>? yes
Force
rewrite<y>? yes
/dev/vg01/mylv:
e2fsck canceled.
/dev/vg01/mylv:
********** WARNING: Filesystem still has errors **********
See, what happened!!! … now all data lost and we need to recreate FS.
[root@rhel6-client1 ~]# mkfs.ext4 /dev/vg01/mylv
mke2fs
1.41.12 (17-May-2010)
Filesystem
label=
OS
type: Linux
Block
size=4096 (log=2)
Fragment
size=4096 (log=2)
Stride=0
blocks, Stripe width=0 blocks
96000
inodes, 384000 blocks
19200
blocks (5.00%) reserved for the super user
First
data block=0
Maximum
filesystem blocks=394264576
12
block groups
32768
blocks per group, 32768 fragments per group
8000
inodes per group
Superblock
backups stored on blocks:
32768, 98304, 163840, 229376, 294912
Writing
inode tables: done
Creating
journal (8192 blocks): done
Writing
superblocks and filesystem accounting information: done
This
filesystem will be automatically checked every 34 mounts or
180
days, whichever comes first. Use tune2fs
-c or -i to override.
[root@rhel6-client1 ~]# mount –a
[root@rhel6-client1 ~]# df -kh
Filesystem Size Used Avail Use% Mounted on
/dev/sda6 15G 6.3G
7.4G 46% /
tmpfs 937M 76K
937M 1% /dev/shm
/dev/sda1 485M 37M
423M 8% /boot
/dev/sda3 1008M 34M
924M 4% /home
/dev/sda2 2.9G 69M
2.7G 3% /opt
/dev/mapper/vg01-mylv
1.5G
35M 1.4G 3% /mylv
[root@rhel6-client1 ~]#
LOGICAL VOLUME (LV) RENAME:
# lvrename VG_Name Old_LV_name
New_LV_name
[root@rhel6-client1 ~]# lvrename vg01 mylv mylvtest1
Renamed "mylv" to
"mylvtest1" in volume group "vg01"
LV is renamed but is it effective…?
[root@rhel6-client1 ~]# df -kh /mylv
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg01-mylv
1.5G 35M
1.4G 3% /mylv
No, then what should we do…?
Remount the FS,
[root@rhel6-client1 ~]# mount /dev/vg01/mylvtest1 /mylv
mount: /dev/mapper/vg01-mylvtest1 already mounted or /mylv busy
mount: according to mtab, /dev/mapper/vg01-mylv is already mounted on
/mylv
[root@rhel6-client1 ~]# umount /mylv
[root@rhel6-client1 ~]# mount /dev/vg01/mylvtest1 /mylv
[root@rhel6-client1 ~]# df -kh /mylv
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg01-mylvtest1
1.5G 35M
1.4G 3% /mylv
Need to change the entry in “fstab” as well.
VOLUME GROUP (VG) RENAME:
# vgrename Old_VG_name New_VG_name
[root@rhel6-client1 ~]# vgrename vg01 vg-test01
Volume group "vg01"
successfully renamed to "vg-test01"
Is it effective…?
[root@rhel6-client1 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
myvg01 3
4 0 wz--n- 9.99g 9.20g
vg-test01 3
4 0 wz--n- 8.99g 1.45g
vg02 1
3 0 wz--n- 2.00g 0
Technically Yes… but …… but …….
[root@rhel6-client1 ~]# df -kh /mylv
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg01-mylvtest1
1.5G 35M
1.4G 3% /mylv
[root@rhel6-client1 ~]# umount /mylv
[root@rhel6-client1 ~]# mount /dev/vg-test01/mylvtest1
/mylv
[root@rhel6-client1 ~]# df -kh /mylv/
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg--test01-mylvtest1
1.5G 35M
1.4G 3% /mylv
Need to change the entry in “fstab” as well.
No comments:
Post a Comment