Automatic root login on livecd
by msacks
Hello List,
I am creating a diagnostic livecd that will run a custom script as
soon as it boots.
I'd like to bypass the login screen altogether and automatically log
in as the root user.
I was considering creating a custom rpm with the following lines in
the following files like so:
/etc/gdm/custom.conf AutomaticLoginEnable=true
AutomaticLogin=root
and my /etc/pam.d/gdm
#auth required pam_succeed_if.so user != root quiet
Is there a better way to achieve this than customizing these config
files and over-writing them in an RPM?
Thanks in advance.
12 years, 9 months
auto-biarch (x86_64 + i686) LiveDVD patch + ISO
by Jan Kratochvil
Hi,
finally created a LiveDVD ISO automatically booting x86_64 OS on x86_64
(and i686 otherwise). Regular users will not notice there exists any new arch
while they will benefit from the full performance of their PC:
http://people.redhat.com/jkratoch/x86bilive-2009062000.tar.gz (71KB)
It uses live_dir=LiveOS-x86_64 vs. live_dir=LiveOS-i686 to boot the image.
The syslinux patch provides "default-{x86_64,i386}" keywords in isolinux.cfg.
livecd-iso-to-disk is not patched/compatible with such image.
livecd-creator should create such ISO on a single run, not by merging the
output of two livecd-creator runs by a 3rd party app.
Regards,
Jan
Reasons:
* I still did not understand why I have to carry with me two media - both
x86_64 and i386 - when all the data perfectly fit on a single media.
* Why I have to try to boot x86_64 first to find out if the specific machine
is x86_64? Even common programmers do not know it, "Windows XP works here".
* The OS must "just work", it must be fun and easy. Requiring a special
technical decision before even starting the OS download is a showstopper.
* Checked that a regular user will on http://fedoraproject.org/get-fedora
still download terrible performance degradation of 32-bit OS although her
hadware is in 70%-95%(?) of cases x86_64. x86_64 is here for 6 years now.
* Arguing x86 may be faster than x86_64... I did not find any such case,
x86_64 is a more modern arch (more registers, PIC for free, better ABI).
We already hit the 2GB address space limitations. x86_64 is the future.
* All the friends of mine have 8Mbit+ ADSL and TB disks downloading many DVD
disks so some several more hundreds of MB are not something to notice.
mkisofs -f -J -r -hide-rr-moved -hide-joliet-trans-tbl -V Fedora-11-x86bi-Live -o ../x86bilive.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-info-table -boot-load-size 4 .
mount -r -o loop Fedora-11-x86_64-Live.iso x86_64/
mount -r -o loop Fedora-11-i686-Live.iso i686/
x86bilive:
total 4
lrwxrwxrwx 1 root root 13 2009-06-18 21:10 GPL -> ../x86_64/GPL
lrwxrwxrwx 1 root root 14 2009-06-18 21:11 LiveOS-i686 -> ../i686/LiveOS/
lrwxrwxrwx 1 root root 16 2009-06-18 21:10 LiveOS-x86_64 -> ../x86_64/LiveOS/
lrwxrwxrwx 1 root root 16 2009-06-18 21:10 README -> ../x86_64/README
drwxr-xr-x 2 root root 4096 2009-06-20 21:44 isolinux/
x86bilive/isolinux:
total 184
lrwxrwxrwx 1 root root 30 2009-06-18 21:13 boot.cat -> ../../x86_64/isolinux/boot.cat
lrwxrwxrwx 1 root root 31 2009-06-18 21:17 ii686 -> ../../i686/isolinux/initrd0.img
-rw-r--r-- 1 root root 14336 2009-06-20 21:45 isolinux.bin
-r--r--r-- 1 root root 1411 2009-06-20 21:44 isolinux.cfg
lrwxrwxrwx 1 root root 33 2009-06-18 21:13 ix8664 -> ../../x86_64/isolinux/initrd0.img
lrwxrwxrwx 1 root root 28 2009-06-18 21:17 ki686 -> ../../i686/isolinux/vmlinuz0
lrwxrwxrwx 1 root root 30 2009-06-18 21:13 kx8664 -> ../../x86_64/isolinux/vmlinuz0
lrwxrwxrwx 1 root root 29 2009-06-18 21:13 memtest -> ../../x86_64/isolinux/memtest
lrwxrwxrwx 1 root root 32 2009-06-18 21:13 splash.jpg -> ../../x86_64/isolinux/splash.jpg
-r--r--r-- 1 root root 159888 2009-06-20 20:48 vesamenu.c32
isolinux.cfg:
default vesamenu.c32
timeout 100
menu background splash.jpg
menu title Welcome to Fedora-11-x86bi-Live!
menu color border 0 #ffffffff #00000000
menu color sel 7 #ffffffff #ff000000
menu color title 0 #ffffffff #00000000
menu color tabmsg 0 #ffffffff #00000000
menu color unsel 0 #ffffffff #00000000
menu color hotsel 0 #ff000000 #ffffffff
menu color hotkey 7 #ffffffff #ff000000
menu color timeout_msg 0 #ffffffff #00000000
menu color timeout 0 #ffffffff #00000000
menu color cmdline 0 #ffffffff #00000000
menu hidden
menu hiddenrow 5
label linux0
menu label x86_64 Boot
kernel kx8664
append initrd=ix8664 root=CDLABEL=Fedora-11-x86bi-Live rootfstype=auto live_dir=LiveOS-x86_64 ro liveimg quiet rhgb
menu default-x86_64
label check0
menu label x86_64 Verify and Boot
kernel kx8664
append initrd=ix8664 root=CDLABEL=Fedora-11-x86bi-Live rootfstype=auto live_dir=LiveOS-x86_64 ro liveimg quiet rhgb check
label linux1
menu label i686 Boot
kernel ki686
append initrd=ii686 root=CDLABEL=Fedora-11-x86bi-Live rootfstype=auto live_dir=LiveOS-i686 ro liveimg quiet rhgb
menu default-i386
label check1
menu label i686 Verify and Boot
kernel ki686
append initrd=ii686 root=CDLABEL=Fedora-11-x86bi-Live rootfstype=auto live_dir=LiveOS-i686 ro liveimg quiet rhgb check
label memtest
menu label Memory Test
kernel memtest
label local
menu label Boot from local drive
localboot 0xffff
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ defaults.patch 20 Jun 2009 20:10:46 -0000
@@ -0,0 +1,175 @@
+--- syslinux-3.75-orig/com32/menu/Makefile 2009-04-16 06:42:14.000000000 +0200
++++ syslinux-3.75-defaults/com32/menu/Makefile 2009-06-20 19:21:32.000000000 +0200
+@@ -24,7 +24,7 @@ MODULES = menu.c32 vesamenu.c32
+ TESTFILES =
+
+ COMMONOBJS = menumain.o readconfig.o passwd.o drain.o printmsg.o colors.o \
+- background.o refstr.o execute.o
++ background.o refstr.o execute.o verify_cpu.o
+
+ all: $(MODULES) $(TESTFILES)
+
+--- syslinux-3.75-orig/com32/menu/menu.h 2009-04-16 06:42:14.000000000 +0200
++++ syslinux-3.75-defaults/com32/menu/menu.h 2009-06-20 19:21:32.000000000 +0200
+@@ -224,4 +224,9 @@ void execute(const char *cmdline, enum k
+ /* drain.c */
+ void drain_keyboard(void);
+
++/* verify_cpu.S */
++#if defined(__i386__) || defined(__x86_64__)
++int verify_cpu(void);
++#endif
++
+ #endif /* MENU_H */
+--- syslinux-3.75-orig/com32/menu/readconfig.c 2009-04-16 06:42:14.000000000 +0200
++++ syslinux-3.75-defaults/com32/menu/readconfig.c 2009-06-20 20:23:24.000000000 +0200
+@@ -656,11 +656,22 @@ static void parse_config_file(FILE *f)
+ m->parent_entry->displayname = refstr_get(m->title);
+ }
+ }
+- } else if ( looking_at(p, "default") ) {
+- if (ld.label) {
+- ld.menudefault = 1;
+- } else if (m->parent_entry) {
+- m->parent->defentry = m->parent_entry->entry;
++ } else if ( looking_at(p, "default")
++#if defined(__i386__) || defined(__x86_64__)
++ || looking_at(p, "default-i386")
++ || looking_at(p, "default-x86_64")
++#endif
++ ) {
++#if defined(__i386__) || defined(__x86_64__)
++ if (! ( ( looking_at(p, "default-i386") && verify_cpu () == 0 ) ||
++ ( looking_at(p, "default-x86_64") && verify_cpu () != 0 ) ) )
++#endif
++ {
++ if (ld.label) {
++ ld.menudefault = 1;
++ } else if (m->parent_entry) {
++ m->parent->defentry = m->parent_entry->entry;
++ }
+ }
+ } else if ( looking_at(p, "hide") ) {
+ ld.menuhide = 1;
+--- syslinux-3.75-orig/com32/menu/verify_cpu.S 1970-01-01 01:00:00.000000000 +0100
++++ syslinux-3.75-defaults/com32/menu/verify_cpu.S 2009-06-20 20:30:27.000000000 +0200
+@@ -0,0 +1,119 @@
++/* https://lists.linux-foundation.org/pipermail/fastboot/2006-November/01188... */
++#if defined(__i386__) || defined(__x86_64__)
++ .globl verify_cpu
++verify_cpu:
++ push %ebx
++ push %esi
++ push %edi
++ push %ebp
++ call Xverify_cpu
++ pop %ebp
++ pop %edi
++ pop %esi
++ pop %ebx
++ ret
++
++/*
++ *
++ * verify_cpu.S
++ *
++ * 14 Nov 2006 Vivek Goyal: Created the file
++ *
++ * This is a common code for verification whether CPU supports
++ * long mode and SSE or not. It is not called directly instead this
++ * file is included at various places and compiled in that context.
++ * Following are the current usage.
++ *
++ * This file is included by both 16bit and 32bit code.
++ *
++ * arch/x86_64/boot/setup.S : Boot cpu verification (16bit)
++ * arch/x86_64/boot/compressed/head.S: Boot cpu verification (32bit)
++ * arch/x86_64/kernel/trampoline.S: secondary processor verfication (16bit)
++ * arch/x86_64/kernel/acpi/wakeup.S:Verfication at resume (16bit)
++ *
++ * verify_cpu, returns the status of cpu check in register %eax.
++ * 0: Success 1: Failure
++ *
++ * The caller needs to check for the error code and take the action
++ * appropriately. Either display a message or halt.
++ */
++
++Xverify_cpu:
++
++ pushfl # Save caller passed flags
++ pushl $0 # Kill any dangerous flags
++ popfl
++
++ /* minimum CPUID flags for x86-64 */
++ /* see http://www.x86-64.org/lists/discuss/msg02971.html */
++#define SSE_MASK ((1<<25)|(1<<26))
++#define REQUIRED_MASK1 ((1<<0)|(1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<<8)|\
++ (1<<13)|(1<<15)|(1<<24))
++#define REQUIRED_MASK2 (1<<29)
++ pushfl # standard way to check for cpuid
++ popl %eax
++ movl %eax,%ebx
++ xorl $0x200000,%eax
++ pushl %eax
++ popfl
++ pushfl
++ popl %eax
++ cmpl %eax,%ebx
++ jz verify_cpu_no_longmode # cpu has no cpuid
++
++ movl $0x0,%eax # See if cpuid 1 is implemented
++ cpuid
++ cmpl $0x1,%eax
++ jb verify_cpu_no_longmode # no cpuid 1
++
++ xor %di,%di
++ cmpl $0x68747541,%ebx # AuthenticAMD
++ jnz verify_cpu_noamd
++ cmpl $0x69746e65,%edx
++ jnz verify_cpu_noamd
++ cmpl $0x444d4163,%ecx
++ jnz verify_cpu_noamd
++ mov $1,%di # cpu is from AMD
++
++verify_cpu_noamd:
++ movl $0x1,%eax # Does the cpu have what it takes
++ cpuid
++ andl $REQUIRED_MASK1,%edx
++ xorl $REQUIRED_MASK1,%edx
++ jnz verify_cpu_no_longmode
++
++ movl $0x80000000,%eax # See if extended cpuid is implemented
++ cpuid
++ cmpl $0x80000001,%eax
++ jb verify_cpu_no_longmode # no extended cpuid
++
++ movl $0x80000001,%eax # Does the cpu have what it takes
++ cpuid
++ andl $REQUIRED_MASK2,%edx
++ xorl $REQUIRED_MASK2,%edx
++ jnz verify_cpu_no_longmode
++
++verify_cpu_sse_test:
++ movl $1,%eax
++ cpuid
++ andl $SSE_MASK,%edx
++ cmpl $SSE_MASK,%edx
++ je verify_cpu_sse_ok
++ test %di,%di
++ jz verify_cpu_no_longmode # only try to force SSE on AMD
++ movl $0xc0010015,%ecx # HWCR
++ rdmsr
++ btr $15,%eax # enable SSE
++ wrmsr
++ xor %di,%di # don't loop
++ jmp verify_cpu_sse_test # try again
++
++verify_cpu_no_longmode:
++ popfl # Restore caller passed flags
++ movl $1,%eax
++ ret
++verify_cpu_sse_ok:
++ popfl # Restore caller passed flags
++ xorl %eax, %eax
++ ret
++#endif
--- syslinux.spec 16 Apr 2009 18:11:30 -0000 1.59
+++ syslinux.spec 20 Jun 2009 20:10:46 -0000
@@ -7,6 +7,7 @@ License: GPLv2+
Group: Applications/System
URL: http://syslinux.zytor.com/
Source0: ftp://ftp.kernel.org/pub/linux/utils/boot/syslinux/%{name}-%{tarball_vers...
+Patch9: defaults.patch
ExclusiveArch: %{ix86} x86_64
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: nasm >= 0.98.38-1, perl, netpbm-progs
@@ -33,12 +34,18 @@ MEMDISK, which loads legacy operating sy
%prep
%setup -q -n syslinux-%{tarball_version}
+%patch9 -p1
%build
CFLAGS="-Werror -Wno-unused -finline-limit=2000"
export CFLAGS
# If you make clean here, we lose the provided syslinux.exe
#make clean
+rm -f com32/menu/vesamenu.c32
+make -C com32/lib libcom32.a
+make -C com32/gpllib libcom32gpl.a
+make -C com32/menu vesamenu.c32
+test -f com32/menu/vesamenu.c32
make installer
make -C sample tidy
12 years, 9 months
chkconfig on doesn't work for init script in livecd
by msacks
I am trying to get a custom init script to start up at boot time on a
livecd I am spinning, but for some reason it isn't getting picked up.
Here is the recount of what I've done:
I created a custom init script (/etc/init.d/custombinary) as follows
and put it in an rpm with my binary:
#!/bin/bash
#
# custombinary Start up the custombinary utility
#
# chkconfig: 2345 55 25
# description: This service starts up a custombinary
#
# processname: custombinary
### BEGIN INIT INFO
# Provides: custombinary
# Required-Start: $local_fs $network $syslog
# Required-Stop: $local_fs $syslog
# Should-Start: $syslog
# Should-Stop: $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: run custom binary
# Description: Custom binary init script script to be used with liveCD
### END INIT INFO
# source function library
. /etc/rc.d/init.d/functions
start()
{
echo "Starting custom binary"
/opt/custom/bin/custombinary
}
stop()
{
echo "Shutdown"
killall -9 custombinary
}
case "$1" in
start)
start
;;
stop)
stop
;;
*)
echo "Usage: start | stop"
exit 1
;;
esac
exit $?
I package the rpm and init script, both of those get pushed out to the
liveCD with no problem.
In my spin-kickstart file I have the following line:
%post --log=/tmp/my-post.log
/sbin/chkconfig --add custombinary
/sbin/chkconfig --level 35 custombinary on
When I run livecd-creator, I don't get any errors.
When I run a chkconfig --list custombinary I get an error saying
service custombinary supports chkconfig, but is not referenced in any
runlevel (run 'chkconfig --add custombinary'
What is super-confusing is that my init script works with chkconfig if I run
/sbin/chkconfig --add custombinary
/sbin/chkconfig --level 35 custombinary on
once my livecd is booted up, but for some reason it isn't getting
turned on by default during the livecd creation.
12 years, 10 months
[PATCH] Merge livecd-creator and image-creator
by Lubomir Rintel
image-creator was duplicating a lot of code, while still failing to stay
in sync with livecd-creator (not providing useful options, such as
tmpdir or cachedir). Make it a link to livecd-creator and determine the
image packaging by argv[0].
---
Makefile | 2 +-
tools/image-creator | 75 --------------------------------------------------
tools/livecd-creator | 48 ++++++++++++++++++++++++++------
3 files changed, 40 insertions(+), 85 deletions(-)
delete mode 100755 tools/image-creator
diff --git a/Makefile b/Makefile
index 83880ef..be14e32 100644
--- a/Makefile
+++ b/Makefile
@@ -22,8 +22,8 @@ man:
install: man
$(INSTALL_PROGRAM) -D tools/livecd-creator $(DESTDIR)/usr/bin/livecd-creator
+ ln $(DESTDIR)/usr/bin/livecd-creator $(DESTDIR)/usr/bin/image-creator
$(INSTALL_PROGRAM) -D tools/liveimage-mount $(DESTDIR)/usr/bin/liveimage-mount
- $(INSTALL_PROGRAM) -D tools/image-creator $(DESTDIR)/usr/bin/image-creator
$(INSTALL_PROGRAM) -D tools/livecd-iso-to-disk.sh $(DESTDIR)/usr/bin/livecd-iso-to-disk
$(INSTALL_PROGRAM) -D tools/livecd-iso-to-pxeboot.sh $(DESTDIR)/usr/bin/livecd-iso-to-pxeboot
$(INSTALL_PROGRAM) -D tools/mkbiarch.py $(DESTDIR)/usr/bin/mkbiarch
diff --git a/tools/image-creator b/tools/image-creator
deleted file mode 100755
index 6f2604c..0000000
--- a/tools/image-creator
+++ /dev/null
@@ -1,75 +0,0 @@
-#!/usr/bin/python -tt
-#
-# image-creator: Create an ext3 system image
-#
-# Copyright 2007, Red Hat Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; version 2 of the License.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Library General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-import os
-import sys
-import shutil
-import optparse
-import logging
-
-import imgcreate
-
-def parse_options(args):
- parser = optparse.OptionParser(usage = "%prog [--name=<name>] <kickstart>")
-
- parser.add_option("-n", "--name", type="string", dest="name",
- help="Image name and filesystem label")
-
- imgcreate.setup_logging(parser)
-
- (options, args) = parser.parse_args()
-
- if len(args) != 1:
- parser.print_usage()
- sys.exit(1)
-
- return (args[0], options)
-
-def main():
- (kscfg, options) = parse_options(sys.argv[1:])
-
- if os.geteuid () != 0:
- print >> sys.stderr, "You must run image-creator as root"
- return 1
-
- try:
- ks = imgcreate.read_kickstart(kscfg)
- except imgcreate.CreatorError, e:
- logging.error("Unable to load kickstart file '%s' : %s" % (kscfg, e))
- return 1
-
- if options.name:
- name = options.name
- else:
- name = imgcreate.build_name(kscfg)
-
- creator = imgcreate.LoopImageCreator(ks, name)
-
- try:
- creator.create()
- except imgcreate.CreatorError, e:
- logging.error("Unable to create image : %s" % e)
- return 1
- finally:
- creator.cleanup()
-
- return 0
-
-if __name__ == "__main__":
- sys.exit(main())
diff --git a/tools/livecd-creator b/tools/livecd-creator
index d352d74..8559372 100755
--- a/tools/livecd-creator
+++ b/tools/livecd-creator
@@ -41,6 +41,11 @@ def parse_options(args):
help="Add packages to an existing live CD iso9660 image.")
imgopt.add_option("-f", "--fslabel", type="string", dest="fs_label",
help="File system label (default based on config name)")
+ # Provided for img-create compatibility
+ imgopt.add_option("-n", "--name", type="string", dest="fs_label",
+ help=optparse.SUPPRESS_HELP)
+ imgopt.add_option("", "--image-type", type="string", dest="image_type",
+ help=optparse.SUPPRESS_HELP)
imgopt.add_option("", "--compression-type", type="string", dest="compress_type",
help="Compression type recognized by mksquashfs (default gzip, lzma needs custom kernel, lzo needs a 2.6.36+ kernel)",
default="gzip")
@@ -70,14 +75,31 @@ def parse_options(args):
help=optparse.SUPPRESS_HELP)
(options, args) = parser.parse_args()
+
+ # Pretend to be a image-creator if called with that name
+ if not options.image_type:
+ if sys.argv[0].endswith('image-creator'):
+ options.image_type = 'image'
+ else:
+ options.image_type = 'livecd'
+ if options.image_type not in ('livecd', 'image'):
+ raise Usage("'%s' is a recognized image type" % options.image_type)
+
+ # image-create compatibility: Last argument is kickstart file
+ if len(args) == 1:
+ options.kscfg = args.pop()
+ if len(args):
+ raise Usage("Extra arguments given")
+
if not options.kscfg:
raise Usage("Kickstart file must be provided")
if options.base_on and not os.path.isfile(options.base_on):
- raise Usage("Live CD ISO '%s' does not exist" %(options.base_on,))
- if options.fs_label and len(options.fs_label) > imgcreate.FSLABEL_MAXLEN:
- raise Usage("CD labels are limited to 32 characters")
- if options.fs_label and options.fs_label.find(" ") != -1:
- raise Usage("CD labels cannot contain spaces.")
+ raise Usage("Image file '%s' does not exist" %(options.base_on,))
+ if options.image_type == 'live':
+ if options.fs_label and len(options.fs_label) > imgcreate.FSLABEL_MAXLEN:
+ raise Usage("CD labels are limited to 32 characters")
+ if options.fs_label and options.fs_label.find(" ") != -1:
+ raise Usage("CD labels cannot contain spaces.")
return options
@@ -96,17 +118,17 @@ def main():
return ret
if os.geteuid () != 0:
- print >> sys.stderr, "You must run livecd-creator as root"
+ print >> sys.stderr, "You must run %s as root" % sys.argv[0]
return 1
if options.fs_label:
fs_label = options.fs_label
name = fs_label
else:
- name = imgcreate.build_name(options.kscfg, "livecd-")
+ name = imgcreate.build_name(options.kscfg, options.image_type + "-")
fs_label = imgcreate.build_name(options.kscfg,
- "livecd-",
+ options.image_type + "-",
maxlen = imgcreate.FSLABEL_MAXLEN,
suffix = "%s-%s" %(os.uname()[4], time.strftime("%Y%m%d%H%M")))
@@ -114,7 +136,15 @@ def main():
ks = imgcreate.read_kickstart(options.kscfg)
- creator = imgcreate.LiveImageCreator(ks, name, fs_label)
+ if options.image_type == 'livecd':
+ creator = imgcreate.LiveImageCreator(ks, name, fs_label)
+ elif options.image_type == 'image':
+ creator = imgcreate.LoopImageCreator(ks, name, fs_label)
+ else:
+ # Cannot happen, we validate this when parsing options.
+ logging.error(u"'%s' is not a valid image type" % options.image_type)
+ return 1
+
creator.tmpdir = os.path.abspath(options.tmpdir)
creator.compress_type = options.compress_type
creator.skip_compression = options.skip_compression
--
1.7.3.2
12 years, 10 months
tools/livecd-iso-to-disk.sh
by Brian C. Lane
tools/livecd-iso-to-disk.sh | 34 ++++++++++++++++++++++------------
1 file changed, 22 insertions(+), 12 deletions(-)
New commits:
commit 07b8bcc12c88f4d23f1aacb6e0980b06a7e026c6
Author: Frederick Grose <fgrose(a)gmail.com>
Date: Mon Nov 29 16:20:12 2010 -0800
Cleanup if/then blocks (#652522)
diff --git a/tools/livecd-iso-to-disk.sh b/tools/livecd-iso-to-disk.sh
index caa7bde..d3f0ba7 100755
--- a/tools/livecd-iso-to-disk.sh
+++ b/tools/livecd-iso-to-disk.sh
@@ -74,7 +74,7 @@ resetMBR() {
fi
getdisk $1
# if efi, we need to use the hybrid MBR
- if [ -n "$efi" ];then
+ if [ -n "$efi" ]; then
if [ -f /usr/lib/syslinux/gptmbr.bin ]; then
gptmbr='/usr/lib/syslinux/gptmbr.bin'
elif [ -f /usr/share/syslinux/gptmbr.bin ]; then
@@ -266,7 +266,7 @@ checkFilesystem() {
USBLABEL=$(/sbin/blkid -s UUID -o value $dev)
if [ -n "$USBLABEL" ]; then
- USBLABEL="UUID=$USBLABEL" ;
+ USBLABEL="UUID=$USBLABEL"
else
USBLABEL=$(/sbin/blkid -s LABEL -o value $dev)
if [ -n "$USBLABEL" ]; then
@@ -321,7 +321,7 @@ checkint() {
fi
}
-if [ $(id -u) != 0 ]; then
+if [ $(id -u) != 0 ]; then
echo "You need to be root to run this script"
exit 1
fi
@@ -335,7 +335,7 @@ detectisotype() {
if [ -e $CDMNT/Packages ]; then
isotype=installer
return
- else
+ else
isotype=netinst
return
fi
@@ -499,10 +499,10 @@ fi
#checkFilesystem $USBDEV
# do some basic sanity checks.
checkMounted $USBDEV
-if [ -n "$format" -a -z "$skipcopy" ];then
+if [ -n "$format" -a -z "$skipcopy" ]; then
checkLVM $USBDEV
# checks for a valid filesystem
- if [ -n "$efi" ];then
+ if [ -n "$efi" ]; then
createGPTLayout $USBDEV
elif [ "$USBFS" == "vfat" -o "$USBFS" == "msdos" ]; then
createMSDOSLayout $USBDEV
@@ -688,7 +688,7 @@ cp $CDMNT/isolinux/* $USBMNT/$SYSLINUXPATH
BOOTCONFIG=$USBMNT/$SYSLINUXPATH/isolinux.cfg
# Set this to nothing so sed doesn't care
BOOTCONFIG_EFI=
-if [ -n "$efi" ];then
+if [ -n "$efi" ]; then
cp $CDMNT/EFI/boot/* $USBMNT/EFI/boot
# this is a little ugly, but it gets the "interesting" named config file
@@ -702,8 +702,12 @@ if [ -n "$LANG" ]; then
kernelargs="$kernelargs LANG=$LANG"
fi
sed -i -e "s/CDLABEL=[^ ]*/$USBLABEL/" -e "s/rootfstype=[^ ]*/rootfstype=$USBFS/" -e "s/LABEL=[^ ]*/$USBLABEL/" $BOOTCONFIG $BOOTCONFIG_EFI
-if [ -n "$kernelargs" ]; then sed -i -e "s/liveimg/liveimg ${kernelargs}/" $BOOTCONFIG $BOOTCONFIG_EFI ; fi
-if [ "$LIVEOS" != "LiveOS" ]; then sed -i -e "s;liveimg;liveimg live_dir=$LIVEOS;" $BOOTCONFIG $BOOTCONFIG_EFI ; fi
+if [ -n "$kernelargs" ]; then
+ sed -i -e "s/liveimg/liveimg ${kernelargs}/" $BOOTCONFIG $BOOTCONFIG_EFI
+fi
+if [ "$LIVEOS" != "LiveOS" ]; then
+ sed -i -e "s;liveimg;liveimg live_dir=$LIVEOS;" $BOOTCONFIG $BOOTCONFIG_EFI
+fi
# DVD Installer
if [ "$isotype" = "installer" ]; then
@@ -801,7 +805,9 @@ if [ -n "$xo" ]; then
fi
args="$args reset_overlay"
xosyspath=$(echo $SYSLINUXPATH | sed -e 's;/;\\;')
- if [ ! -d $USBMNT/boot ]; then mkdir -p $USBMNT/boot ; fi
+ if [ ! -d $USBMNT/boot ]; then
+ mkdir -p $USBMNT/boot
+ fi
cat > $USBMNT/boot/olpc.fth <<EOF
\ Boot script for USB boot
hex rom-pa fffc7 + 4 \$number drop h# 2e19 < [if]
@@ -846,7 +852,9 @@ if [ -z "$multi" ]; then
echo "Installing boot loader"
if [ -n "$efi" ]; then
# replace the ia32 hack
- if [ -f "$USBMNT/EFI/boot/boot.conf" ]; then cp -f $USBMNT/EFI/boot/bootia32.conf $USBMNT/EFI/boot/boot.conf ; fi
+ if [ -f "$USBMNT/EFI/boot/boot.conf" ]; then
+ cp -f $USBMNT/EFI/boot/bootia32.conf $USBMNT/EFI/boot/boot.conf
+ fi
fi
# this is a bit of a kludge, but syslinux doesn't guarantee the API for its com32 modules :/
@@ -865,7 +873,9 @@ if [ -z "$multi" ]; then
# and has to run with the file system unmounted
mv $USBMNT/$SYSLINUXPATH/isolinux.cfg $USBMNT/$SYSLINUXPATH/syslinux.cfg
# deal with mtools complaining about ldlinux.sys
- if [ -f $USBMNT/$SYSLINUXPATH/ldlinux.sys ] ; then rm -f $USBMNT/$SYSLINUXPATH/ldlinux.sys ; fi
+ if [ -f $USBMNT/$SYSLINUXPATH/ldlinux.sys ]; then
+ rm -f $USBMNT/$SYSLINUXPATH/ldlinux.sys
+ fi
cleanup
if [ -n "$SYSLINUXPATH" ]; then
syslinux -d $SYSLINUXPATH $USBDEV
12 years, 10 months
Updated imgcreate 'logging' handling
by James Laska
Greetings,
While working with clumens on an anaconda storage testsuite, we were trying to
determine why the livecd-creator --logfile= argument was not being handled as
we expected. For example, it wasn't capturing command output (e.g. mke2fs) in
the log file, it also wasn't being used elsewhere in imgcreate when emitting
progress (e.g. yuminst.py). It made for an extremely verbose test output log
which made problem determination difficult. To address this, I have adjusted
imgcreate to resolve the following issues. Comments encouraged.
= 0001-Add-a-quiet-option-to-surpress-stdout.-Adjust-handle.patch =
Don't automatically surpress stdout/stderr when adding a --logfile. Add a
--quiet option to handle stderr/stdout surpression.
= 0002-Work-with-the-logging-settings-when-emitting-progres.patch =
Don't bypass the logging module settings when emitting progress. Instead, work
with the logging module so that we honor arguments such as: --verbose, --debug
--logfile and --quiet.
= 0003-Wrap-subprocess.call-so-we-can-capture-all-command-o.patch =
Capture output from all subprocess.call() commands and log as debug output.
The only remaining output that isn't routed through logging during a
livecd-creator is the "Installing:" message. I think this is coming from
yum/rpmtrans.py itself (specifically the SimpleCliCallBack().event() method)
and will need to be handled differently.
Installing: bc ##################### [432/483]
Installing: unzip ##################### [433/483]
Installing: ed ##################### [434/483]
Installing: nano ##################### [435/483]
Installing: time ##################### [436/483]
Installing: telnet ##################### [437/483]
Installing: talk ##################### [438/483]
Installing: mtr ##################### [439/483]
Thanks,
James
12 years, 10 months
[PATCH] Fix partition number selection for MMC bus devices
by Frederick Grose
>From Bug 587411 <https://bugzilla.redhat.com/show_bug.cgi?id=587411> -
livecd-iso-to-disk
--format fails with SD/MMC partitions:
Comment 10:
Support prefixed partition numbers
Partition numbers and any prefix is now detected with simpler code.
Review and testing requested..
--Fred
----------------------------------------------------------------------
>From 2535f8a1c7a931ddbf06bcf9e74e7e943e592b43 Mon Sep 17 00:00:00 2001
From: Frederick Grose <fgrose(a)gmail.com>
Date: Tue, 23 Nov 2010 19:43:05 -0500
Subject: [PATCH] Fix partition number selection for MMC bus devices
Enable detection of partition number prefixes.
---
tools/livecd-iso-to-disk.sh | 24 +++++++++++++++++-------
1 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/tools/livecd-iso-to-disk.sh b/tools/livecd-iso-to-disk.sh
index caa7bde..ca28709 100755
--- a/tools/livecd-iso-to-disk.sh
+++ b/tools/livecd-iso-to-disk.sh
@@ -68,6 +68,13 @@ getdisk() {
partnum=${p##$device}
}
+getpartition() {
+ DEV=$1
+ pa=$( < /proc/partitions )
+ pa=${pa##*$DEV}
+ partnum=${pa%% *}
+}
+
resetMBR() {
if isdevloop "$DEV"; then
return
@@ -166,11 +173,12 @@ createGPTLayout() {
partinfo=$(LC_ALL=C /sbin/parted --script -m $device "unit b print"
|grep ^$device:)
size=$(echo $partinfo |cut -d : -f 2 |sed -e 's/B$//')
/sbin/parted --script $device unit b mkpart '"EFI System Partition"'
fat32 17408 $(($size - 17408)) set 1 boot on
- USBDEV=${device}1
# Sometimes automount can be _really_ annoying.
echo "Waiting for devices to settle..."
/sbin/udevadm settle
sleep 5
+ getpartition ${device#/dev/}
+ USBDEV=${device}${partnum}
umount $USBDEV &> /dev/null
/sbin/mkdosfs -n LIVE $USBDEV
USBLABEL="UUID=$(/sbin/blkid -s UUID -o value $USBDEV)"
@@ -188,15 +196,16 @@ createMSDOSLayout() {
partinfo=$(LC_ALL=C /sbin/parted --script -m $device "unit b print"
|grep ^$device:)
size=$(echo $partinfo |cut -d : -f 2 |sed -e 's/B$//')
/sbin/parted --script $device unit b mkpart primary fat32 17408
$(($size - 17408)) set 1 boot on
- if ! isdevloop "$DEV"; then
- USBDEV=${device}1
- else
- USBDEV=${device}
- fi
# Sometimes automount can be _really_ annoying.
echo "Waiting for devices to settle..."
/sbin/udevadm settle
sleep 5
+ if ! isdevloop "$DEV"; then
+ getpartition ${device#/dev/}
+ USBDEV=${device}${partnum}
+ else
+ USBDEV=${device}
+ fi
umount $USBDEV &> /dev/null
/sbin/mkdosfs -n LIVE $USBDEV
USBLABEL="UUID=$(/sbin/blkid -s UUID -o value $USBDEV)"
@@ -214,11 +223,12 @@ createEXTFSLayout() {
partinfo=$(LC_ALL=C /sbin/parted --script -m $device "unit b print"
|grep ^$device:)
size=$(echo $partinfo |cut -d : -f 2 |sed -e 's/B$//')
/sbin/parted --script $device unit b mkpart primary ext2 17408 $(($size
- 17408)) set 1 boot on
- USBDEV=${device}1
# Sometimes automount can be _really_ annoying.
echo "Waiting for devices to settle..."
/sbin/udevadm settle
sleep 5
+ getpartition ${device#/dev/}
+ USBDEV=${device}${partnum}
umount $USBDEV &> /dev/null
/sbin/mkfs.ext4 -L LIVE $USBDEV
USBLABEL="UUID=$(/sbin/blkid -s UUID -o value $USBDEV)"
--
1.7.3.2
12 years, 10 months
[PATCH] Fix disk space estimation errors in livecd-iso-to-disk
by Frederick Grose
>From Bug 656154 <https://bugzilla.redhat.com/show_bug.cgi?id=656154> - Fix
disk space estimation errors in livecd-iso-to-disk :
Fix disk space estimation and reporting code
The patch submitted addresses the following:
1. The estimates of disk space to-be-deleted and to-be-added ignored the
/syslinux and /EFI/boot folders (typically ~13 MiB on F-14 Live Desktop).
2. If the --skipcompression install option was selected, the compressed size of
ext3fs.img was reported (underestimating the installed size by ~975 MiB).
3. The command to estimate free space on the target device could fail if a
'newline' ever crept into the mountpoint name (not likely since the script
checks that it is unmounted first).
4. The requested and available space report could be formatted for easier
reading.
The patch does not consider or change any of the DVD or net installer code.
The EFI or multi code paths were NOT tested.
Review and testing requested.. --Fred
---------------------------------------------------------------------------------------------------------
>From e9ec02cf67451bc559829c53cd559cd40d90a217 Mon Sep 17 00:00:00 2001
From: Frederick Grose <fgrose(a)gmail.com>
Date: Tue, 23 Nov 2010 00:24:16 -0500
Subject: [PATCH] Fix disk space estimation errors.
Include /syslinux and /EFI/boot folders in the estimate,
use du --apparent-size for the --skipcompression install option,
protect df from failing due to mountpoints with '\n' in their name,
and format the size report for better readability.
---
tools/livecd-iso-to-disk.sh | 66
+++++++++++++++++++++++++++++-------------
1 files changed, 45 insertions(+), 21 deletions(-)
diff --git a/tools/livecd-iso-to-disk.sh b/tools/livecd-iso-to-disk.sh
index caa7bde..320c319 100755
--- a/tools/livecd-iso-to-disk.sh
+++ b/tools/livecd-iso-to-disk.sh
@@ -571,18 +571,27 @@ if [ -d $CDMNT/LiveOS ]; then
else
check=$CDMNT
fi
-if [ -d $USBMNT/$LIVEOS ]; then
- tbd=$(du -s -B 1M $USBMNT/$LIVEOS | awk {'print $1;'})
- [ -f $USBMNT/$LIVEOS/$HOMEFILE ] && homesz=$(du -s -B 1M
$USBMNT/$LIVEOS/$HOMEFILE | awk {'print $1;'})
- [ -n "$homesz" -a -n "$keephome" ] && tbd=$(($tbd - $homesz))
+if [[ -d $USBMNT/$LIVEOS ]]; then
+ tbd=($(du -B 1M $USBMNT/$LIVEOS))
+ [[ -s $USBMNT/$LIVEOS/$HOMEFILE ]] && \
+ homesize=($(du -B 1M $USBMNT/$LIVEOS/$HOMEFILE))
+ ((homesize > 0)) && [[ -n $keephome ]] && ((tbd -= homesize))
else
tbd=0
fi
-livesize=$(du -s -B 1M $check | awk {'print $1;'})
-if [ -n "$skipcompress" ]; then
- if [ -e $CDMNT/LiveOS/squashfs.img ]; then
+targets="$USBMNT/$SYSLINUXPATH"
+if [[ -n $efi ]]; then
+ targets+=" $USBMNT/EFI/boot"
+fi
+duTable=($(du -c -B 1M $targets 2> /dev/null))
+((tbd += ${duTable[*]: -2:1}))
+
+sources="$CDMNT/isolinux"
+[[ -n $efi ]] && sources+=" $CDMNT/EFI/boot"
+if [[ -n $skipcompress ]]; then
+ if [[ -s $CDMNT/LiveOS/squashfs.img ]]; then
if mount -o loop $CDMNT/LiveOS/squashfs.img $CDMNT; then
- livesize=$(du -s -B 1M $CDMNT/LiveOS/ext3fs.img | awk {'print
$1;'})
+ livesize=($(du -B 1M --apparent-size $CDMNT/LiveOS/ext3fs.img))
umount $CDMNT
else
echo "WARNING: --skipcompress or --xo was specified but the
currently"
@@ -591,22 +600,37 @@ if [ -n "$skipcompress" ]; then
skipcompress=""
fi
fi
+ duTable=($(du -c -B 1M $sources 2> /dev/null))
+ ((livesize += ${duTable[*]: -2:1}))
+else
+ sources+=" $check/osmin.img $check/squashfs.img"
+ duTable=($(du -c -B 1M $sources 2> /dev/null))
+ livesize=${duTable[*]: -2:1}
fi
-free=$(df -B1M $USBDEV |tail -n 1 |awk {'print $4;'})
+
+freespace=($(df -B 1M --total $USBDEV))
+freespace=${freespace[*]: -2:1}
if [ "$isotype" = "live" ]; then
- tba=$(($overlaysizemb + $homesizemb + $livesize + $swapsizemb))
- if [ $tba -gt $(($free + $tbd)) ]; then
- echo "Unable to fit live image + overlay on available space on USB
stick"
- echo "+ Size of live image: $livesize"
- [ "$overlaysizemb" -gt 0 ] && echo "+ Overlay size:
$overlaysizemb"
- [ "$homesizemb" -gt 0 ] && echo "+ Home overlay size: $homesizemb"
- [ "$swapsizemb" -gt 0 ] && echo "+ Swap overlay size: $swapsizemb"
- echo "---------------------------"
- echo "= Requested: $tba"
- echo "- Available: $(($free + $tbd))"
- echo "---------------------------"
- echo "= To fit, free or decrease requested size total by: $(($tba
- $free - $tbd))"
+ tba=$((overlaysizemb + homesizemb + livesize + swapsizemb))
+ if ((tba > freespace + tbd)); then
+ needed=$((tba - freespace - tbd))
+ printf "\n The live image + overlay, home, & swap space, if
requested,
+ \r will NOT fit in the space available on the target device.\n
+ \r + Size of live image: %10s MiB\n" $livesize
+ (($overlaysizemb > 0)) && \
+ printf " + Overlay size: %16s\n" $overlaysizemb
+ (($homesizemb > 0)) && \
+ printf " + Home directory size: %9s\n" $homesizemb
+ (($swapsizemb > 0)) && \
+ printf " + Swap overlay size: %11s\n" $swapsizemb
+ printf " = Total requested space: %6s MiB\n" $tba
+ printf " - Space available: %12s\n" $(($free + $tbd))
+ printf " ==============================\n"
+ printf " Space needed: %15s MiB\n\n" $needed
+ printf " To fit the installation on this device,
+ \r free space on the target, or decrease the
+ \r requested size total by: %s MiB\n\n" $needed
exitclean
fi
fi
--
1.7.3.2
12 years, 10 months
Fedora boot on Mac
by Marcos Barbosa
Someone can explain to me (i can't understand the script) how
livecd-iso-to-disk.sh create a Fedora bootable USB stick compatible with
Mac? Thanks a lot.
--
Marcos Henrique Esteves Barbosa
marcosestevesbarbosa(a)gmail.com
12 years, 10 months
[PATCH] Tolerate empty transactions
by Lubomir Rintel
It can be useful when rebuilding the image without adding or removing a
package.
---
imgcreate/yuminst.py | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/imgcreate/yuminst.py b/imgcreate/yuminst.py
index 9e54982..8aac85d 100644
--- a/imgcreate/yuminst.py
+++ b/imgcreate/yuminst.py
@@ -171,6 +171,10 @@ class LiveCDYum(yum.YumBase):
(res, resmsg) = self.buildTransaction()
except yum.Errors.RepoError, e:
raise CreatorError("Unable to download from repo : %s" %(e,))
+ # Empty transactions are generally fine, we might be rebuilding an
+ # existing image with no packages added
+ if resmsg.endswith(" - empty transaction"):
+ return res
if res != 2:
raise CreatorError("Failed to build transaction : %s" % str.join("\n", resmsg))
--
1.7.3.2
12 years, 10 months