[lorax/rhel7 1/3] livemedia-creator: Add minimal disk example kickstart (#1019728)

Brian C. Lane bcl at redhat.com
Thu Oct 31 22:03:08 UTC 2013


From: "Brian C. Lane" <bcl at redhat.com>

Also adds a check for a bad url repo, and fix ram calculation for
appliance mode. Updates the README.livemedia-creator documentation.

Resolves: rhbz#1019728
---
 README.livemedia-creator   | 29 +++++++++++++++++++++-----
 docs/rhel7-minimal.ks      | 52 ++++++++++++++++++++++++++++++++++++++++++++++
 src/sbin/livemedia-creator | 20 +++++++++++-------
 3 files changed, 89 insertions(+), 12 deletions(-)
 create mode 100644 docs/rhel7-minimal.ks

diff --git a/README.livemedia-creator b/README.livemedia-creator
index e8c2e4a..62d5f13 100644
--- a/README.livemedia-creator
+++ b/README.livemedia-creator
@@ -16,6 +16,14 @@ minimum you need:
 --iso to specify the Anaconda install media to use with virt-install
 --ks is the kickstart to use to install the system
 
+To use livemedia-creator with virt-install you will need to install the
+following packages, as well as have libvirtd setup correctly.
+  virt-install
+  libvirt-python
+
+If you are going to be using Anaconda directly, with --no-virt mode, make sure
+you have the anaconda package installed.
+
 
 QUICKSTART
 ----------
@@ -74,13 +82,18 @@ written using the Mako template system which is very flexible.
 
 KICKSTARTS
 ----------
-Existing spin kickstarts can be used to create live media with a few changes.
-Here are the steps I used to convert the XFCE spin.
+The docs/ directory includes two example kickstarts, one to create a live desktop
+iso using GNOME, and the other to create a minimal disk image. When creating your
+own kickstarts you should start with the minimal example, it includes several
+needed packages that are not always included by dependencies.
+
+Or you can use existing spin kickstarts to create live media with a few
+changes. Here are the steps I used to convert the Fedora XFCE spin.
 
 1. Flatten the xfce kickstart using ksflatten
 2. Add zerombr so you don't get the disk init dialog
 3. Add clearpart --all
-4. Add swap and biosboot partitions
+4. Add swap partition
 5. bootloader target
 6. Add shutdown to the kickstart
 7. Add network --bootproto=dhcp --activate to activate the network
@@ -96,7 +109,6 @@ network --bootproto=dhcp --activate
 zerombr
 clearpart --all
 bootloader --location=mbr
-part biosboot --size=1
 part swap --size=512
 shutdown
 
@@ -110,6 +122,9 @@ passwd -d root > /dev/null
 
 cat /dev/null > /dev/fstab
 
+    Do this only for live iso's, the filesystem will be mounted read only if
+    there is no /etc/fstab
+
 11. Don't delete initramfs files from /boot in %post
 12. Have grub2-efi, shim, memtest86+, isomd5sum and syslinux in the package list
 13. Omit dracut-config-rescue from the package list "-dracut-config-rescue"
@@ -179,7 +194,7 @@ switch. This will create the partitioned disk image and an XML file that can be
 used with virt-image to setup a virtual system.
 
 The XML is generated using the Mako template from
-/usr/share/lorax/appliance/virt-image.xml You can use a different template by
+/usr/share/lorax/appliance/libvirt.xml You can use a different template by
 passing --app-template <template path>
 
 Documentation on the Mako template system can be found here:
@@ -204,6 +219,10 @@ title           from --title
 project         from --project
 releasever      from --releasever
 
+The created image can be imported into libvirt using:
+
+virt-image appliance.xml
+
 
 DEBUGGING PROBLEMS
 ------------------
diff --git a/docs/rhel7-minimal.ks b/docs/rhel7-minimal.ks
new file mode 100644
index 0000000..978c24a
--- /dev/null
+++ b/docs/rhel7-minimal.ks
@@ -0,0 +1,52 @@
+# Minimal Disk Image
+#
+sshpw --username=root --plaintext randOmStrinGhERE
+# Firewall configuration
+firewall --enabled
+# Use network installation
+url --url=http://prxy.notae.us/rhel7.0/Server/os
+repo --name=optional --baseurl=http://prxy.notae.us/rhel7.0/Server/optional/os
+
+# Root password
+rootpw --plaintext removethispw
+# Network information
+network  --bootproto=dhcp --onboot=on --activate
+# System authorization information
+auth --useshadow --enablemd5
+# System keyboard
+keyboard --xlayouts=us --vckeymap=us
+# System language
+lang en_US.UTF-8
+# SELinux configuration
+selinux --enforcing
+# Installation logging level
+logging --level=info
+# Shutdown after installation
+shutdown
+# System timezone
+timezone  US/Eastern
+# System bootloader configuration
+bootloader --location=mbr
+# Clear the Master Boot Record
+zerombr
+# Partition clearing information
+clearpart --all
+# Disk partitioning information
+part / --fstype="ext4" --size=4000
+part swap --size=1000
+
+%post
+# Remove root password
+passwd -d root > /dev/null
+%end
+
+%packages
+ at core
+kernel
+memtest86+
+grub2-efi
+grub2
+shim
+syslinux
+-dracut-config-rescue
+%end
diff --git a/src/sbin/livemedia-creator b/src/sbin/livemedia-creator
index d2727d6..042fa33 100755
--- a/src/sbin/livemedia-creator
+++ b/src/sbin/livemedia-creator
@@ -36,6 +36,7 @@ from time import sleep
 import shutil
 import argparse
 import hashlib
+import re
 
 # Use pykickstart to calculate disk image size
 from pykickstart.parser import KickstartParser
@@ -123,12 +124,17 @@ class LogRequestHandler(SocketServer.BaseRequestHandler):
         """
         Check a line to see if it contains an error indicating install failure
         """
-        simple_tests = [ "Traceback (",
-                         "Out of memory:",
-                         "Call Trace:",
-                         "insufficient disk space:" ]
+        simple_tests = ["Traceback (",
+                        "Out of memory:",
+                        "Call Trace:",
+                        "insufficient disk space:"]
+        re_tests =     [r"WARNING packaging: base repo .* not valid"]
         for t in simple_tests:
-            if line.find( t ) > -1:
+            if line.find(t) > -1:
+                self.server.log_error = True
+                return
+        for t in re_tests:
+            if re.search(t, line):
                 self.server.log_error = True
                 return
 
@@ -406,7 +412,7 @@ def make_appliance(disk_img, name, template, outfile, networks=None, ram=1024,
     if not (disk_img and template and outfile):
         return None
 
-    log.info("Creating appliance definition using ${0}".format(template))
+    log.info("Creating appliance definition using {0}".format(template))
 
     if not arch:
         arch = "x86_64"
@@ -791,7 +797,7 @@ if __name__ == '__main__':
         virt_group = parser.add_argument_group("virt-install arguments (DISABLED -- no libvirt)")
     else:
         virt_group = parser.add_argument_group("virt-install arguments")
-    virt_group.add_argument("--ram", metavar="MEMORY", default=1024,
+    virt_group.add_argument("--ram", metavar="MEMORY", type=int, default=1024,
                             help="Memory to allocate for installer in megabytes." )
     virt_group.add_argument("--vcpus", default=1,
                             help="Passed to --vcpus command" )
-- 
1.8.3.1



More information about the anaconda-patches mailing list