You are on page 1of 4

EXAMPLES The basic steps to take to begin using LVM are as follows: + + + + + Identify the disks to be used for

LVM. Create an LVM data structure on each identified disk (see pvcreate(1M)). Collect all the physical volumes to form a new volume group (see vgcreate(1M)). Create logical volumes from the space in the volume group (see lvcreate(1M)). Use each logical volume as if it were a disk section (create a file system, or use for raw access).

To configure disk /dev/dsk/c0t0d0 as part of a new volume group named vg01. First, initialize the disk for LVM with the pvcreate command. pvcreate /dev/rdsk/c0t0d0 Then, create the pseudo device file that is used by the LVM subsystem. mkdir /dev/vg01 mknod /dev/vg01/group c 64 0x030000 The minor number for the group file should be unique among all the volume groups on the system. It has the format 0xNN0000, where NN ranges from 00 to 09. The maximum value of NN is controlled by the kernel tunable parameter, maxvgs. Create the volume group, vg01, containing the physical volume, /dev/dsk/c0t0d0, with the vgcreate command. vgcreate /dev/vg01 /dev/dsk/c0t0d0 You can view information about the newly created volume group with the vgdisplay command. vgdisplay -v /dev/vg01 Create a logical volume of size 100 MB, named usrvol, on this volume group with the lvcreate command. lvcreate -L 100 -n usrvol /dev/vg01 This creates two device files for the logical volume, /dev/vg01/usrvol, which is the block device file, and /dev/vg01/rusrvol, which is the character (raw) device file. You can view information about the newly created logical volume

with the lvdisplay command. lvdisplay /dev/vg01/lvol1 Any operation allowed on a disk partition is allowed on the logical volume. Thus, you can use usrvol to hold a file system. newfs /dev/vg01/rusrvol mount /dev/vg01/usrvol /usr --------------------------------------------------------------------------------------------------------------------------------------------------------------1. create device special files insf -e 2. Create physical volumes that LVM can use check if the disk is already in lvm strings /etc/lvmtab | grep '/dev/dsk' | grep dskname Ex:strings /etc/lvmtab |grep "/dev/dsk" |grep c1t2d3 check disktype: Ex: diskinfo /dev/rdsk/c1t2d0 SCSI describe of /dev/rdsk/c1t2d0: vendor: EMC product id: SYMMETRIX type: direct access size: 8838720 Kbytes bytes per sector: 512 Create physical volume that LVM can use: pvcreate [-f] characterdisk Ex: pvcreate -f /dec/rdsk/c1t2d0 3. Create volume group check the existing volume group Ex: strings /etc/lvmtab |grep vg mkdir /dev/vg02 cd /dev/vg02 mknod group c 64 0x${vgnum}0000 Ex:mknod group c 64 0x0230000 vgcreate -p 30 vgname disks vgcreate -p 30 /dev/vg02 /dev/dsk/c1t2d0 /dev/dsk/c1t3d0 4. Delete voulme group remove disk from volume group vgreduce volumegroup disk Ex: vgreduce /dev/vg02 /dev/dsk/c1t2d0 remove volume group Ex: vgremove /dev/vg02

rm -r /dev/vg02 -------------------------------------------------------------------------------------------------------------------Create File System On HP 1. check free space: vgdisplay vgdisplay volumegroup Ex: vgdisplay vg01 2. Create logical volume: lvcreate lvcreate -L sizeinMB -n filesystemname volumegroupname Ex: lvcreate -L 3500 -n u01 /dev/vg01 3. Create file system: newfs newfs -F filetype -o options rawdevicename Ex: newfs -F vxfs -o largefiles /dev/vg01/ru01 4. Create dir: mkdir mkdir mountpoint Ex: mkdir /u01 5. Add file system to /etc/fstab: vi logicalvolume directory filesystem options Ex: /dev/vg01/u01 /u01 vxfs largefiles,delaylog 0 2 6. Change owner of mount point: chown chown -R owner:group dir Ex: chown -R oracle:install /u01 Extend file system on HP 1. Stop all processes using logical volumes: fuser fuser logicalvolumes Ex: fuser /u01 or get into single user mode 2. Extend logical volume: lvextend lvextend -L newtotalsizeinMB LogicalVolume Ex: lvextend -L 5000 /dev/vg01/u01 3. Umount the file system: umount umount filesystem Ex: umount /u01 4. Extend the file system: extendfs extendfs rawdevice Ex: extendfs /dev/vg01/ru01 5. Mount the file system: mount mount filesystem Ex: mount /u01 Remove filesystem on HP 1. umount file system: umount umount filesystem

Ex: umount /u02 2. Remove logical volumn: lvremove lvremove -f logicalvolname Ex: lvremove -f /dev/vg01/u02 3. Remove mount point: rmdir rmdir mountpoint Ex: rmdir /u02 -------------------------------------------------------------------------------------------------------------------swap: lvcreate -L $needed -n moreswap -C y /dev/$vgname echo /dev/$vgname/moreswap / swap defaults 0 0 >>/etc/fstab swapon -a

You might also like