LVM

From Wsms

Jump to: navigation, search

Contents

Linux LVM

LVM is the default for some recent Linux distros

If you do an default install of CentOS 5, then boot with knoppix and do fdisk, you may see something like this:

Disk /dev/sda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        1044     8281507+  8e  Linux LVM

create an LVM maunally

This setup is similar to what you would get by installing CentOS 5 with the default disk configuration. I booted hayes using a Knoppix 5.1.1 CD-ROM.

root@Knoppix:~# fdisk -l
Disk /dev/hda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1   *           1          13      104391   83  Linux
/dev/hda2              14        9729    78043770   8e  Linux LVM
root@Knoppix:~# pvcreate /dev/hda2^M
  Physical volume "/dev/hda2" successfully created
root@Knoppix:~# vgcreate VolGroup00 /dev/hda2
  Volume group "VolGroup00" successfully created
root@Knoppix:~# lvcreate -L70G -n LogVol00 VolGroup00
  Logical volume "LogVol00" created
root@Knoppix:~# lvcreate -L1G -n LogVol01 VolGroup00
  Logical volume "LogVol01" created
root@Knoppix:~# mkswap /dev/VolGroup00/LogVol01
Setting up swapspace version 1, size = 1073737 kB
no label, UUID=1f26db8f-0614-4a13-a9eb-4182611ec24f
root@Knoppix:~# mke2fs -j /dev/VolGroup00/LogVol00
mke2fs 1.40-WIP (14-Nov-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
9175040 inodes, 18350080 blocks
917504 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
560 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
        4096000, 7962624, 11239424

Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 31 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

Set up the partitions and logical volumes for a new system

root@Knoppix:/mnt# mke2fs /dev/hda1
...
root@Knoppix:/mnt# e2label /dev/hda1 /boot

Then you copy the data across the network using rsync -av ...

Redo grub-install...

commands for managing lvm

vgscan

vgscan scans for logical volume groups. For example:

[root@arthur ~]# vgscan
  Reading all physical volumes.  This may take a while...
  Found volume group "VolGroup00" using metadata type lvm2


vgchange

vgchange changes the status of volume groups. To change all volume groups to active:


[root@arthur ~]# vgchange -a y
  2 logical volume(s) in volume group "VolGroup00" now active

see also

http://tldp.org/HOWTO/LVM-HOWTO/index.html
CSI howto mount LVMs and copy files using Knoppix
lvextend
man vgscan
man vgchange
Personal tools