Google Site SearchFN Site Search FN Blog Login FN Blog Login
Site Navigation:
 
 

HOWTO Add a Disk to an LVM Managed Root Directory

by Andrew W. Donoho on Sep 14, 2004

Introduction

I currently use LVM on my root directory because I want to be able to add drives to the system without having to move data around and set up different mount points. My boot disk has three partitions on it - /boot on /dev/hda1, swap on /dev/hda2 and / (root) on /dev/Volume00/LogVol00 (/dev/hda3). Volume00 and LogVol00 are the default names given to an LVM managed partition by DiskDruid on FC2.

Since I chose to use LVM to make it easier to add hard drives, I wanted to see if lvm works as advertised by adding an 80 GB drive from an older system onto my new server. The drive will be attached as the physical device: /dev/hdd.

The Recipe

The following commands are done as either root or with a prepended sudo. Later in the process when you boot off of the install CD, you will be root. Furthermore, this recipe was developed on an FC2 x86-64 system. I have not replicated it on an Intel 32 bit system. I doubt that there are any differences.

Add the hard drive to your system (/dev/hdd) and reboot.

Partition your new disk with 'fdisk /dev/hdd', then:
	delete old partitions (d command)
	create primary partition 1 (n command), 
		whole disk (defaults for start and end)
	Set partition type to Linux LVM (0x8e) (t command)
	write it out (w)

Type the following commands (lines with a # are comments):

# Create the physical volume.
pvcreate /dev/hdd1

# Make it part of your existing volume group.
vgextend Volume00 /dev/hdd1

# Extend the logical volume to use all of the volume group's space.
lvextend /dev/Volume00/LogVol00 /dev/hdd1

# Reboot with your FC2 install CD. 
#	Type 'linux rescue' at the boot prompt. 
#	Do not mount the filesystem, not even read-only.

# Make the volume group available.
lvm vgchange -a y Volume00

# Make the logical volume available.
lvm lvchange -a y /dev/Volume00/LogVol00

# Doublecheck that the volume format is OK.
e2fsck -f /dev/Volume00/LogVol00

# Resize the file system to use all of the space in the logical volume.
resize2fs /dev/Volume00/LogVol00

# Reboot without the install CD and enjoy your new disk space.