How to extend Filesystem to new disk using LVM?
Wayne Pinette
Wpinette at tru.ca
Wed Feb 13 16:41:42 UTC 2008
>>> "Patil, Manjiri S" <mpatil at bu.edu> 13/02/2008 7:59 am >>>
Hi all,
I am running RHEL 4
Here is the out put of df . I want to extend /var to another new hard
drive.
$ df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
27673632 17240220 9027668 66% /
/dev/sda1 101086 39271 56596 41% /boot
none 2987092 0 2987092 0% /dev/shm
/dev/sda2 5162828 4529840 370728 93% /var
I have done following steps .
1) Added disk i.e sdb
2)run fdisk , created single partition i.e sdb1
3) Started system-config-lvm and initialized the disk and added the
disk
to logical volume LGVol00 under VolGroup00. I haven't yet extended
the
volume to use the new disk space .
4) Here is the output of PVSCAN
pvscan
PV /dev/sda3 VG VolGroup00 lvm2 [28.78 GB / 32.00 MB free]
PV /dev/sdb1 VG VolGroup00 lvm2 [136.69 GB / 136.69 GB free]
Total: 2 [165.47 GB] / in use: 2 [165.47 GB] / in no VG: 0 [0 ]
It shows new disk as sdb1 ( 136GB)
How do I extend /var so that it will use new disk space ? Do I have
to
extend LGVol00 to use new disk space ? Can I do it through
system-config-lvm ? I know there is ext2online command but how do I
use
it?
You can't extend your /var partition using lvm's because your /var
partiition is not in an lvm, it is on /dev/sda2.
It seems your / partition is in lvm, but your /boot and /var are not.
You can only extend lvm volumes, you can't mix and match.
Now, if your /var is really too small and you want to use lvm's so you
can extend later, this is what you will have to do :
1) lvcreate -n var -L 50G VolGroup00 — This will create a new
lvm of 50G (pick what ever you want the new /var to be.
2) mk2efs -j /dev/VolgGroup00/var — format the drive
3) mkdir /newvar (make a new temporary mount point)
4) mount /dev/VolgGroup00/var /newvar --test to maek sure the drive
is working and all that stuff.
Now comes the tricky part. You need to reboot the machien into single
user mode (edit inittabl and put a 1 for the run level or disrupt the
boot cycle at grub and append a 1 to the boot line)
Once in single user mode do the following :
1) mount /dev/VolgGroup00/var /newvar mounts your new var
2) rsync -av /var/ /newvar this will copy all of /var into /newvar.
You need to do this in s. user mode so that /var is not being written
to.
3) edit /etc/fstab and chance /var's mount point to
/dev/VolgGroup00/var
4) reboot back into your usual run mode.
If anything here fails and you reboot and all hell breaks loose, you
can always go back into single user mode and change /var's mount point
back to the original disk. moving mount points does not delete data, it
just no longer points to that disk space.
Wayner
More information about the redhat-list
mailing list