LVM(Logical Volume Manager) is a method of allocating hard drive space into logical volumes that can be easily resized instead of partitions.

1.Create a partition Linux LVM type.
2.Inform the OS of partition table changes.
3.Create a Physical Volume (LMV).
4.Create a Volume Group using these Physical Volumes.
5.Create a Logical Volume from this Volume Group.
6.Format Volume Group.
7.Mount Volume Group.
1.Create a partition Linux LVM type.
[root@sys80 ~]# fdisk /dev/sda
The number of cylinders for this disk is set to 60801.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): p
Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 6374 51199123+ 83 Linux
/dev/sda2 6375 6948 4610655 82 Linux swap
/dev/sda3 6949 13028 48837600 83 Linux
/dev/sda4 13029 19108 48837600 5 Extended
/dev/sda5 13029 19108 48837568+ 8e Linux LVM
[root@sys80 ~]# fdisk /dev/sdb
The number of cylinders for this disk is set to 19457.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): p
Disk /dev/sdb: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-19457, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-19457, default 19457): +50G
Command (m for help): p
Disk /dev/sdb: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 6080 48837568+ 83 Linux
Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)
Command (m for help): p
Disk /dev/sdb: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 6080 48837568+ 8e Linux LVM
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
2.Inform the OS of partition table changes.
[root@sys80 ~]# partprobe
[root@sys80 ~]# cat /proc/partitions
major minor #blocks name
8 0 488386584 sda
8 1 51199123 sda1
8 2 4610655 sda2
8 3 48837600 sda3
8 4 0 sda4
8 5 48837568 sda5
8 16 156290904 sdb
8 17 48837568 sdb1
3.Create a Physical Volume (LMV).
[root@sys80 ~]# pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created
[root@sys80 ~]# pvcreate /dev/sda5
Physical volume "/dev/sda5" successfully created
4.Create a Volume Group using these Physical Volumes.
[root@sys80 ~]# vgcreate vg0 /dev/sdb1 /dev/sda5
Volume group "vg0" successfully created
5.Create a Logical Volume from this Volume Group.
[root@sys80 ~]# lvcreate -L 3048M -n data vg0
Logical volume "data" created
[root@sys80 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 49G 7.8G 38G 18% /
none 1.5G 0 1.5G 0% /dev/shm
/dev/sda3 46G 32M 43G 1% /db
6.Format Volume Group.
[root@sys80 ~]# mkfs.ext3 /dev/vg0/data
mke2fs 1.35 (28-Feb-2004)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
390144 inodes, 780288 blocks
39014 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=801112064
24 block groups
32768 blocks per group, 32768 fragments per group
16256 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 29 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
7.Mount Volume Group.
[root@sys80 ~]# mkdir /oracle
[root@sys80 ~]# mount /dev/vg0/data /oracle
[root@sys80 ~]# mount
/dev/sda1 on / type ext3 (rw)
none on /proc type proc (rw)
none on /sys type sysfs (rw)
none on /dev/pts type devpts (rw,gid=5,mode=620)
usbfs on /proc/bus/usb type usbfs (rw)
none on /dev/shm type tmpfs (rw)
/dev/sda3 on /db type ext3 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
/dev/mapper/vg0-data on /oracle type ext3 (rw)
[root@sys80 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 49G 7.8G 38G 18% /
none 1.5G 0 1.5G 0% /dev/shm
/dev/sda3 46G 32M 43G 1% /db
/dev/mapper/vg0-data 3.0G 37M 2.8G 2% /oracle

No comments:
Post a Comment