Unattended Guest OS Install - Research Paper

Discussions related to using the OSE version of VirtualBox.

Unattended Guest OS Install - Research Paper

Postby Technologov » 20. Dec 2011, 15:39

Forenote:
This is theoretical part. For working implementation, see 'vbox-unattended' here:
https://forums.virtualbox.org/viewtopic ... 87#p211187

Background:
OS vendors support automation, so big corporations can deploy many physical OSes quickly.
Every major operating system supports / requires it's own format of automatic scripts.
But with some trickery it can be done in virtual hardware, too...
The operating system installers knows how-to read such 'unattended scripts'
We will generate the necessary scripts on the fly, and feed to the OS installers.

research paper:
Copyright (c) 2011 Alexey Eromenko "Technologov"

I have analyzed VMware Workstation 7 product.
Found several backends:
Red Hat Anaconda kickstart,
Windows NT 5.x and
Windows NT 6.x scripts.
Debian preseed (found on the net)

The scripts for each backend is generated on the fly, based on template.

-----------------------------------------------------------
Part A: Windows unattended scripts:
-----------------------------------------------------------

Windows NT 5.x unattended scripts: (family includes Windows 2000/XP/2003)
is just single file 'winnt.sif' on floppy, that has INI-like syntax.
Windows NT 6.x unattended scripts: (family includes Windows Vista/7/2008)
is just single file 'autounattend.xml' on floppy, that has XML-like syntax.
Docs about both formats can be found on Google.

For VBox deployment, I recommend to use 2 CDs + floppy.
(1st CD = Windows, 2nd CD = Guest Additions.iso, floppy = has the config file)
We'll boot from the Windows CD.

We must:
1. generate the Windows-unattended scripts (winnt.sif and autounattend.xml),
2. create a FAT12-formatted 1.44 MB standard empty floppy image.
3. copy the Windows-unattended scripts into the floppy image.

Steps:
Linux hosts:
stage 1. is done by python strings parser.
stage 2a. dd if=/dev/zero of=/tmp/myfloppy.img count=1440 bs=1024 (create floppy image)
stage 2b. mkfs.msdos /tmp/myfloppy.img (format floppy image)
stage 3. mcopy -i /tmp/myfloppy.img winnt.sif autounattend.xml :: (copy file 1+2 into floppy image)
note: syntax of 'mcopy' is DOS-like [from] [from] ... [to], while "::" means to floppy image. Image must be specified using '-i [image]' parameter.
Problems:
stage 2 and stage 3 are impossible on Windows hosts without C coding.
(on Linux I use 'dd' and 'mkfs.msdos' for stage 2; 'mtools' for stage 3)
Possible Solutions: (hack)
stage 2: ship empty pre-formatted floppy image inside "vbox-unattended" for Windows hosts. (if zipped, it takes only few kilobytes)
stage 3: compile 'mtools' on Cygwin ? (very ugly hack, but no I see better solution for now)
Allternative: (ugly hack)
stage 2+3: Use "dir2floppy.jar" (pulls Java dependency). Advantage: Should work on Windows, without porting.
https://github.com/jedi4ever/veewee/tre ... r/lib/java
Best Solution: (good)
stage 2+3: Qemu has MIT-licensed FAT12 code built-in. (this avoids 'dd', 'mkfs.msdos' and 'mtools' hacks)
Possibly in this file:
http://svn.kju-app.org/trunk/qemu/qemu/block-vvfat.c
Porting such code to VirtualBox will pretty much solve the issue.

----------------------------------------------------------
Part B: Red Hat Anaconda kickstart:
----------------------------------------------------------

(family includes RHEL3/4/5/6, CentOS, Scientific Linux and Oracle Enterprise Linux,
that claims to be 'Unbreakble') :)
(a bit harder to support, but also possible is: Fedora)
Those are much more complex. Anaconda does not read kickstart config files
from floppy, unlike Windows.

The end result, is that there is a need to generate cusom-made bootable ISO,
that includes linux kernel, initrd, and kickstart config file.
In addition, I also recommend putting VBoxLinuxAdditions.run on the 2nd CD,
so they could be automatically deployed.

For VBox deployment, I recommend to use 2 CDs.
(1st CD = custom-made.iso (bootable), 2nd CD = Red Hat Enterprise Linux)

We must:
1. generate Linux-kickstart scripts
2. extract Linux-kernel, initrd, bootloader from original Red-Hat-like DVD.
3. extract VBoxLinuxAdditions.run from GuestAdditions.iso.
4. generate bootable custom-made iso (ISO9660 filesystem), that uses components from steps #1, #2, #3.

Steps:
Linux hosts:
stage 1. is done by python strings parser.
stages 2+3: 7z e /path/Red-Hat-like.iso isolinux/ && rm -Rvf isolinux/
(Alternative: can be done via 'mount -o loop')
stage 4: $ genisoimage -o /tmp/boot-ks.iso -r -b isolinux.bin -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -R -J -v -T .
(Alternative: can be done via 'mkisofs')
(VMware WS 7 uses 'mkisofs' on Windows hosts for stage 4)
Problems:
Is including and invoking LGPLed utility (7-zip) acceptable for VirtualBox team, if this code to be upstreamed ?
Extra steps: (required for full remastering of Red Hat)
stage A. copy .discinfo (hidden file; else your Red Hat won't detect DVD)
stage B. implantisomd5 redhat_custom.iso (so that media test will succeed)

More read:
Red Hat kickstart configurator GUI:
http://docs.redhat.com/docs/en-US/Red_H ... start.html

-----------------------------------------------------
Part C: Debian installer preseed:
-----------------------------------------------------

Debian actually provides not one, but two (!) methods of unattended installation:
- FAI (Fully Automatic Installation) and Debian Preseed.

In this material I cover the later, because the former doesn't suit our needs.

About FAI: from my very quick review, it seems to require very complex host-side
scripting, that are part of Debian.
It will likely work only on Debian hosts, or from Debian servers. Doesn't suit our needs.
Unlike FAI, preseed hides most of it's complex logic inside guest.

Preseed is in some ways similar to Red Hat kickstart, but more picky at some places, and requires more work;
Scripts are easy-to-read plain text.
It allows for both for semi-automatic and fully-automatic installs, by pre-seeding ready results.
For example it doesn't allows to boot from CD-A and load preseed script from same CD-A,
but install from CD-B.
So here we boot from CD-A, read script from floppy, then install from CD-B.
Moreover, preseed requires more parameters to be passed to the kernel.
The reason to use floppy, is that I was unable to load the script from CD.

isolinux.cfg:
kernel /install.386/vmlinuz
append initrd=/install.386/initrd.gz debian-installer/locale=en_US console-setup/layoutcode=us netcfg/choose_interface=auto priority=critical preseed/file=/floppy/preseed.cfg --

If you forget to specify "locale" or "layoutcode", the d-i (debian installer)
will ask the user about those interactively, converting our install to semi-automatic.
priority=critical is related to the amount of questions that various "deb"
packages usually ask (such as which Display Manager to use: XDM or KDM).

We must:
1. generate Debian-preseed scripts and isolinux.cfg
2. extract Linux-kernel, initrd, bootloader from original Debian media. (install.{arch}/ and isolinux/)
3. extract VBoxLinuxAdditions.run from GuestAdditions.iso.
4. generate bootable custom-made iso, that uses components from steps #1, #2, #3.
5. create a FAT12-formatted 1.44 MB standard empty floppy image.
6. put the Debian-preseed scripts into the floppy image.

For VBox deployment, I recommend to use 2 CDs+1 floppy.
(1st CD = custom-made.iso (bootable), 2nd CD = Debian, custom-made-floppy.img (w/preseed))

Steps:
Similar to RedHat + Windows combined.

More reading about preseed:
http://www.debian.org/releases/stable/i ... 02.html.en
-and-
http://www.debian-administration.org/ar ... ding/print

--------------------------------------
Part D: SUSE AutoYast:
--------------------------------------
(family includes SUSE Linux Enterprise and openSUSE)

SUSE's AutoYast automatic installer in it's logic and concept is similar to Red Hat's kickstart.
Both depend on 2 CD-ROMs being loaded, and both don't need any floppy.
Major difference is the actual format, that uses XML format.

================
Sister projects:
1. Oz
http://clalance.blogspot.com/2011/02/oz ... n-010.html
http://aeolusproject.org/oz-download.html
Chris Lalancette <clalance@redhat.com>

2. passion engine
https://github.com/hh/veewee/tree/master/templates
https://github.com/passionengine/ii
done by <hippiehacker> on #vbox

-Technologov
Last edited by Technologov on 19. Aug 2016, 11:37, edited 1 time in total.
Technologov
Volunteer
 
Posts: 3313
Joined: 10. May 2007, 16:59
Location: Israel

Re: Unattended Guest OS Install - Research Paper

Postby Technologov » 20. Dec 2011, 15:46

---------------------------------------------------
Part A1: Windows NT 5.x - Format Analysis
---------------------------------------------------
Very simple INI-like syntax.

Few highlights: (from example 'winnt.sif')

[UserData]
ProductKey = "12345-12345-12345-12345-12345"
FullName = "user"
OrgName = ""
ComputerName = *

[Display]
XResolution = 800
YResolution = 600
BitsPerPel = 32

[GuiRunOnce]
Command0="d:\vboxadditions.exe /S /xres=800 /yres=600 /depth=32"

===
1. user & passwords, and ProductKey need to be replaced.
2. desktop resolution default: 800x600.
3. Guest Additions integration: needs to be done last.
3.a. Problem: I don't see a way to restart Guest OS after installing this thing.
---------------------------------------------------------------
Part B: Red Hat Anaconda kickstart - Format Analysis
---------------------------------------------------------------
example "ks.cfg":

lang en_US
langsupport --default en_US
network --bootproto dhcp
cdrom
keyboard us
zerombr yes
clearpart --all
part / --size 3000 --grow
part swap --recommended
install
mouse generic3ps/2
firewall --enabled
timezone --utc America/New_York
xconfig --resolution=800x600
rootpw 123456
reboot
auth --useshadow --enablemd5
bootloader --location=mbr
key --skip
%packages --resolvedeps
python
kernel-source
@ X Window System
@ GNOME Desktop Environment
@ Graphical Internet
@ Development Tools

%post
[bash code here] <-- we will use this section to install VBox GA later.
...
/usr/sbin/usermod -p 'GpXt0LkddbPY2' user

=======
Here is use standard settings, and setup single / (root) partition of maximum size.

important details:
1. 'Development Tools' group is necessary on all Red-Hat-like systems, else VBox GA fails to build.
It installs 'kernel-headers', 'gcc', 'automake', 'autoconf'.
2. 'kernel-source' package is required on RHEL3, else VBox GA fails to build.
Having just headers is not enough on RHEL3.
3. 'key --skip' <-- this needs to be removed on RHEL3/4, but should exist for RHEL5 guests.
4. passwords and usernames need to be changed on the fly.
5. 'langsupport' <-- this needs to be removed on RHEL6 systems.

Problem:
1. how-to generate password-hash from clear-text password ? (like 'GpXt0LkddbPY2')
TODO:
1. Add VBoxLinuxAdditions install code
2. add 'user' to 'vboxsf' group by default.

Possible Red Hat groups (in Fedora 15):

Installed Groups:
Administration Tools
Authoring and Publishing
Base
Design Suite
Development Libraries
Development Tools
Dial-up Networking Support
Editors
Educational Software
Electronic Lab
Engineering and Scientific
Fonts
GNOME Desktop Environment
GNOME Software Development
Games and Entertainment
Graphical Internet
Graphics
Hardware Support
Input Methods
Java
KDE Software Compilation
Legacy Fonts
Mail Server
Milkymist
MySQL Database
Network Servers
Office/Productivity
Printing Support
Robotics
Server Configuration Tools
Sound and Video
System Tools
Text-based Internet
Window Managers
X Software Development
X Window System

Available Groups:
Books and Guides
Clustering
DNS Name Server
Directory Server
Dogtag Certificate System
FTP Server
Fedora Eclipse
Fedora Packager
Font design and packaging
Haskell
Java Development
KDE Software Development
LXDE
Legacy Network Server
Legacy Software Development
LibreOffice Development
MeeGo NetBook UX Environment
MinGW cross-compiler
News Server
OCaml
Perl Development
PostgreSQL Database
Ruby
Somali Support
Sugar Desktop Environment
Virtualization
Web Development
Web Server
Windows File Server
XFCE Software Development
Xfce

-Technologov
Technologov
Volunteer
 
Posts: 3313
Joined: 10. May 2007, 16:59
Location: Israel


Return to VirtualBox OSE

Who is online

Users browsing this forum: No registered users and 2 guests