2 # Transfer a Live image so that it's bootable off of a USB/SD device.
3 # Copyright 2007-2012 Red Hat, Inc.
5 # Jeremy Katz <katzj@redhat.com>
6 # Brian C. Lane <bcl@redhat.com>
8 # overlay/persistence enhancements by Douglas McClendon <dmc@viros.org>
9 # GPT+MBR hybrid enhancements by Stewart Adam <s.adam@diffingo.com>
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; version 2 of the License.
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU Library General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write to the Free Software
22 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 export PATH
=/sbin
:/usr
/sbin
:$PATH
31 livecd-iso-to-disk [--help] [--noverify] [--format] [--msdos] [--reset-mbr]
32 [--efi] [--skipcopy] [--force] [--xo] [--xo-no-home]
33 [--timeout <time>] [--totaltimeout <time>]
34 [--extra-kernel-args <args>] [--multi] [--livedir <dir>]
35 [--compress] [--skipcompress] [--swap-size-mb <size>]
36 [--overlay-size-mb <size>] [--home-size-mb <size>]
37 [--delete-home] [--crypted-home] [--unencrypted-home]
38 [--updates updates.img] [--ks kickstart]
39 <source> <target device>
41 (Enter livecd-iso-to-disk --help on the command line for more information.)"
49 livecd-iso-to-disk - Transfer a LiveOS image so that it's bootable off of
52 The script may be run in simplest form with just the two arguments:
55 This may be the filesystem path to a LiveOS .iso image file,
56 such as from a CD-ROM, DVD, or download. It could also be the
57 device node reference for the mount point of another LiveOS
58 filesystem, including the currently-running one (such as a
59 booted Live CD/DVD/USB, where /dev/live references the running
63 This should be the device partition name for the attached,
64 target device, such as /dev/sdb1 or /dev/sdc1. (Issue the
65 df -Th command to get a listing of the mounted partitions,
66 where you can confirm the filesystem types, available space,
67 and device names.) Be careful to specify the correct device,
68 or you may overwrite important data on another disk!
70 To execute the script to completion, you will need to run it with root user
72 SYSLINUX must be installed on the computer running the installation script.
76 livecd-iso-to-disk installs a Live CD/DVD/USB image (LiveOS) onto a USB/SD
77 storage device (or any storage partition that will boot with a SYSLINUX
78 bootloader). The target storage device can then boot the installed
79 operating system on systems that support booting via the USB or the SD
80 interface. The script requires a LiveOS source image and a target storage
81 device. The source image may be either a LiveOS .iso file, the currently-
82 running LiveOS image, the device node reference for an attached device with
83 an installed LiveOS image, or a file backed by a block device with an
84 installed LiveOS image. If the operating system supports persistent
85 overlays for saving system changes, a pre-sized overlay may be included with
88 Unless you request the --format option, the installation does not destroy
89 data outside of the LiveOS, syslinux, & EFI folders on your target device.
90 This allows one to maintain other files on the target disk outside of the
93 LiveOS images provide embedded filesystems through the Device-mapper
94 component of the Linux kernel. The embedded filesystems exist within files
95 such as /LiveOS/squashfs.img (the default compressed storage) or
96 /LiveOS/ext3fs.img (an uncompressed version) on the primary volume partition
97 of the storage device. In use, these are read-only filesystems. Optionally,
98 one may specify a persistent LiveOS overlay to hold image-change snapshots
99 (that use write-once, difference-tracking storage) in the
100 /LiveOS/overlay-<device_id> file, which, *one should note*, always grows in
101 size due to the storage mechanism. (The fraction of allocated space that
102 has been consumed by system activity and changes may be displayed by issuing
103 the 'dmsetup status' command in a terminal session of a running LiveOS
104 image.) One way to conserve the unrecoverable, overlay file space, is to
105 specify a persistent home folder for user files, which will be saved in a
106 /LiveOS/home.img filesystem image file. This file space is encrypted by
107 default, but is not compressed. (One may bypass encryption with the
108 --unencrypted-home installation option.) Files in this home folder may be
109 erased to recover and reuse their storage space. The home.img file is also
110 convenient for backing up or swapping user account files.
115 Displays usage information and exits.
118 Disables the image validation process that occurs before the image is
119 installed from the original Live CD .iso image. When this option is
120 specified, the image is not verified before loading onto the target
124 Formats the target device and creates an MS-DOS partition table (or GPT
125 partition table, if the --efi option is passed).
128 Forces format to use msdos instead of ext4.
131 Sets the Master Boot Record (MBR) of the target storage device to the
132 mbr.bin file from the installation system's syslinux directory. This
133 may be helpful in recovering a damaged or corrupted device.
136 Creates a GUID partition table when --format is passed, and installs a
137 hybrid Extensible Firmware Interface (EFI)/MBR bootloader on the disk.
138 This is necessary for most Intel Macs.
141 Skips the copying of the live image to the target device, bypassing the
142 actions of the --format, --overlay-size-mb, --home-size-mb, &
143 --swap-size-mb options, if present on the command line. (The --skipcopy
144 option may be used while testing the script, in order to avoid repeated
145 and lengthy copy commands, or to repair boot configuration files on a
146 previously installed device.)
149 This option allows the installation script to bypass a delete
150 confirmation dialog in the event that a pre-existing LiveOS directory
151 is found on the target device.
154 Used to prepare an image for the OLPC XO-1 laptop with its compressed,
155 JFFS2 filesystem. Do not use the following options with --xo:
156 --overlay-size-mb <size>, home-size-mb <size>, --delete-home,
160 Used together with the --xo option to prepare an image for an OLPC XO
161 laptop with the home folder on an SD card instead of the internal flash
165 Modifies the bootloader's timeout value, which indicates how long to
166 pause at the boot: prompt before booting automatically. This overrides
167 the value set during iso creation. Units are 1/10 s. The timeout is
168 canceled when any key is pressed, the assumption being that the user
169 will complete the command line. A timeout of zero will disable the
173 Adds a bootloader totaltimeout, which indicates how long to wait before
174 booting automatically. This is used to force an automatic boot. This
175 timeout cannot be canceled by the user. Units are 1/10 s.
177 --extra-kernel-args <args>
178 Specifies additional kernel arguments, <args>, that will be inserted
179 into the syslinux and EFI boot configurations. Multiple arguments
180 should be specified in one string, i.e.,
181 --extra-kernel-args \"arg1 arg2 ...\"
184 Used when installing multiple image copies to signal configuration of
185 the boot files for the image in the --livedir <dir> parameter.
189 Used with multiple image installations to designate the directory <dir>
190 for the particular image.
192 --compress (default state for the operating system files)
193 The default, compressed SquashFS filesystem image is copied on
194 installation. This option has no effect when the source filesystem is
197 --skipcompress (default option when --xo is specified)
198 Expands the source SquashFS image on installation into the read-only
199 /LiveOS/ext3fs.img filesystem image file.
201 --swap-size-mb <size>
202 Sets up a swap file of <size> mebibytes (integer values only) on the
205 --overlay-size-mb <size>
206 This option sets the overlay size in mebibytes (integer values only).
207 The overlay makes persistent storage available to the live operating
208 system, if the operating system supports it. The persistent LiveOS
209 overlay holds image-change snapshots (using write-once, difference-
210 tracking storage) in the /LiveOS/overlay-<device_id> file, which, *one
211 should note*, always grows in size due to the storage mechanism. (The
212 fraction of allocated space that has been consumed may be displayed by
213 issuing the 'dmsetup status' command in a terminal session of a running
214 LiveOS installation.) One way to conserve the unrecoverable, overlay
215 file space, is to specify a persistent home folder for user files, see
216 --home-size-mb below. The target storage device must have enough free
217 space for the image and the overlay. A maximum <size> of 4095 MiB is
218 permitted for vfat-formatted devices. If there is insufficient room on
219 your device, you will be given information to help in adjusting your
222 --home-size-mb <size>
223 Sets the home directory size in mebibytes (integer values only). A
224 persistent home directory will be made in the /LiveOS/home.img
225 filesystem image file. This file space is encrypted by default, but not
226 compressed (one may bypass encryption with the --unencrypted-home
227 installation option). Files in this home folder may be erased to
228 recover and reuse their storage space. The target storage device must
229 have enough free space for the image, any overlay, and the home
230 directory. Note that the --delete-home option must also be selected to
231 replace an existing persistent home with a new, empty one. A maximum
232 <size> of 4095 MiB is permitted for vfat-formatted devices. If there is
233 insufficient room on your device, you will be given information to help
234 in adjusting your settings.
237 To prevent unwitting deletion of user files, this option must be
238 explicitly selected when the option --home-size-mb <size> is selected
239 and there is an existing persistent home directory on the target device.
241 --crypted-home (default that only applies to new home-size-mb requests)
242 Specifies the default option to encrypt a new persistent home directory
243 if --home-size-mb <size> is specified.
246 Prevents the default option to encrypt a new persistent home directory.
248 --updates updates.img
249 Setup inst.updates to point to an updates image on the device. Anaconda
250 uses this for testing updates to an iso without needing to make a new iso.
253 Setup inst.ks to point to an kickstart file on the device. Use this for
254 automating installs on boot.
258 livecd-iso-to-disk: David Zeuthen, Jeremy Katz, Douglas McClendon,
259 Chris Curran and other contributors.
260 (See the AUTHORS file in the source distribution for
261 the complete list of credits.)
265 Report bugs to the mailing list
266 http://admin.fedoraproject.org/mailman/listinfo/livecd or directly to
267 Bugzilla http://bugzilla.redhat.com/bugzilla/ against the Fedora product,
268 and the livecd-tools component.
272 Copyright (C) Fedora Project 2008, 2009, 2010 and various contributors.
273 This is free software. You may redistribute copies of it under the terms of
274 the GNU General Public License http://www.gnu.org/licenses/gpl.html.
275 There is NO WARRANTY, to the extent permitted by law.
279 livecd-creator, project website http://fedoraproject.org/wiki/FedoraLiveCD
286 [ -d "$SRCMNT" ] && umount
$SRCMNT && rmdir $SRCMNT
287 [ -d "$TGTMNT" ] && umount
$TGTMNT && rmdir $TGTMNT
292 if [ -d "$SRCMNT" ] ||
[ -d "$TGTMNT" ];
294 [ "$RETVAL" = 0 ] ||
echo "Cleaning up to exit..."
301 [ x
"${1#/dev/loop}" != x
"$1" ]
307 if isdevloop
"$DEV"; then
312 p
=$
(udevadm info
-q path
-n $DEV)
313 if [ $?
-gt 0 ]; then
314 echo "Error getting udev path to $DEV"
317 if [ -e /sys
/$p/device
]; then
318 device
=$
(basename /sys
/$p)
320 device
=$
(basename $
(readlink
-f /sys
/$p/..
/))
322 if [ ! -e /sys
/block
/$device -o ! -e /dev
/$device ]; then
323 echo "Error finding block device of $DEV. Aborting!"
327 device
="/dev/$device"
328 # FIXME: weird dev names could mess this up I guess
329 p
=/dev
/$
(basename $p)
330 partnum
=${p##$device}
334 if isdevloop
"$DEV"; then
338 # if efi, we need to use the hybrid MBR
339 if [ -n "$efi" ]; then
340 if [ -f /usr
/lib
/syslinux
/gptmbr.bin
]; then
341 cat /usr
/lib
/syslinux
/gptmbr.bin
> $device
342 elif [ -f /usr
/share
/syslinux
/gptmbr.bin
]; then
343 cat /usr
/share
/syslinux
/gptmbr.bin
> $device
345 echo "Could not find gptmbr.bin (syslinux)"
348 # Make it bootable on EFI and BIOS
349 parted
-s $device set $partnum legacy_boot on
351 if [ -f /usr
/lib
/syslinux
/mbr.bin
]; then
352 cat /usr
/lib
/syslinux
/mbr.bin
> $device
353 elif [ -f /usr
/share
/syslinux
/mbr.bin
]; then
354 cat /usr
/share
/syslinux
/mbr.bin
> $device
356 echo "Could not find mbr.bin (syslinux)"
363 if isdevloop
"$DEV"; then
368 bs
=$
(mktemp
/tmp
/bs.XXXXXX
)
369 dd if=$device of
=$bs bs
=512 count
=1 2>/dev
/null ||
exit 2
371 mbrword
=$
(hexdump -n 2 $bs |
head -n 1|
awk {'print $2;'})
373 if [ "$mbrword" = "0000" ]; then
374 if [ -z "$format" ]; then
375 echo "MBR appears to be blank."
376 echo "Press Enter to replace the MBR and continue or ctrl-c to abort"
389 # if we're installing to whole-disk and not a partition, then we
390 # don't need to worry about being active
391 if [ "$dev" = "$device" ]; then
394 if isdevloop
"$DEV"; then
398 if [ "$(/sbin/fdisk -l $device 2>/dev/null |grep -m1 $dev |awk {'print $2;'})" != "*" ]; then
399 echo "Partition isn't marked bootable!"
400 echo "You can mark the partition as bootable with "
401 echo " # /sbin/parted $device"
402 echo " (parted) toggle N boot"
403 echo " (parted) quit"
411 if [ -x /sbin
/pvs
-a \
412 "$(/sbin/pvs -o vg_name --noheadings $dev* 2>/dev/null || :)" ]; then
413 echo "Device, $dev, contains a volume group and cannot be formated!"
414 echo "You can remove the volume group using vgremove."
424 echo "WARNING: THIS WILL DESTROY ANY DATA ON $device!!!"
425 echo "Press Enter to continue or ctrl-c to abort"
427 umount
${device}* &> /dev
/null ||
:
429 /sbin
/parted
--script $device mklabel gpt
430 partinfo
=$
(LC_ALL
=C
/sbin
/parted
--script -m $device "unit MB print" |
grep ^
$device:)
431 dev_size
=$
(echo $partinfo |cut
-d : -f 2 |
sed -e 's/MB$//')
432 p1_size
=$
(($dev_size - 3))
434 if [ $p1_size -le 0 ]; then
435 echo "Your device isn't big enough to hold $SRC"
436 echo "It is $(($p1_size * -1)) MB too small"
440 p1_end
=$
(($p1_size + 1))
441 /sbin
/parted
-s $device u MB mkpart
'"EFI System Partition"' fat32
$p1_start $p1_end set 1 boot on
442 # Sometimes automount can be _really_ annoying.
443 echo "Waiting for devices to settle..."
447 umount
$TGTDEV &> /dev
/null ||
:
448 /sbin
/mkdosfs
-n LIVE
$TGTDEV
449 TGTLABEL
="UUID=$(/sbin/blkid -s UUID -o value $TGTDEV)"
452 createMSDOSLayout
() {
456 echo "WARNING: THIS WILL DESTROY ANY DATA ON $device!!!"
457 echo "Press Enter to continue or ctrl-c to abort"
459 umount
${device}* &> /dev
/null ||
:
461 /sbin
/parted
--script $device mklabel msdos
462 partinfo
=$
(LC_ALL
=C
/sbin
/parted
--script -m $device "unit MB print" |
grep ^
$device:)
463 dev_size
=$
(echo $partinfo |cut
-d : -f 2 |
sed -e 's/MB$//')
464 p1_size
=$
(($dev_size - 3))
466 if [ $p1_size -le 0 ]; then
467 echo "Your device isn't big enough to hold $SRC"
468 echo "It is $(($p1_size * -1)) MB too small"
472 p1_end
=$
(($p1_size + 1))
473 /sbin
/parted
-s $device u MB mkpart primary fat32
$p1_start $p1_end set 1 boot on
474 # Sometimes automount can be _really_ annoying.
475 echo "Waiting for devices to settle..."
478 if ! isdevloop
"$DEV"; then
483 umount
$TGTDEV &> /dev
/null ||
:
484 /sbin
/mkdosfs
-n LIVE
$TGTDEV
485 TGTLABEL
="UUID=$(/sbin/blkid -s UUID -o value $TGTDEV)"
488 createEXTFSLayout
() {
492 echo "WARNING: THIS WILL DESTROY ANY DATA ON $device!!!"
493 echo "Press Enter to continue or ctrl-c to abort"
495 umount
${device}* &> /dev
/null ||
:
497 /sbin
/parted
-s $device mklabel msdos
498 partinfo
=$
(LC_ALL
=C
/sbin
/parted
-s -m $device "u MB print" |
grep ^
$device:)
499 dev_size
=$
(echo $partinfo |cut
-d : -f 2 |
sed -e 's/MB$//')
500 p1_size
=$
(($dev_size - 3))
502 if [ $p1_size -le 0 ]; then
503 echo "Your device isn't big enough to hold $SRC"
504 echo "It is $(($p1_size * -1)) MB too small"
508 p1_end
=$
(($p1_size + 1))
509 /sbin
/parted
-s $device u MB mkpart primary ext2
$p1_start $p1_end set 1 boot on
510 # Sometimes automount can be _really_ annoying.
511 echo "Waiting for devices to settle..."
515 umount
$TGTDEV &> /dev
/null ||
:
517 # Check extlinux version
518 if extlinux
-v 2>&1 |
grep -q 'extlinux 3'; then
523 $mkfs -L LIVE
$TGTDEV
524 TGTLABEL
="UUID=$(/sbin/blkid -s UUID -o value $TGTDEV)"
531 if [ "$(/sbin/parted -m $device p 2>/dev/null |grep -ic :gpt:)" -eq "0" ]; then
532 echo "EFI boot requires a GPT partition table."
533 echo "This can be done manually or you can run with --format"
537 partinfo
=$
(LC_ALL
=C
/sbin
/parted
--script -m $device "print" |
grep ^
$partnum:)
538 volname
=$
(echo $partinfo |cut
-d : -f 6)
539 flags
=$
(echo $partinfo |cut
-d : -f 7)
540 if [ "$volname" != "EFI System Partition" ]; then
541 echo "Partition name must be 'EFI System Partition'"
542 echo "This can be set in parted or you can run with --reset-mbr"
545 if [ "$(echo $flags |grep -c boot)" = "0" ]; then
546 echo "Partition isn't marked bootable!"
547 echo "You can mark the partition as bootable with "
548 echo " # /sbin/parted $device"
549 echo " (parted) toggle N boot"
550 echo " (parted) quit"
558 TGTFS
=$
(/sbin
/blkid
-s TYPE
-o value
$dev ||
:)
559 if [ "$TGTFS" != "vfat" ] && [ "$TGTFS" != "msdos" ]; then
560 if [ "$TGTFS" != "ext2" ] && [ "$TGTFS" != "ext3" ] && [ "$TGTFS" != "ext4" ] && [ "$TGTFS" != "btrfs" ]; then
561 echo "Target filesystem ($dev:$TGTFS) must be vfat, ext[234] or btrfs"
566 TGTLABEL
=$
(/sbin
/blkid
-s LABEL
-o value
$dev)
567 if [ "$TGTLABEL" != "LIVE" ]; then
568 if [ "$TGTFS" = "vfat" -o "$TGTFS" = "msdos" ]; then
569 /sbin
/dosfslabel
$dev LIVE
570 if [ $?
-gt 0 ]; then
571 echo "dosfslabel failed on $dev, device not setup"
574 elif [ "$TGTFS" = "ext2" -o "$TGTFS" = "ext3" -o "$TGTFS" = "ext4" ]; then
575 /sbin
/e2label
$dev LIVE
576 if [ $?
-gt 0 ]; then
577 echo "e2label failed on $dev, device not setup"
581 echo "Unknown filesystem type. Try setting its label to LIVE and re-running"
586 # Use UUID if available
587 TGTUUID
=$
(/sbin
/blkid
-s UUID
-o value
$dev)
588 if [ -n "$TGTUUID" ]; then
589 TGTLABEL
="UUID=$TGTUUID"
591 TGTLABEL
="LABEL=LIVE"
594 if [ "$TGTFS" = "vfat" -o "$TGTFS" = "msdos" ]; then
595 mountopts
="-o shortname=winnt,umask=0077"
599 checkSyslinuxVersion
() {
600 if [ ! -x /usr
/bin
/syslinux
]; then
601 echo "You need to have syslinux installed to run this script"
604 check
=($
(syslinux
--version 2>&1)) ||
:
605 if [[ 'syslinux' != $check ]]; then
607 elif [ -n "$multi" ]; then
608 SYSLINUXPATH
="$LIVEOS/syslinux"
610 SYSLINUXPATH
="syslinux"
616 if grep -q "^$dev " /proc
/mounts
; then
617 echo "$dev is mounted, please unmount for safety"
620 if grep -q "^$dev " /proc
/swaps
; then
621 echo "$dev is in use as a swap device, please disable swap"
627 if ! test $1 -gt 0 2>/dev
/null
; then
633 if [ $
(id
-u) != 0 ]; then
634 echo "You need to be root to run this script"
639 if [[ -e "$SRCMNT/Packages" ]]; then
640 echo "/Packages found, will copy source packages to target"
643 if [[ -e "$SRCMNT/LiveOS/squashfs.img" ]]; then
644 # LiveOS style boot image
648 if [ -e $SRCMNT/images
/install.img
-o -e $SRCMNT/isolinux
/initrd.img
]; then
649 if [ -n "$packages" ]; then
655 if [ ! -e $SRCMNT/images
/install.img
]; then
656 echo "$SRC uses initrd.img w/o install.img"
661 echo "ERROR: $SRC does not appear to be a Live image or DVD installer."
666 strace
-q -ewrite cp -- "${1}" "${2}" 2>&1 \
669 if (count % 10 == 0) {
670 percent = count / total_size * 100
671 printf "%3d%% [", percent
672 for (i=0;i<=percent;i++)
675 for (i=percent;i<100;i++)
680 END { print "" }' total_size
=$
(stat
-c '%s' "${1}") count
=0
684 if [ -x /usr
/bin
/rsync
]; then
685 rsync
--inplace -P "$1" "$2"
688 if [ -x /usr
/bin
/gvfs-copy
]; then
689 gvfs-copy
-p "$1" "$2"
692 if [ -x /usr
/bin
/strace
-a -x /bin
/awk ]; then
717 if [[ "$*" =~
"--help" ]]; then
720 while [ $# -gt 2 ]; do
734 --reset-mbr|
--resetmbr)
813 echo "invalid arg -- $1"
821 SRC
=$
(readlink
-f "$1")
822 TGTDEV
=$
(readlink
-f "$2")
824 if [ -z "$SRC" ]; then
825 echo "Missing source"
830 if [ ! -b "$SRC" -a ! -f "$SRC" ]; then
831 echo "$SRC is not a file or block device"
836 if [ -z "$TGTDEV" ]; then
837 echo "Missing target device"
842 if [ ! -b "$TGTDEV" ]; then
843 echo "$TGTDEV is not a block device"
848 if [ -z "$noverify" ]; then
850 echo "Verifying image..."
851 if ! checkisomd5
--verbose "$SRC"; then
852 echo "Are you SURE you want to continue?"
853 echo "Press Enter to continue or ctrl-c to abort"
858 # do some basic sanity checks.
861 # FIXME: would be better if we had better mountpoints
862 SRCMNT
=$
(mktemp
-d /media
/srctmp.XXXXXX
)
863 if [ -b "$SRC" ]; then
864 mount
-o ro
"$SRC" $SRCMNT || exitclean
865 elif [ -f "$SRC" ]; then
866 mount
-o loop
,ro
"$SRC" $SRCMNT || exitclean
868 echo "$SRC is not a file or block device."
871 # Figure out what needs to be done based on the source image
875 if [ -n "$format" -a -z "$skipcopy" ]; then
878 if [ -n "$efi" ]; then
879 createGPTLayout
$TGTDEV
880 elif [ -n "$usemsdos" -o ! -x /sbin
/extlinux
]; then
881 createMSDOSLayout
$TGTDEV
883 createEXTFSLayout
$TGTDEV
887 checkFilesystem
$TGTDEV
888 if [ -n "$efi" ]; then
893 # Because we can't set boot flag for EFI Protective on msdos partition tables
894 [ -z "$efi" ] && checkPartActive
$TGTDEV
895 [ -n "$resetmbr" ] && resetMBR
$TGTDEV
899 if [ "$overlaysizemb" -gt 0 ]; then
900 if [ "$TGTFS" = "vfat" -a "$overlaysizemb" -gt 4095 ]; then
901 echo "Can't have an overlay of 4095MB or greater on VFAT"
904 LABEL
=$
(/sbin
/blkid
-s LABEL
-o value
$TGTDEV)
905 if [[ "$LABEL" =~
( ) ]]; then
906 echo "The LABEL($LABEL) on $TGTDEV has spaces in it, which do not work with the overlay"
907 echo "You can re-format or use dosfslabel/e2fslabel to change it"
912 if [ "$homesizemb" -gt 0 -a "$TGTFS" = "vfat" ]; then
913 if [ "$homesizemb" -gt 4095 ]; then
914 echo "Can't have a home overlay greater than 4095MB on VFAT"
919 if [ "$swapsizemb" -gt 0 -a "$TGTFS" = "vfat" ]; then
920 if [ "$swapsizemb" -gt 4095 ]; then
921 echo "Can't have a swap file greater than 4095MB on VFAT"
926 TGTMNT
=$
(mktemp
-d /media
/tgttmp.XXXXXX
)
927 mount
$mountopts $TGTDEV $TGTMNT || exitclean
929 trap exitclean SIGINT SIGTERM
931 if [ -f "$TGTMNT/$LIVEOS/$HOMEFILE" -a -n "$keephome" -a "$homesizemb" -gt 0 ]; then
932 echo "ERROR: Requested keeping existing /home and specified a size for /home"
933 echo "Please either don't specify a size or specify --delete-home"
937 if [ -n "$efi" ]; then
938 if [ -d $SRCMNT/EFI
/BOOT
]; then
940 elif [ -d $SRCMNT/EFI
/boot
]; then
943 echo "ERROR: This live image does not support EFI booting"
948 # let's try to make sure there's enough room on the target device
949 if [[ -d $TGTMNT/$LIVEOS ]]; then
950 tbd
=($
(du
-B 1M
$TGTMNT/$LIVEOS))
951 if [[ -s $TGTMNT/$LIVEOS/$HOMEFILE ]] && [[ -n $keephome ]]; then
952 homesize
=($
(du
-B 1M
$TGTMNT/$LIVEOS/$HOMEFILE))
953 tbd
=$
((tbd
- homesize
))
959 if [[ live
== $srctype ]]; then
960 targets
="$TGTMNT/$SYSLINUXPATH"
961 [[ -n $efi ]] && targets
+=" $TGTMNT$EFI_BOOT"
962 [[ -n $xo ]] && targets
+=" $TGTMNT/boot/olpc.fth"
963 target_size
=$
(du
-s -c -B 1M
$targets 2> /dev
/null |
awk '/total$/ {print $1;}') ||
:
964 tbd
=$
((tbd
+ target_size
))
967 if [[ -n $skipcompress ]] && [[ -s $SRCMNT/LiveOS
/squashfs.img
]]; then
968 if mount
-o loop
$SRCMNT/LiveOS
/squashfs.img
$SRCMNT; then
969 livesize
=($
(du
-B 1M
--apparent-size $SRCMNT/LiveOS
/ext3fs.img
))
971 if ((livesize
> 4095)) && [[ vfat
== $TGTFS ]]; then
973 An uncompressed image size greater than 4095 MB is not suitable
974 for a VFAT-formatted device. The compressed SquashFS will be
975 copied to the target device.
981 echo "WARNING: --skipcompress or --xo was specified but the
982 currently-running kernel can not mount the SquashFS from the source
983 file to extract it. Instead, the compressed SquashFS will be copied
984 to the target device."
988 if [[ live
== $srctype ]]; then
989 thisScriptpath
=$
(readlink
-f "$0")
990 sources
="$SRCMNT/LiveOS/ext3fs.img $SRCMNT/LiveOS/osmin.img"
991 [[ -z $skipcompress ]] && sources
+=" $SRCMNT/LiveOS/squashfs.img"
992 sources
+=" $SRCMNT/isolinux $SRCMNT/syslinux"
993 [[ -n $efi ]] && sources
+=" $SRCMNT$EFI_BOOT"
994 [[ -n $xo ]] && sources
+=" $SRCMNT/boot/olpc.fth"
995 source_size
=$
(du
-s -c -B 1M
"$thisScriptpath" $sources 2> /dev
/null |
awk '/total$/ {print $1;}') ||
:
996 livesize
=$
((livesize
+ source_size
))
999 freespace
=$
(df
-B 1M
--total $TGTDEV |
awk '/^total/ {print $4;}')
1001 if [[ live
== $srctype ]]; then
1002 tba
=$
((overlaysizemb
+ homesizemb
+ livesize
+ swapsizemb
))
1003 if ((tba
> freespace
+ tbd
)); then
1004 needed
=$
((tba
- freespace
- tbd
))
1005 printf "\n The live image + overlay, home, & swap space, if requested,
1006 \r will NOT fit in the space available on the target device.\n
1007 \r + Size of live image: %10s MiB\n" $livesize
1008 (($overlaysizemb > 0)) && \
1009 printf " + Overlay size: %16s\n" $overlaysizemb
1010 (($homesizemb > 0)) && \
1011 printf " + Home directory size: %9s\n" $homesizemb
1012 (($swapsizemb > 0)) && \
1013 printf " + Swap overlay size: %11s\n" $swapsizemb
1014 printf " = Total requested space: %6s MiB\n" $tba
1015 printf " - Space available: %12s\n" $
((freespace
+ tbd
))
1016 printf " ==============================\n"
1017 printf " Space needed: %15s MiB\n\n" $needed
1018 printf " To fit the installation on this device,
1019 \r free space on the target, or decrease the
1020 \r requested size total by: %6s MiB\n\n" $needed
1025 # Verify available space for DVD installer
1026 if [ "$srctype" = "installer" ]; then
1027 if [ "$imgtype" = "install" ]; then
1028 imgpath
=images
/install.img
1030 imgpath
=isolinux
/initrd.img
1032 installimgsize
=$
(du
-s -B 1M
$SRCMNT/$imgpath |
awk {'print $1;'})
1035 if [ -e $TGTMNT/$imgpath ]; then
1036 tbd
=$
(du
-s -B 1M
$TGTMNT/$imgpath |
awk {'print $1;'})
1038 if [ -e "$TGTMNT/$(basename "$SRC")" ]; then
1039 tbd
=$
(($tbd + $
(du
-s -B 1M
"$TGTMNT/$(basename "$SRC")" |
awk {'print $1;'})))
1041 echo "Size of $imgpath: $installimgsize"
1042 echo "Available space: $((freespace + tbd))"
1043 if (( installimgsize
> ((freespace
+ tbd
)) )); then
1044 echo "ERROR: Unable to fit DVD image + install.img on available space on the target device."
1049 if [ -z "$skipcopy" ] && [ "$srctype" = "live" ]; then
1050 if [ -d $TGTMNT/$LIVEOS -a -z "$force" ]; then
1051 echo "Already set up as live image."
1052 if [ -z "$keephome" -a -e $TGTMNT/$LIVEOS/$HOMEFILE ]; then
1053 echo "WARNING: Persistent /home will be deleted!!!"
1054 echo "Press Enter to continue or ctrl-c to abort"
1057 echo "Deleting old OS in fifteen seconds..."
1060 [ -e "$TGTMNT/$LIVEOS/$HOMEFILE" -a -n "$keephome" ] && mv $TGTMNT/$LIVEOS/$HOMEFILE $TGTMNT/$HOMEFILE
1063 rm -rf $TGTMNT/$LIVEOS
1067 # Bootloader is always reconfigured, so keep these out of the if skipcopy stuff.
1068 [ ! -d $TGTMNT/$SYSLINUXPATH ] && mkdir
-p $TGTMNT/$SYSLINUXPATH
1069 [ -n "$efi" -a ! -d $TGTMNT$EFI_BOOT ] && mkdir
-p $TGTMNT$EFI_BOOT
1072 if [ "$srctype" = "live" -a -z "$skipcopy" ]; then
1073 echo "Copying live image to target device."
1074 [ ! -d $TGTMNT/$LIVEOS ] && mkdir
$TGTMNT/$LIVEOS
1075 [ -n "$keephome" -a -f "$TGTMNT/$HOMEFILE" ] && mv $TGTMNT/$HOMEFILE $TGTMNT/$LIVEOS/$HOMEFILE
1076 if [ -n "$skipcompress" -a -f $SRCMNT/LiveOS
/squashfs.img
]; then
1077 mount
-o loop
$SRCMNT/LiveOS
/squashfs.img
$SRCMNT || exitclean
1078 copyFile
$SRCMNT/LiveOS
/ext3fs.img
$TGTMNT/$LIVEOS/ext3fs.img ||
{
1079 umount
$SRCMNT ; exitclean
; }
1081 elif [ -f $SRCMNT/LiveOS
/squashfs.img
]; then
1082 copyFile
$SRCMNT/LiveOS
/squashfs.img
$TGTMNT/$LIVEOS/squashfs.img || exitclean
1083 elif [ -f $SRCMNT/LiveOS
/ext3fs.img
]; then
1084 copyFile
$SRCMNT/LiveOS
/ext3fs.img
$TGTMNT/$LIVEOS/ext3fs.img || exitclean
1086 if [ -f $SRCMNT/LiveOS
/osmin.img
]; then
1087 copyFile
$SRCMNT/LiveOS
/osmin.img
$TGTMNT/$LIVEOS/osmin.img || exitclean
1092 # Adjust syslinux sources for replication of installed images
1093 # between filesystem types.
1094 if [[ -d $SRCMNT/isolinux
/ ]]; then
1095 cp $SRCMNT/isolinux
/* $TGTMNT/$SYSLINUXPATH
1096 elif [[ -d $SRCMNT/syslinux
/ ]]; then
1097 cp $SRCMNT/syslinux
/* $TGTMNT/$SYSLINUXPATH
1098 if [[ -f $SRCMNT/syslinux
/extlinux.conf
]]; then
1099 mv $TGTMNT/$SYSLINUXPATH/extlinux.conf \
1100 $TGTMNT/$SYSLINUXPATH/isolinux.cfg
1101 elif [[ -f $SRCMNT/syslinux
/syslinux.cfg
]]; then
1102 mv $TGTMNT/$SYSLINUXPATH/syslinux.cfg
$TGTMNT/$SYSLINUXPATH/isolinux.cfg
1105 BOOTCONFIG
=$TGTMNT/$SYSLINUXPATH/isolinux.cfg
1106 # Set this to nothing so sed doesn't care
1108 if [ -n "$efi" ]; then
1109 echo "Setting up $EFI_BOOT"
1110 cp -r $SRCMNT$EFI_BOOT/* $TGTMNT$EFI_BOOT
1112 # The GRUB EFI config file can be one of:
1116 if [ -e $TGTMNT$EFI_BOOT/grub.cfg
]; then
1117 BOOTCONFIG_EFI
=$TGTMNT$EFI_BOOT/grub.cfg
1118 elif [ -e $TGTMNT$EFI_BOOT/+(BOOT|boot
)?
*.conf
]; then
1119 BOOTCONFIG_EFI
=$TGTMNT$EFI_BOOT/+(BOOT|boot
)?
*.conf
1121 echo "Unable to find EFI config file."
1124 rm -f $TGTMNT$EFI_BOOT/grub.conf
1126 # On some images (RHEL) the BOOT*.efi file isn't in $EFI_BOOT, but is in
1127 # the eltorito image, so try to extract it if it is missing
1129 # test for presence of *.efi grub binary
1130 if [ ! -f $TGTMNT$EFI_BOOT/+(BOOT|boot
)?
*.efi
]; then
1131 if [ ! -x /usr
/bin
/dumpet
]; then
1132 echo "No /usr/bin/dumpet tool found. EFI image will not boot."
1133 echo "Source media is missing grub binary in /EFI/BOOT/*efi"
1136 # dump the eltorito image with dumpet, output is $SRC.1
1138 EFIMNT
=$
(mktemp
-d /media
/srctmp.XXXXXX
)
1139 mount
-o loop
"$SRC".1 $EFIMNT
1141 if [ -f $EFIMNT$EFI_BOOT/+(BOOT|boot
)?
*.efi
]; then
1142 cp $EFIMNT$EFI_BOOT/+(BOOT|boot
)?
*.efi
$TGTMNT$EFI_BOOT
1144 echo "No BOOT*.efi found in eltorito image. EFI will not boot"
1155 # DVD installer copy
1156 if [ -z "$skipcopy" -a \
( "$srctype" = "installer" -o "$srctype" = "netinst" \
) ]; then
1157 echo "Copying DVD image to target device."
1158 mkdir
-p $TGTMNT/images
/
1159 if [ "$imgtype" = "install" ]; then
1160 for img
in install.img updates.img product.img
; do
1161 if [ -e $SRCMNT/images
/$img ]; then
1162 copyFile
$SRCMNT/images
/$img $TGTMNT/images
/$img || exitclean
1168 # Copy packages over.
1169 # Before Fedora17 we could copy the .iso and setup a repo=
1170 # F17 and later look for repodata on the source media.
1171 # The presence of packages and LiveOS indicates F17 or later.
1172 if [ -n "$packages" -a -z "$skipcopy" ]; then
1173 if [ "$srctype" != "live" ]; then
1174 echo "Copying $SRC to device"
1175 copyFile
"$SRC" "$TGTMNT/"
1177 # Setup a repo= to point to the .iso
1178 sed -i -e "s;initrd.img;initrd.img repo=hd:$TGTLABEL:/;g" $BOOTCONFIG
1179 if [ -n "$efi" ]; then
1180 sed -i -e "s;vmlinuz;vmlinuz repo=hd:$TGTLABEL:/;g" $BOOTCONFIG_EFI
1183 echo "Copying package data from $SRC to device"
1184 rsync
--inplace -rLDP --exclude EFI
/ --exclude images
/ --exclude isolinux
/ \
1185 --exclude TRANS.TBL
--exclude LiveOS
/ "$SRCMNT/" "$TGTMNT/"
1187 echo "Waiting for device to finish writing"
1191 if [ "$srctype" = "live" ]; then
1192 # Copy this installer script.
1193 cp -fT "$thisScriptpath" $TGTMNT/$LIVEOS/livecd-iso-to-disk
1194 chmod +x
$TGTMNT/$LIVEOS/livecd-iso-to-disk
&> /dev
/null ||
:
1196 # When the source is an installed Live USB/SD image, restore the boot config
1197 # file to a base state before updating.
1198 if [[ -d $SRCMNT/syslinux
/ ]]; then
1199 echo "Preparing boot config file."
1200 sed -i -e "s/root=live:[^ ]*/root=live:CDLABEL=name/"\
1201 -e "s/\(r*d*.*live.*ima*ge*\) .* quiet/\1 quiet/"\
1202 $BOOTCONFIG $BOOTCONFIG_EFI
1203 sed -i -e "s/^timeout.*$/timeout\ 100/"\
1204 -e "/^totaltimeout.*$/d" $BOOTCONFIG
1208 # Setup the updates.img
1209 if [ -n "$updates" ]; then
1210 copyFile
"$updates" "$TGTMNT/updates.img"
1211 kernelargs
+=" inst.updates=hd:$TGTLABEL:/updates.img"
1214 # Setup the kickstart
1215 if [ -n "$ks" ]; then
1216 copyFile
"$ks" "$TGTMNT/ks.cfg"
1217 kernelargs
+=" inst.ks=hd:$TGTLABEL:/ks.cfg"
1220 echo "Updating boot config file"
1221 # adjust label and fstype
1222 sed -i -e "s/CDLABEL=[^ ]*/$TGTLABEL/" -e "s/rootfstype=[^ ]*/rootfstype=$TGTFS/" -e "s/LABEL=[^ ]*/$TGTLABEL/" $BOOTCONFIG $BOOTCONFIG_EFI
1223 if [ -n "$kernelargs" ]; then
1224 sed -i -e "s;initrd.\?\.img;& ${kernelargs};" $BOOTCONFIG
1225 if [ -n "$efi" ]; then
1226 sed -i -e "s;vmlinuz.\?;& ${kernelargs} ;" $BOOTCONFIG_EFI
1229 if [ "$LIVEOS" != "LiveOS" ]; then
1230 sed -i -e "s;r*d*.*live.*ima*ge*;& live_dir=$LIVEOS;"\
1231 $BOOTCONFIG $BOOTCONFIG_EFI
1234 # EFI images are in $SYSLINUXPATH now
1235 if [ -n "$efi" ]; then
1236 sed -i -e "s;/isolinux/;/$SYSLINUXPATH/;g" $BOOTCONFIG_EFI
1237 sed -i -e "s;/images/pxeboot/;/$SYSLINUXPATH/;g" $BOOTCONFIG_EFI
1238 sed -i -e "s;findiso;;g" $BOOTCONFIG_EFI
1241 # DVD Installer for netinst
1242 if [ "$srctype" != "live" ]; then
1243 if [ "$imgtype" = "install" ]; then
1244 sed -i -e "s;initrd.img;initrd.img stage2=hd:$TGTLABEL:/images/install.img;g" $BOOTCONFIG
1245 if [ -n "$efi" ]; then
1246 sed -i -e "s;vmlinuz;vmlinuz stage2=hd:$TGTLABEL:/images/install.img;g" $BOOTCONFIG_EFI
1249 # The initrd has everything, so no stage2
1250 sed -i -e "s;stage2=\S*;;g" $BOOTCONFIG $BOOTCONFIG_EFI
1254 # Adjust the boot timeouts
1255 if [ -n "$timeout" ]; then
1256 sed -i -e "s/^timeout.*$/timeout\ $timeout/" $BOOTCONFIG
1258 if [ -n "$totaltimeout" ]; then
1259 sed -i -e "/^timeout.*$/a\totaltimeout\ $totaltimeout" $BOOTCONFIG
1262 if [ "$overlaysizemb" -gt 0 ]; then
1263 echo "Initializing persistent overlay file"
1264 OVERFILE
="overlay-$( /sbin/blkid -s LABEL -o value $TGTDEV )-$( /sbin/blkid -s UUID -o value $TGTDEV )"
1265 if [ -z "$skipcopy" ]; then
1266 if [ "$TGTFS" = "vfat" ]; then
1267 # vfat can't handle sparse files
1268 dd if=/dev
/zero of
=$TGTMNT/$LIVEOS/$OVERFILE count
=$overlaysizemb bs
=1M
1270 dd if=/dev
/null of
=$TGTMNT/$LIVEOS/$OVERFILE count
=1 bs
=1M seek
=$overlaysizemb
1273 sed -i -e "s/r*d*.*live.*ima*ge*/& overlay=${TGTLABEL}/"\
1274 $BOOTCONFIG $BOOTCONFIG_EFI
1275 sed -i -e "s/\ ro\ /\ rw\ /" $BOOTCONFIG $BOOTCONFIG_EFI
1278 if [ "$swapsizemb" -gt 0 -a -z "$skipcopy" ]; then
1279 echo "Initializing swap file"
1280 dd if=/dev
/zero of
=$TGTMNT/$LIVEOS/swap.img count
=$swapsizemb bs
=1M
1281 mkswap
-f $TGTMNT/$LIVEOS/swap.img
1284 if [ "$homesizemb" -gt 0 -a -z "$skipcopy" ]; then
1285 echo "Initializing persistent /home"
1286 homesource
=/dev
/zero
1287 [ -n "$cryptedhome" ] && homesource
=/dev
/urandom
1288 if [ "$TGTFS" = "vfat" ]; then
1289 # vfat can't handle sparse files
1290 dd if=${homesource} of
=$TGTMNT/$LIVEOS/$HOMEFILE count
=$homesizemb bs
=1M
1292 dd if=/dev
/null of
=$TGTMNT/$LIVEOS/$HOMEFILE count
=1 bs
=1M seek
=$homesizemb
1294 if [ -n "$cryptedhome" ]; then
1296 losetup
$loop $TGTMNT/$LIVEOS/$HOMEFILE
1298 echo "Encrypting persistent /home"
1299 while ! cryptsetup luksFormat
-y -q $loop; do :; done;
1301 echo "Please enter the password again to unlock the device"
1302 while ! cryptsetup luksOpen
$loop EncHomeFoo
; do :; done;
1304 mkfs.ext4
-j /dev
/mapper
/EncHomeFoo
1305 tune2fs
-c0 -i0 -ouser_xattr,acl
/dev
/mapper
/EncHomeFoo
1307 cryptsetup luksClose EncHomeFoo
1310 echo "Formatting unencrypted /home"
1311 mkfs.ext4
-F -j $TGTMNT/$LIVEOS/$HOMEFILE
1312 tune2fs
-c0 -i0 -ouser_xattr,acl
$TGTMNT/$LIVEOS/$HOMEFILE
1316 # create the forth files for booting on the XO if requested
1317 # we'd do this unconditionally, but you have to have a kernel that will
1318 # boot on the XO anyway.
1319 if [ -n "$xo" ]; then
1320 echo "Setting up /boot/olpc.fth file"
1321 args
=$
(grep "^ *append" $TGTMNT/$SYSLINUXPATH/isolinux.cfg |
head -n1 |
sed -e 's/.*initrd=[^ ]*//')
1322 if [ -z "$xonohome" -a ! -f $TGTMNT/$LIVEOS/$HOMEFILE ]; then
1323 args
="$args persistenthome=mtd0"
1325 args
="$args reset_overlay"
1326 xosyspath
=$
(echo $SYSLINUXPATH |
sed -e 's;/;\\;')
1327 if [ ! -d $TGTMNT/boot
]; then
1328 mkdir
-p $TGTMNT/boot
1330 cat > $TGTMNT/boot
/olpc.fth
<<EOF
1331 \ Boot script for USB boot
1332 hex rom-pa fffc7 + 4 \$number drop h# 2e19 < [if]
1333 patch 2drop erase claim-params
1334 : high-ramdisk ( -- )
1336 h# 22c +lp l@ 1+ memory-limit umin /ramdisk - ffff.f000 and ( new-ramdisk-adr )
1337 ramdisk-adr over /ramdisk move ( new-ramdisk-adr )
1340 ' high-ramdisk to load-ramdisk
1343 : set-bootpath-dev ( -- )
1344 " /chosen" find-package if ( phandle )
1345 " bootpath" rot get-package-property 0= if ( propval$ )
1346 get-encoded-string ( bootpath$ )
1347 [char] \ left-parse-string 2nip ( dn$ )
1352 " /sd" dn-buf count sindex 0>= if
1357 " BOOTPATHDEV" \$set-macro
1361 " $args" to boot-file
1362 " \${BOOTPATHDEV}$xosyspath\initrd0.img" expand$ to ramdisk
1363 " \${BOOTPATHDEV}$xosyspath\vmlinuz0" expand$ to boot-device
1370 if [ -z "$multi" ]; then
1371 echo "Installing boot loader"
1372 if [ -n "$efi" ]; then
1373 # replace the ia32 hack
1374 if [ -f "$TGTMNT$EFI_BOOT/BOOT.conf" ]; then
1375 cp -f $TGTMNT$EFI_BOOT/BOOTia32.conf
$TGTMNT$EFI_BOOT/BOOT.conf
1379 # this is a bit of a kludge, but syslinux doesn't guarantee the API for its com32 modules :/
1380 if [ -f $TGTMNT/$SYSLINUXPATH/vesamenu.c32
-a -f /usr
/share
/syslinux
/vesamenu.c32
]; then
1381 cp /usr
/share
/syslinux
/vesamenu.c32
$TGTMNT/$SYSLINUXPATH/vesamenu.c32
1382 elif [ -f $TGTMNT/$SYSLINUXPATH/vesamenu.c32
-a -f /usr
/lib
/syslinux
/vesamenu.c32
]; then
1383 cp /usr
/lib
/syslinux
/vesamenu.c32
$TGTMNT/$SYSLINUXPATH/vesamenu.c32
1384 elif [ -f $TGTMNT/$SYSLINUXPATH/menu.c32
-a -f /usr
/share
/syslinux
/menu.c32
]; then
1385 cp /usr
/share
/syslinux
/menu.c32
$TGTMNT/$SYSLINUXPATH/menu.c32
1386 elif [ -f $TGTMNT/$SYSLINUXPATH/menu.c32
-a -f /usr
/lib
/syslinux
/menu.c32
]; then
1387 cp /usr
/lib
/syslinux
/menu.c32
$TGTMNT/$SYSLINUXPATH/menu.c32
1390 if [ "$TGTFS" == "vfat" -o "$TGTFS" == "msdos" ]; then
1391 # syslinux expects the config to be named syslinux.cfg
1392 # and has to run with the file system unmounted
1393 mv $TGTMNT/$SYSLINUXPATH/isolinux.cfg
$TGTMNT/$SYSLINUXPATH/syslinux.cfg
1394 # deal with mtools complaining about ldlinux.sys
1395 if [ -f $TGTMNT/$SYSLINUXPATH/ldlinux.sys
]; then
1396 rm -f $TGTMNT/$SYSLINUXPATH/ldlinux.sys
1399 if [ -n "$SYSLINUXPATH" ]; then
1400 syslinux
-d $SYSLINUXPATH $TGTDEV
1404 elif [ "$TGTFS" == "ext2" -o "$TGTFS" == "ext3" -o "$TGTFS" == "ext4" -o "$TGTFS" == "btrfs" ]; then
1405 # extlinux expects the config to be named extlinux.conf
1406 # and has to be run with the file system mounted
1407 mv $TGTMNT/$SYSLINUXPATH/isolinux.cfg
$TGTMNT/$SYSLINUXPATH/extlinux.conf
1408 extlinux
-i $TGTMNT/$SYSLINUXPATH
1409 # Starting with syslinux 4 ldlinux.sys is used on all file systems.
1410 if [ -f "$TGTMNT/$SYSLINUXPATH/extlinux.sys" ]; then
1411 chattr -i $TGTMNT/$SYSLINUXPATH/extlinux.sys
1412 elif [ -f "$TGTMNT/$SYSLINUXPATH/ldlinux.sys" ]; then
1413 chattr -i $TGTMNT/$SYSLINUXPATH/ldlinux.sys
1418 # we need to do some more config file tweaks for multi-image mode
1419 sed -i -e "s;kernel vm;kernel /$LIVEOS/syslinux/vm;" $TGTMNT/$SYSLINUXPATH/isolinux.cfg
1420 sed -i -e "s;initrd=i;initrd=/$LIVEOS/syslinux/i;" $TGTMNT/$SYSLINUXPATH/isolinux.cfg
1421 mv $TGTMNT/$SYSLINUXPATH/isolinux.cfg
$TGTMNT/$SYSLINUXPATH/syslinux.cfg
1425 echo "Target device is now set up with a Live image!"