Sunday, January 16, 2011

Quick Tips (LVM)

1. TO CREATE LVM

1.fdisk /dev/sda   ->create 3 partitions + label to 8e
2.partprobe
3.fdisk -l
4.pvcreate /dev/sda8 /dev/sda9
5.pvdisplay /dev/sda8
6.pvdisplay /dev/sda9
7.vgcreate vg0 /dev/sda8 /dev/sda9
8.vgdisplay
9.lvcreate -L +200M -n /dev/vg0/home1
10.lvdisplay /dev/vg0/home1
11.lvcreate -L +300M -n /dev/vg0/var1
12.lvdisplay /dev/vg0/var1
13.mkfs.ext3 /dev/vg0/var1
14 mkfs.ext3 /dev/vg0/home1
15.mkdir /home1
16.mkdir /var1
17.mount /dev/vg0/home1 /home1
18.mount /dev/vg0/var1 /var1
19.cp /etc/a* /home1
20.cp /etc/b* /var1
21.vim /etc/fstab
22.mount -a

TO EXTEND LVM

1.lvdisplay /dev/vg0/home1
2.lvextend -L +200M /dev/vg0/home1
3.ls /home1
4.resize2fs /dev/vg0/home1
5.ls /home1

TO REDUCE LVM

1. lvdisplay
2. umount /var1
3. e2fsck -f /dev/vg0/var1
4. resize2fs /dev/vg0/var1 100M
5. lvreduce -L -100M -n /dev/vg0/var1
6. mount /dev/vg0/var1 /var1
7. df -h

LVM SNAPSHOT

1.  lvcreate  -L 200M -s -n lv2 /dev/llc/lv1

TO EXTEND PV
1.pvcreate /dev/sda10
2.pvdisplay
 
TO EXTEND VG
1.vgextend vg0 /dev/sda10
2.vgdisplay vg0

TO REDUCE VG
1.vgreduce vg0 /dev/sda10
2.vgdisplay

TO REDUCE PV
1.pvremove /dev/sda10
2.pvdisplay

REMOVE LVM
1.lvdisplay
2.umount /dev/vg0/home1
3.umount /dev/vg0/var1
4.vim /etc/fstab
5.lvremove /dev/vg0/home1
6.lvremove /dev/vg0/var1
7.lvdisplay

REMOVE VG
1.vgdisplay
2.vgremove /dev/vg0
3.vgdisplay

REMOVE PV
1.pvdisplay
2.pvremove /dev/sda9
3.pvremove /dev/sda8

1 comment: