Tuesday, January 21, 2014
Extending an ext3 partition with LVM
LVM is quite technical but very powerful, here is extending an ext3 filesystem that is stored on a logical volume under Linux LVM.
Starting with a spare disk, setup with 4 LVM partitions:
[root@hpmicro ~]# fdisk -l /dev/sdb
Disk /dev/sdb: 320.0 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 9727 78132096 8e Linux LVM
/dev/sdb2 9728 19454 78132127+ 8e Linux LVM
/dev/sdb3 19455 29181 78132127+ 8e Linux LVM
/dev/sdb4 29182 38913 78172290 8e Linux LVM
I make the first two into a LVM ext3 filesystem:
[root@hpmicro ~]# pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created
[root@hpmicro ~]# pvcreate /dev/sdb2
Physical volume "/dev/sdb2" successfully created
Create a volume group "TempVG" that uses these two partitions:
[root@hpmicro ~]# vgcreate TempVG /dev/sdb1 /dev/sdb2
Volume group "TempVG" successfully created
Create a logical volume that uses storage from TempVG:
[root@hpmicro ~]# lvcreate --name TempVol00 --size 140G TempVG
Logical volume "TempVol00" created
Create the filesystem on the logical volume:
[root@hpmicro ~]# mkfs -t ext3 /dev/TempVG/TempVol00
Mount the filesystem
[root@hpmicro ~]# mkdir /store
[root@hpmicro ~]# mount /dev/TempVG/TempVol00 /store
Now create the other two PV's:
[root@hpmicro disc]# pvcreate /dev/sdb3
Physical volume "/dev/sdb3" successfully created
[root@hpmicro disc]# pvcreate /dev/sdb4
Physical volume "/dev/sdb4" successfully created
Extend the existing volume group:
[root@hpmicro disc]# vgextend TempVG /dev/sdb3 /dev/sdb4
Volume group "TempVG" successfully extended
Extend the logical volume:
lvresize -L+150G /dev/mapper/TempVG-TempVol00
Extending logical volume TempVol00 to 290.00 GB
Logical volume TempVol00 successfully resized
Now resize the filesystem on that logical volume (checking with df sizes before and after):
[root@hpmicro disc]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/TempVG-TempVol00
138G 4.8G 127G 4% /store
[root@hpmicro ~]# resize2fs /dev/mapper/TempVG-TempVol00
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/mapper/TempVG-TempVol00 is mounted on /store; on-line resizing required
Performing an on-line resize of /dev/mapper/TempVG-TempVol00 to 76021760 (4k) blocks.
The filesystem on /dev/mapper/TempVG-TempVol00 is now 76021760 blocks long.
[root@hpmicro ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/TempVG-TempVol00
286G 191M 271G 1% /store
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment