Archive for the ‘lvm’ Category.

LVM volgroup creation Debian etch 4.0

I’ve just upgraded my home media server, and had to set up LVM again, and as i do it so infrequently, i completely forgot what i was doing… so i thought I’d make some notes:

We are going to set up a LVM across two drives, identical 750GB sata disks (sda & sdb), then format it with the jfs file system, which is arguably the best for large (>1GB) files. xfs is also a suitable file system, but ext3 is really slow. in fact I’m surprised anyone uses it at all any more, as reiser is much better for a system partition. Justin Piszcz has the figures to prove it.

First we need to install LVM and JFS suppport:

 apt-get install jfsutils lvm2 lvm-common

Initialise the drives with cfdisk (fdisk is buggy and shouldn’t be used. If you need bsd support or stuff cfdisk can’t do then use sfdisk which is the best in terms of compatibility, but cfdisk is good at what it supports and the interface is nicer).
Create a single partition filling the whole disk. I chose the standard type for linux, 82, & it seemed to work OK, but I did notice that there is a specific type for LVM’s (8E), That may be a better choice. I’ll look into it and let you know.

now initialise the disks to LVM. this can be done to a partition instead of the whole disk, just use /dev/sda# instead of /dev/sda

pvcreate  /dev/sda
pvcreate /dev/dsb

if you get errors you can wipe the disk with
*CAUTION*

dd if=/dev/zero of=/dev/sd# bs=1k count=1

Now create the VolGroup

vgcreate VG_Data /dev/sda /dev/sdb

you can add to an existing volgroup with

vgextend VG_Data /dev/sdc

now initialise the volgroup

vgchange -a y VG_Data

use vgdisplay to see your shiny new volgroup, and note how many extents it has (Total PE):

vgdisplay

Create a logical volume on the volgroup:

lvcreate -l[number of extents] -i[PV's to strip over] -I[stripe size, 32/64/128] -n[name] [VolGroup]

in my case

lvcreate -l357702 -i2 -I128 -ndata VG_Data

check to see the utilisation with vgdisplay, you can extend the logical vol with lvextend:

lvextend -L+2.4G /dev/VG_Data/data

now format the new volume:

mkfs.jfs /dev/VG_Data/data

And that’s it, mount and play:

mkdir /mnt/data
mount -tjfs /dev/VG_Data/data /mnt/data