Reg: Convert normal partition to lvm

Thomas Fess dfezz1 at yahoo.com
Thu May 7 20:43:13 UTC 2009


Yes, but / or your root dir is very tricky, better to only convert /tmp, /home, /var and /usr and only if those filesystems are separated and are not all under you root "/" filesystem.

These steps make a lot of assumptions and you will need to make sure you have the data backed-up, i in no way support or stand by these steps...they have worked for me.  RHEL4.6 update 6 or 7 

Here is a document that wrote on the subject.  If you write me personally I will send you the word doc with graphics and screen shots.

####################################################################
Steps to move /tmp, /home and /var partitions into the new hard disk by using LVM (Logical Volume Management)


•	Shutdown the server.

•	Insert 2 additional hard disks into the server.

•	Start the server

•	Press “F” to load and save new configurations.

For Ex:

•	Virtualdisk 0
•	Virtualdisk 1

To ensure which HDD is new one by using the command “fdisk -l” and “inq”

In the below example, /dev/sdc is the new one.
 

Please take the backup before doing this activity

To create the LVM in the new hard disk

There are 2 steps to create LVM by using

•	LVM commands ( pvreate, vgcreate,lvcreate)

•	LVM GUI Tool from X windows

Herewith enclosed LVM partition details

Volume Group Name	RootVG		
			
LV Name	Temporary mount point	Actual Mount Point	Size
tmplv	/mnt/newtmp	/tmp	5 GB
homelv	/mnt/newhome	/home	5 GB
varlv	/mnt/newvar	/var	3 GB









Please check the total used disk space of each partition before allocating space into LVM

# cd /
# cd /home/
# du -sh
6.5G    .
# cd /var/
# du -sh
222M    .
# cd /tmp/
# du -sh
1.8M    .

Herewith enclosed steps to create LVM by using command (we are assuming the hard disk drive is /dev/sdc

Delete the existing partitions if any and create the partition with a system type “8e 
( Linux LVM) by using fdisk

# fdisk -l /dev/sdc

Disk /dev/sdc: 72.7 GB, 72746008576 bytes
255 heads, 63 sectors/track, 8844 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1        8845    71041023+  8e  Linux LVM





























•	To Create LVM by using  LVM GUI Tool from X windows


•	Start ->Applications  System settings  Logical Volume Management

 

Create the Physical volume then create Volume Group 

 







To create LV

 

# vgdisplay

Then, go to  “Drop to single-user mode” step


















•	To Create LVM by using LVM commands

# pvcreate /dev/sdc1

# pvdisplay

  --- Physical volume ---
  PV Name               /dev/sdc1
  VG Name               RootVG
  PV Size               67.75 GB / not usable 32.00 MB
  Allocatable           yes
  PE Size (KByte)       32768
  Total PE              2167
  Free PE               1783
  Allocated PE          384
  PV UUID               mq8ju2-Tw6W-lmnT-ODYe-rqvh-A6qK-wOzhMl

# vgcreate RootVG /dev/sdc1

# vgdisplay

  --- Volume group ---
  VG Name               RootVG
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  5
  VG Access             read/write
  VG Status             resizable
  MAX LV                256
  Cur LV                3
  Open LV               3
  Max PV                256
  Cur PV                1
  Act PV                1
  VG Size               67.72 GB
  PE Size               32.00 MB
  Total PE              2167
  Alloc PE / Size       384 / 12.00 GB
  Free  PE / Size       1783 / 55.72 GB
  VG UUID               Y5DDBI-YZ0I-E8ef-Z2JQ-Lv1C-LMiH-G4AWZT

# vgscan

  Reading all physical volumes.  This may take a while...
  Found volume group "RootVG" using metadata type lvm2







# lvcreate --name varlv --size 3G RootVG
# lvcreate --name homelv --size 2G RootVG
# lvcreate --name tmplv --size 4G RootVG



# lvdisplay

  --- Logical volume ---
  LV Name                /dev/RootVG/varlv
  VG Name                RootVG
  LV UUID                yVsHGM-fouY-feIT-u0LR-NlPE-V74g-tP5bOq
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                2.00 GB
  Current LE             64
  Segments               1
  Allocation             inherit
  Read ahead sectors     0
  Block device           253:0

  --- Logical volume ---
  LV Name                /dev/RootVG/homelv
  VG Name                RootVG
  LV UUID                79Rn6c-FT8u-YbuX-FHkX-IGP3-rGQl-LESt5p
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                8.00 GB
  Current LE             256
  Segments               2
  Allocation             inherit
  Read ahead sectors     0
  Block device           253:1

  --- Logical volume ---
  LV Name                /dev/RootVG/tmplv
  VG Name                RootVG
  LV UUID                3Zud73-RJJF-BYfw-cFLi-nlve-83PX-03Wo4h
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                2.00 GB
  Current LE             64
  Segments               1
  Allocation             inherit
  Read ahead sectors     0
  Block device           253:2








# lvscan

  ACTIVE            '/dev/RootVG/varlv' [2.00 GB] inherit
  ACTIVE            '/dev/RootVG/homelv' [8.00 GB] inherit
  ACTIVE            '/dev/RootVG/tmplv' [2.00 GB] inherit



# mkfs.ext3 /dev/RootVG/homelv
# mkfs.ext3 /dev/RootVG/tmplv
# mkfs.ext3 /dev/RootVG/varlv

# mkdir /mnt/newhome /mnt/newvar /mnt/newtmp

# mount /dev/RootVG/homelv /mnt/newhome
# mount /dev/RootVG/tmplv /mnt/newtmp
# mount /dev/RootVG/varlv /mnt/newvar



•	Drop to single-user mode

Entering single-user mode
# init 1

Change directories to /home and copy files

# cd /home
# cp -ax * /mnt/newhome

Moving the directory
# cd /
# mv /home /old.home
# mkdir /home
# umount /dev/RootVG/homelv
# mount /dev/RootVG/homelv /home

Change directories to /home and copy files

# cd /tmp
# chmod 1777 /mnt/newtmp
# cp -ax * /mnt/newtmp

Moving the /tmp directory
# cd /
# mv /tmp /old.tmp
# mkdir /tmp
# chmod 1777 /tmp
# umount /dev/RootVG/tmplv
# mount /dev/RootVG/tmplv /tmp







Change directories to /var and copy files

# cd /var
# cp -ax * /mnt/newvar

Moving the /var directory
# cd /
# mv /var /old.var
# mkdir /var
# umount /dev/RootVG/varlv
# mount /dev/RootVG/varlv /var




Editing fstab

Before change

/dev/RootVG/varlv             /mnt/newvar    ext3    defaults        1 2
/dev/RootVG/homelv            /mnt/newhome   ext3    defaults        1 2
/dev/RootVG/tmplv             /mnt/newtmp    ext3    defaults        1 2

After change

/dev/RootVG/varlv               /var            ext3    defaults        1 2
/dev/RootVG/homelv              /home           ext3    defaults        1 2
/dev/RootVG/tmplv               /tmp            ext3    defaults        1 2


# init 3

# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sdb3             20641788  14965092   4628056  77% /
/dev/sdb7              5162796   1975052   2925488  41% /asm
/dev/sdb1               101086     13811     82056  15% /boot
none                  16445284         0  16445284   0% /dev/shm
/dev/sdb2             20641788   4106260  15486888  21% /oracle
/dev/sdb6              5162796   1432604   3467936  30% /usr/openv
/dev/mapper/RootVG-varlv
                       2064208    262724   1696628  14% /var
/dev/mapper/RootVG-homelv
                       8256952   6830976   1006560  88% /home
/dev/mapper/RootVG-tmplv
                       2064208     37748   1921604   2% /tmp


•	Reboot the server to verify the changes 
####################################################################

--- On Thu, 5/7/09, Kannan, Mouli <Mouli.Kannan at tui-infotec.com> wrote:

> From: Kannan, Mouli <Mouli.Kannan at tui-infotec.com>
> Subject: Reg: Convert normal partition to lvm
> To: redhat-list at redhat.com
> Date: Thursday, May 7, 2009, 5:43 AM
> Hi,
> 
> Could you please tell me IS it possible to convert normal
> partion to LVM
> pation in redahat wihotut data loss on existing volume?
> 
> 
> Thanks,
> Mouli N
> --
> redhat-list mailing list
> unsubscribe mailto:redhat-list-request at redhat.com?subject=unsubscribe
> https://www.redhat.com/mailman/listinfo/redhat-list
> 


      




More information about the redhat-list mailing list