Wednesday, July 23, 2008

lvm how to cool

2) drive 2 setup as lvm!

fdisk /dev/sda
(use full disk) setup /dev/sda1 type 8e
pvcreate /dev/sda1
sets up the drive to be a physical volume
vgcreate lvm-vol /dev/sda1
sets up the volume group on the drive(s)
(could do vgcreate lvm-vol /dev/sda1 /dev/sdb1)
lvcreate -n 2005-big1 --size 221g lvm-vol
mkfs.ext3 /dev/lvm-vol/2005-big1

lvcreate -n 2005-big0 --size 221g lvm-vol
mkfs.ext3 /dev/lvm-vol/2005-big0

a) mount on machine
b) copy data to two partions

now can mount them all in raid-mount-script

how to do adjust and expand size of a partitions

what can do to find out:


How to expand?

umount /dev/lvm-vol/2005-big0
lvextend -L+100g /dev/lvm-vol/2005-big0
e2fsck -f /dev/lvm-vol/2005-big0
resize2fs /dev/lvm-vol/2005-big0

now we are expanded

Other commands?

lvremove kills contents
lvrename to renam
lvreduce make smaller
lvextend to make bigger

/etc/lvm/archive has list of commands performed on my machine!

How to move a volume group to another machine?
(call the volume group lvm1 say)
1) unmount file system say we have ie the logical volume 2006-data on the volume group lvm1
umount /dev/lvm1/2006-data

2) mark volume group inactive
vgchange -an lvm1

3) export from old system
vgexport lvm1

4) plug into new computer

5) pvscan to identify it

6) vgimport lvm1

7) mount /dev/lvm1/2006-data /mnt

You forgot to export from old system?
Then you try vgimport and get an error message

"Volume group "lvm1" is not exported"
??? what to do????

vgchange -ay lvm1
will activate the volume even though was not exported

vgscan will identify that it exists:
will indicate

--- Logical volume ---
LV Name /dev/lvm1/2006-big0
VG Name lvm1
LV UUID BZCkFH-MjH1-LS5r-giPN-g4GF-yiat-wCGtaC
LV Write Access read/write
LV Status available
# open 0
LV Size 359.00 GB
Current LE 91904

Now you can mount it
mount /dev/lvm1/2006-big0 /home/big0
and you are done.

? how to automatically mount it on the machine.

1. Problem just putting it in the /etc/fstab
it seems not to find it if I just put
/dev/lvm1/2006-big0 /mnt ext3
in the /etc/fstab
I get a hang during boot up.
2. Howrver this works: Create a perl boot script
that does
system("mount /dev/lvm1/2006-big0 /mnt");
runs fine;

? why does the output of the command look like
df -h
/dev/mapper/lvm1-2006--big0 354G 348G 5.8G 99% /mnt

when I did mount /dev/lvm1/2006-big0 /mnt?
what is meaning of /dev/mapper
what is meaning of the extra "-" dashes in the /dev/mapper/ name???

now what to put in the /etc/fstab to get it all to work???

Best sources:

No comments: