Archive for the ‘Linux Stuff’ Category

LVM on ubuntu

Friday, September 4th, 2009

Ok, here we are, a ftp server has no more space on its 1 To /home mounted drive… we don’t know what take so much place, but now the idea is to put another 1To drive to have a bigger /home.

No choice, LVM to create a new 2To partition, and mount this on a brand new /home where I’ll have to copy old 1To home. It’s not so hard to find what to do, but as always under linux, nothing go well at the first time.

After rebooting the machine, the old /home sdc1 does not work.  Then juste before panic, I see that my colleague changed the order of drive on sata controllers, and the old sdb1 was now sdc1.
I just change the /etc/fstab mount device for the old /home and everything went ok and it’s 1To of precious data not lost…

Ok, so start building the logical volume with the 2 new drives sdb and sdd:

fdisk /dev/sdb, v to display status, o to create msdos partition table, and v to see display again, q for quit

fdisk /dev/sdd, v to display status, o to create msdos partition table, and v to see display again, q for quit

Then I have my devices sdb1 and sdd1, I can create physical volumes:

pvcreate /dev/sdb1
pvcreate /dev/sdd1
pvdisplay confirms that

Now let’s create and activate the volume group:
vgcreate memnonhome /dev/sdb1 /dev/sdd1
vgchange -a y memnonhome
vgdisplay to confirm the volume group.

As I did’nt find a way to take all the available space with lvcreate, I used the size value given by the vgdisplay to do
lvcreate -L1829G -nHomeLV memnonhome

and then

mkfs.ext3 /dev/memnonhome/HomeLV which has created the partition correctly.

After few modification in the /etc/fstab, I mounted the old home in /oldhome, and the /dev/memnonhome/HomeLV in /home.

Just have to run a last copy with the -p option to preserve owners rights etc…
Ok, so few preparation, and so lucky to make it work in 1h…cool…Again google and other blog save my life.