WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-users

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

To: xen-users@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-users] Mass LVM VBD script for DomU creation
From: Tristram Cheer <tristram@xxxxxxxxxxxxx>
Date: Thu, 29 Dec 2005 19:54:28 +1300
Delivery-date: Thu, 29 Dec 2005 06:57:31 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-users-request@lists.xensource.com?subject=help>
List-id: Xen user discussion <xen-users.lists.xensource.com>
List-post: <mailto:xen-users@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-users>, <mailto:xen-users-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-users>, <mailto:xen-users-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-users-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mozilla Thunderbird 1.0.7 (Windows/20050923)
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

<Prev in Thread] Current Thread [Next in Thread>