[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-users] Mass LVM VBD script for DomU creation



That will teach me to hit send too quick, remove the 'echo' from each of the lines in order for it to actually do things, as it stands the script will just spit out the command's it would have run

Tristram Cheer wrote:

Hi everybody,

After going through and makeing 20 LV's in LVM and formatting them etc etc getting ready to deploy 20 DomU's i've made a very basic script to configure LVM and format the drives for a bunch of servers at once. Thought i would share it with the list, i know its nothing great but it saved me a bunch of time

--------------------------------------------------------------------------------------------------
#!/bin/bash
# Creates LV in LVM for Server List
# Written By Tristram Cheer

#Create the PV on the drive
echo pvcreate '/dev/'$1

# Create the VG on the PV
echo vgcreate 'vg-'$1 '/dev/'$1

#Create the LV for the root filesystem and swap filesystem and format them both
for server in `cat serverlist`
do
echo lvcreate '-L'$2'M' -n $server 'vg-'$1
echo lvcreate '-L'$3'M' -n $server'-swap' 'vg-'$1
echo mkfs.ext3  '/dev/vg-'$1'/'$server
echo mkswap '/dev/vg-'$1'/'$server'-swap'
done

exit 0
--------------------------------------------------------------------------------------------------

save that bash script in a folder somewhere and create a file in the same folder called 'serverlist' in that file list all the names of the servers you want to make, 1 to each line.
Then you can run the script like so
./mass-lvm-domu-create.sh sda 2252 512

Where sda is the disk you are using for teh LVM, 2552 is the size in megabytes of the root volume and 512 is the size of the Swap partition.

Beware this assumes you are starting from scratch, it will create the PV and VG on the drive you specifiy etc etc, those that cant read what the script does from the code shouldnt really use it.

USE AT OWN RISK.

- Tristram Cheer


_______________________________________________
Xen-users mailing list
Xen-users@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-users




_______________________________________________
Xen-users mailing list
Xen-users@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-users


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.