android (3)
ant (2)
beautifulsoup (1)
debian (1)
decorators (1)
django (9)
dovecot (1)
encryption (1)
fix (4)
gotcha (2)
hobo (1)
htmlparser (1)
imaplib (2)
java (1)
json (2)
kerberos (2)
linux (7)
lxml (5)
markdown (4)
mechanize (6)
multiprocessing (1)
mysql (2)
nagios (2)
new_features (3)
open_source (5)
optparse (2)
parsing (1)
perl (2)
postgres (1)
preseed (1)
pxe (4)
pyqt4 (1)
python (41)
raid (1)
rails (1)
red_hat (1)
reportlab (4)
request_tracker (2)
rt (2)
ruby (1)
scala (1)
screen_scraping (7)
shell_scripting (8)
soap (1)
solaris (3)
sql (2)
sqlalchemy (2)
tips_and_tricks (1)
twitter (2)
ubuntu (1)
vmware (2)
windows (1)
zimbra (2)

In the middle of last year, I had a short post detailing booting the ESXi installer. Tom recently asked how one would PXE boot and kickstart the ESX installer. This is not much different than any other Red Hat Kickstart. I am going to assume you already have a working PXE booting environment using pxelinux and a FTP server set up to host the install media plus kickstart configurations.

The first thing to do is copy the contents of the install media to a location on your FTP server. If you have the install media in ISO form, it is as easy as this:

mkdir /mnt/esxinstall
mount -o loop /path/to/esx.iso /mnt/esxinstall
cp -r /mnt/esxinstall /var/ftp/pub
umount /mnt/esxinstall
rm -r /mnt/esxinstall

Verify that you can navigate the contents via FTP on another machine before continuing. Now that the media is accessible, we need the kernel and initial ram disk to boot from pxelinux. You will find both in the contents of the install media, in images/pxeboot, with the names vmlinuz and initrd.img. Copy these files somewhere in your tftpboot directory like so:

cd /var/ftp/pub/esxinstall/images/pxeboot
cp vmlinuz initrd.img /var/lib/tftpboot/esx

Note that /var/lib/tftpboot is where tftpboot resides on Fedora 10, the distribution I am hosting everything in this example on. This may be different on your system. The next step is to make your kickstart configuration. The easiest way to get a starting point on this is to install ESX normally. After install, ESX stores a kickstart config based on the install in /root/anaconda-ks.cfg, like every other Red Hat derivative. ESX features some special kickstart options for VMware specific functions, like service console memory and virtual networking. Here is a minimal headless kickstart for ESX:

lang en_US.UTF-8
langsupport --default en_US.UTF-8
keyboard us
mouse genericwheelps/2 --device psaux
# DHCP if you are doing multiple
network --device eth0 --bootproto dhcp --addvmportgroup=1 --vlanid=0
rootpw this_is_too_easy
firewall --enabled
authconfig --enableshadow --enablemd5
timezone --utc America/Denver
bootloader --location=mbr
clearpart --exceptvmfs --drives=sda
part /boot --fstype ext3 --size=100 --ondisk=sda --asprimary
part / --fstype ext3 --size=1800 --grow --maxsize=5000 --ondisk=sda
part swap --size=544 --grow --maxsize=544 --ondisk=sda
part /var/log --fstype ext3 --size=500 --grow --maxsize=2000 --ondisk=sda
part local --size 1 --ondisk=sda --fstype vmfs2 --grow


# Put whatever commands you would like to run at the end here,
# Just like in other Kickstarts

Put your kickstart somewhere available from your FTP, like /var/ftp/pub/esxinstall/headless.cfg. For the final ordeal, we need to add a entry in pxelinux.cfg/default or similar, so our machines can PXE boot. Here is what it might look like:

label esx
  kernel esx/vmlinuz
  append initrd=esx/initrd.img ramdisk_size=7268  ksdevice=eth0 ip=dhcp \
    method=ftp://yourftpserver/esxinstall ks=ftp://yourftpserver/esxinstall/headless.cfg

This will give you headless installs. NOTE: Do not include the backslashes and line breaks in your append line of your pxelinux entry. These are only here for readability's sake. Here is an explanation of the append options.

  • ksdevice If you have multiple nics, you can tell anaconda which to use during the first install phase.
  • ip Tell anaconda how to configure networking for this install.
  • method = URL to your media.
  • ks = URL to your kickstart configuration.
Posted by Tyler Lesmann on March 14, 2009 at 15:59 and commented on 5 times
Tagged as: pxe red_hat vmware

If you are like me, then you want to use network booting for everything, especially installs. PXE booting the VMware installer with pxelinux is much easier than I thought it would be. First, copy the entire contents of the installer CD to your tftp directory. I copied mine to /tftpboot/esxi/3.5.

Now, open your pxelinux.cfg/default. Add this entry, changing the path to each of the components to coincide with where you placed the files within your tftp directory.

label esx35i
  kernel esxi/3.5/mboot.c32
  append esxi/3.5/vmkernel.gz --- esxi/3.5/binmod.tgz --- esxi/3.5/ienviron.tgz --- \
  esxi/3.5/cim.tgz --- esxi/3.5/oem.tgz --- esxi/3.5/license.tgz --- esxi/3.5/install.tgz

That's all you have to do.

You may also want to look at the post on PXE booting and kickstarting the ESX installer.

Posted by Tyler Lesmann on July 15, 2008 at 12:04 and commented on 2 times
Tagged as: pxe vmware

One of the things I do is give away older computers with Ubuntu on them. I've given away quite a few and the installs can take a while, plus I like to install flash and dvd decryption for the new users. I learned about preseed from this post. It didn't have all the information I needed to create this, so that is why I'm sharing my experience.

Preseed is Debian's/Ubuntu's answer to unattended installation. It will do everything for you, from partitioning to setting up users. You just need to create a text file, make it available, and tell the installer where it is. First, here is my preseed for ubuntu hardy.

### Network configuration
d-i netcfg/choose_interface select eth0
d-i netcfg/get_hostname string ubuntu

### Mirror settings
d-i mirror/country string enter information manually
d-i mirror/http/hostname string ftp.deathcat.dci
d-i mirror/http/directory string /ubuntu
d-i mirror/http/proxy string

### Partitioning
d-i partman-auto/init_automatically_partition
d-i partman-auto/disk string /dev/sda
d-i partman-auto/method string regular
d-i partman-auto/purge_lvm_from_device boolean true
d-i partman-auto/expert_recipe string boot-root :: 100 50 100 ext3 \
    $primary{ } \
    $bootable{ } \
    method{ format } \
    format{ } \
    use_filesystem{ } \
    filesystem{ ext3 } \
    mountpoint{ /boot } \
    . \
    512 512 200% linux-swap \
    method{ swap } \
    format{ } \
    . \
    512 10000 1024 reiserfs \
    method{ format } \
    format{ } \
    use_filesystem{ } \
    filesystem{ reiserfs } \
    mountpoint{ / } \
    . \
    512 10000 1024 reiserfs \
    method{ format } \
    format{ } \
    use_filesystem{ } \
    filesystem{ reiserfs } \
    mountpoint{ /tmp } \
    . \
    1000 10000 2000 reiserfs \
    method{ format } \
    format{ } \
    use_filesystem{ } \
    filesystem{ reiserfs } \
    mountpoint{ /var } \
    . \
    3000 10000 4000 reiserfs \
    method{ format } \
    format{ } \
    use_filesystem{ } \
    filesystem{ reiserfs } \
    mountpoint{ /usr } \
    . \
    100 10000 100000000 reiserfs \
    method{ format } \
    format{ } \
    use_filesystem{ } \
    filesystem{ reiserfs } \
    mountpoint{ /home } \
d-i partman/confirm_write_new_label boolean true
d-i partman/choose_partition \
    select Finish partitioning and write changes to disk
d-i partman/confirm boolean true

### Clock and time zone setup
d-i clock-setup/utc boolean true
d-i time/zone string America/Denver

### Installation setup
d-i prebaseconfig/reboot_in_progress note

d-i debconf/priority select critical
debconf debconf/priority select critical

base-config base-config/intro note
base-config base-config/login note

# The user's name and login.
passwd passwd/user-fullname string Ubuntu
passwd passwd/username string ubuntu
# And their password, but use caution!
passwd passwd/user-password ubuntu ubuntu
passwd passwd/user-password-again ubuntu ubuntu

# install desktop + standard packages
tasksel tasksel/first multiselect ubuntu-standard, ubuntu-desktop
d-i finish-install/reboot_in_progress note

# post install scripts
d-i preseed/late_command string \
    cd /target; \
    wget ftp://ftp.deathcat.dci/pub/ubuntu/scripts/post-install; \
    chmod +x ./post-install; \
    chroot ./ ./post-install; \
    rm -f ./post-install

A lot of stuff is in there as you can see. Let's look at the part under Network Configuration. The first line, d-i netcfg/choose_interface select eth0, tells the installer to use eth0 for networking during the install. This does absolute nothing during a PXE boot install, which is irratating if you are installing on to laptops with a wireless card. The next line, d-i netcfg/get_hostname string ubuntu, tells the install to give the new install the hostname ubuntu.

Now, to the Mirror settings section. This section tells the installer I want to manually set the location of the installer packages to http://ftp.deathcat.dci/ubuntu and not to use a proxy.

The Partitioning portion is the most perplexing. It was for me anyway. I like to set up several partitions, for /boot, swap, /, /var/, /usr, and /home. I also like to use reiserfs for speed. The first two lines tell the installer to automatically wipe /dev/sda and prepare to partition it. The next line tells it to use regular partitions opposed to lvm and after that is installer is told to not warn when deleting an lvm. Now, for the meat and potatoes of the partition. This one line (Yes, that is one line and must be so to function) defines how the installer should do the actual partitioning.

d-i partman-auto/expert_recipe string boot-root :: 100 50 100 ext3 \
    $primary{ } \
    $bootable{ } \
    method{ format } \
    format{ } \
    use_filesystem{ } \
    filesystem{ ext3 } \
    mountpoint{ /boot } \

The first thing is leave the 100 50 100 ext3 on the first line. Don't attempt to place the backslash after the :: and continue on the next. It doesn't work. I wish it did. Anyway, the first 100 says to give this partition a minimal size of 100MB. The 50 is the priority. The lower it is, the more likely it will be filled to maximum size, which is the second 100. Ext3 is the partition type to mount this partition as. $primary{ } ensures this partition will be a primary partition and $bootable{ } will set the boot flag. method{ format } tells it to format this partition and not preserve the filesystem as does the next line. Preseed is redundant, isn't it? Use_filesystem{ } tells it to auto detect the filesystem for mounting this time. Filesystem{ ext3 } says use ext3 for formating. Finally, mountpoint{ /boot } tells the installer to mount this to /boot. The "." terminates the configuration of the one partition. Read the rest of that line for more examples.

The three lines after that one big one, tell the installer to write the partitions to disk, format, and not ask questions.

The Clock and time zone setup section sets up the hard clock to use UTC and the timezone to that of Denver, Colorado.

The Installation Setup tells the system to first reboot automatically after install. It also tells the system to crash if debconf doesn't like the rest of the file.

The user's name and login portion is self-explanatory. You'll note that the password ubuntu is written four times, twice on two lines. Why it is required to type it more than once, I don't know. Preseed is redundant!

The next section tells the installer to install the ubuntu-standard and ubuntu-desktop packages and their dependencies. It also tells the installer to reboot after install...again.

At the end of the preseed, I have the installer download a file and execute it in a chroot of the new install. This is that file with comments detailing what's going on.



cd /tmp

# Setup auto login
UBUNTUUSER=$( getent passwd 1000 | cut -d : -f 1 )
wget "$SCRIPTURL/gdm.conf-custom"
sed "s/AutomaticLogin=ubuntu/AutomaticLogin=$UBUNTUUSER/g" \
    gdm.conf-custom > gdm.conf-custom2
mv /etc/gdm/gdm.conf-custom /etc/gdm/gdm.conf-custom.orig
cp gdm.conf-custom2 /etc/gdm/gdm.conf-custom
rm -f gdm.conf-custom gdm.conf-custom2

# Setup ubuntu sources
wget "$SCRIPTURL/sources.list"
rm -f /etc/apt/sources.list
cp sources.list /etc/apt/sources.list
rm -f sources.list

# Get updates
apt-get update
apt-get -y upgrade

# Install flash, vlc, and dvd playing software
apt-get -y install \
    gstreamer0.10-plugins-ugly-multiverse \
    gstreamer0.10-plugins-bad-multiverse \
    gstreamer0.10-plugins-bad \
    gstreamer0.10-plugins-ugly \
    gstreamer0.10-ffmpeg \
    libxine1-ffmpeg \
    libdvdread3 \
    flashplugin-nonfree \

# Setup DVD decryption

exit 0

And that's it. One more note before I finish. To make this entirely hand-free, you will have to past a few arguments at boot: The locale, keymap, network interface to use, and the location of the preseed file. I do this in my pxelinux.cfg/default.

label ubuntu
  kernel ubuntu/hardy/i386/linux
  append vga=normal initrd=ubuntu/hardy/i386/initrd.gz \
  locale=en_US.UTF-8 debian-installer/keymap=us \
  netcfg/wireless_wep= netcfg/choose_interface=eth0 \
  netcfg/get_hostname=ubuntu \
  preseed/url=ftp://ftp.deathcat.dci/pub/linux/ubuntu/preseed/easy.cfg --
Posted by Tyler Lesmann on July 6, 2008 at 12:58 and commented on 8 times
Tagged as: linux preseed pxe ubuntu

Pxelinux can do a lot of things, but loading the solaris installer is not one of them. For that, it is easier to use pxegrub. What can you do if you still want to use pxelinux as your primary network bootloader? You can easily make an entry in your pxelinux.cfg/default for pxegrub!

First of all, here is what my /tftpboot directory without the many linux, bsd, and solaris boot files:


If you are paying attention, you'll notice that pxegrub's filename is different than normal. You have to end the filename with a .0. If you don't, then pxelinux will not load it properly, which caused me a bit of confusion. Also, you will need to place pxegrub's configuration, menu.lst, in /boot/grub at the root of your tftp. Pxegrub looks there by default.

If you have everything set as so, you will be able to load pxegrub from pxelinux with the following clause:

label g
  kernel pxegrub.0

It's really that easy.

Posted by Tyler Lesmann on July 6, 2008 at 0:40
Tagged as: pxe