donderdag 7 oktober 2010

Logical Volume Manager and one big volume with multiple disks


How to create one big LVM with multiple disks

NFS Storage

REMEMBER: If you want to create LVM on the rootdisk you
should install LVM from scratch. You cannot convert the
bootdisk without creating a temporary disk. You can
resize the partition but there must be more than half of
free space and you need to boot into single user mode!!!!
The storage that we added to a Fedora 8 machine is
attached to the SCSI bus. We put a SCSI controller
in the machine and attached some SCSI storage to
the machine.
We want to make this storage accessible through the NFS
environment so that VMware and Unix machines can access it
Mainly for test purposes so the storage is Read Write for all!
The disks:
/dev/sdb, /dev/sdc, /dev/sdd are 18 GB disks
/dev/sde, /dev/sdf are 34 GB disks

FDISK actions

The disks were used by other OSes so first I deleted the partition
using fdisk
storage# fdisk /dev/sdb

The number of cylinders for this disk is set to 34732.
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)
1
d = delete partition
Selected partition 1
w = write
q = quit
 
Repeat this for all disks
 

Logical Volume Manager actions

storage# pvcreate /dev/sdb

Repeat this for all disks
We create a volume group called vg storage# vgcreate vg /dev/sdb You can add all the devices to this command :
vgcreate vg /dev/sdb /dev/sdc /dev/sdd ...
but I will show you how to extend
With this method you can always add disks to the
volume group
storage# lvcreate vg --size 18G

Logical volume "lvol0' created The size may vary due to the block size and administration
that LVM puts on the disk
So it could be that you can only allocate 17 or 16 GB
Check the device path, the /dev/vg is the volume group and
the lvol0 is the logical volume : 
storage# ls /dev/vg/lvol0
Make a file system on it: 
storage# mkfs -t ext3 -v /dev/vg/lvol0
Mount it: 
storage# mkdir -p /mnt/storage

storage# mount /dev/vg/lvol0 /mnt/storage
storage# touch /mnt/storage/hello
storage# ls /mnt/storage/*
hello lost+found
Now extend the volume group with an extra disk
 storage# vgextend vg /dev/sdc

storage# lvextend /dev/vg/lvol0 --size 36G 
The lvextend command needs the storage amount after
the extend. So if the first was 18 GB and we add another 18 GB
it will become 36 ... etc.. for all the rest of the disks
The filesystem needs to grow with it: (or shrink in the case reduction)
 storage# resize2fs /dev/vg/lvol0

Check the size of the disk:
 storage# df -k

Add the export to NFS

storage# vi /etc/exports

/mnt/storage    *(rw,sync,no_root_squash,insecure)
And run the nfs server:
 storage# /etc/init.d/nfs restart


Geen opmerkingen:

Een reactie posten