Logical Volume Manager (lvm)

Monday, February 16, 2009 |


Quick LVM setup on a Debian/Ubunutu box
****************************************

puttalu:~# apt-get install lvm2 dmsetup

puttalu:~# fdisk -l


Disk /dev/sda: 80.0 GB, 80032038912 bytes

255 heads, 63 sectors/track, 9730 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes


Device Boot Start End Blocks Id System

/dev/sda1 1 12 96358+ 83 Linux

/dev/sda2 13 498 3903795 82 Linux swap / Solaris

/dev/sda3 499 1471 7815622+ 83 Linux

/dev/sda4 1472 9730 66340417+ 5 Extended

/dev/sda5 1472 9730 66340386 8e Linux LVM

puttalu:~#


puttalu:~# pvcreate /dev/sda5

Physical volume "/dev/sda5" successfully created

puttalu:~#


puttalu:~# vgcreate vg0 /dev/sda5

Volume group "vg0" successfully created

puttalu:~# pvdisplay /dev/sda5

--- Physical volume ---

PV Name /dev/sda5

VG Name vg0

PV Size 63.27 GB / not usable 0

Allocatable yes

PE Size (KByte) 4096

Total PE 16196

Free PE 16196

Allocated PE 0

PV UUID xwuXvV-1DYA-SuhM-87c9-QRju-PuRa-tlPf30


puttalu:~#

puttalu:~# lvcreate -L20G -nusrlv vg0

Logical volume "usrlv" created

puttalu:~#

puttalu:~# lvdisplay

--- Logical volume ---

LV Name /dev/vg0/usrlv

VG Name vg0

LV UUID FJu6pi-qOzW-1Pwf-Fz6u-PtUb-FWb4-w23LM7

LV Write Access read/write

LV Status available

# open 0

LV Size 20.00 GB

Current LE 5120

Segments 1

Allocation inherit

Read ahead sectors 0

Block device 254:0


puttalu:~# mkdir /usr/back

puttalu:~# mount -t ext3 /dev/vg0/usrlv /usr/back

puttalu:~#

puttalu:~# lvcreate -L40G -nvarlv vg0

Logical volume "varlv" created

puttalu:~#

puttalu:~# mkfs.ext3 /dev/vg0/varlv

mke2fs 1.40-WIP (14-Nov-2006)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

5242880 inodes, 10485760 blocks

524288 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=0

320 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


Writing inode tables: done

Creating journal (32768 blocks): done

Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 39 mounts or

180 days, whichever comes first. Use tune2fs -c or -i to override.

puttalu:~# mkdir /var/image

puttalu:~# mount -t ext3 /dev/vg0/varlv /var/image

puttalu:~#

puttalu:~# lvdisplay

--- Logical volume ---

LV Name /dev/vg0/usrlv

VG Name vg0

LV UUID FJu6pi-qOzW-1Pwf-Fz6u-PtUb-FWb4-w23LM7

LV Write Access read/write

LV Status available

# open 1

LV Size 20.00 GB

Current LE 5120

Segments 1

Allocation inherit

Read ahead sectors 0

Block device 254:0


--- Logical volume ---

LV Name /dev/vg0/varlv

VG Name vg0

LV UUID 0V2BDl-Sra5-GFgI-6zGN-Uy7u-pzAs-7ZDfVC

LV Write Access read/write

LV Status available

# open 1

LV Size 40.00 GB

Current LE 10240

Segments 1

Allocation inherit

Read ahead sectors 0

Block device 254:1


puttalu:~# df -h /var/image

Filesystem Size Used Avail Use% Mounted on

/dev/mapper/vg0-varlv

40G 177M 38G 1% /var/image

/dev/mapper/vg0-usrlv

20G 173M 19G 1% /usr/back

puttalu:~#

0 comments:

Post a Comment