archboot/usr/bin/archboot-usbimage-helper.sh
Tobias Powalowski 19bfd13771 - Renamed kernel and initramfs files.
- Separated x86_64 and i686 specific code in all-in-one script so that
a x86_64 only iso can be created if needed.
- revamp grub2 uefi config used in all-in-one and update-iso scripts
- added  "gpt loglevel=7" to kernel parameters
- Enabled xz compression for packages squashfs files
- xz initramfs (in archboot-update-iso.sh)
- used INITRD option in syslinux config files
- change PREFIX for GRUB2_UEFI in setup script to /boot/grub as per
changes in grub2 bzr r3856 (upstream), package will be in the repos
shortly
- disable get_grub2_map() , grub-mkdevicemap removed by upstream in r3856
- revamp dogrub2_config function
- common config for both grub2-bios and grub2 uefi in setup script
(required r3856 pkg)
- use sgdisk alone for auto_prepare gpt in setup script
- increase UEFISYS part size to 512 MiB in auto_prepare in setup
script (required for alternate UEFI bootloaders)
- fix repeating .efi in efibootmgr command in setup script
- other minor fixes, added quotes whereever required
- [TRIED TO] fix quickinst script
2012-02-06 14:44:34 +01:00

89 lines
2.5 KiB
Bash
Executable file

#!/bin/bash
# based on mkusbimg, modified to use syslinux
# by Tobias Powalowski <tpowa@archlinux.org>
#
# mkusbimg - creates a bootable disk image
# Copyright (C) 2008 Simo Leone <simo@archlinux.org>
#
# 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, either version 3 of the License, or
# (at your option) any later version.
#
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# usage(exitvalue)
# outputs a usage message and exits with value
APPNAME="$(basename "${0}")"
_usage() {
echo "usage: ${APPNAME} <imageroot> <imagefile>"
exit ${1}
}
##################################################
if [ $# -ne 2 ]; then
_usage 1
fi
DISKIMG="${2}"
IMGROOT="${1}"
TMPDIR=$(mktemp -d)
TMPDIR2=$(mktemp -d)
FSIMG=$(mktemp)
# ext2 overhead's upper bound is 6%
# empirically tested up to 1GB
rootsize=$(du -bs ${IMGROOT}|cut -f1)
IMGSZ=$(( (${rootsize}*102)/100/512 + 1)) # image size in sectors
# create the filesystem image file
dd if=/dev/zero of="${FSIMG}" bs="512" count="${IMGSZ}"
# create a filesystem on the image
mkfs.vfat -S 512 -F32 -n "ARCHBOOT" "${FSIMG}"
# mount the filesystem and copy data
if ! [[ "$(lsmod | grep ^loop)" ]]; then
modprobe -q loop || echo "Your hostsystem has a different kernel version installed, please load loop module first on hostsystem!"
fi
LOOP_DEVICE="$(losetup --show --find "${FSIMG}")"
mount -o rw,flush -t vfat "${LOOP_DEVICE}" "${TMPDIR}"
if [[ ! -e "${IMGROOT}/efi/boot/bootx64.efi" ]]; then
LOOP_DEVICE2="$(losetup --show --find "${IMGROOT}/efi/grub2/grub2_efi.bin")"
mount -o ro -t vfat "${LOOP_DEVICE2}" "${TMPDIR2}"
cp "${TMPDIR2}/bootx64.efi" "${IMGROOT}/efi/boot/bootx64.efi"
umount "${TMPDIR2}"
losetup --detach "${LOOP_DEVICE2}"
rm -rf "${TMPDIR2}"
fi
cp -r "${IMGROOT}"/* "${TMPDIR}"
rm -f "${TMPDIR}/boot/syslinux"/*.{com,bin,c32} || true
cp "/usr/lib/syslinux"/*.{com,bin,c32} "${TMPDIR}/boot/syslinux/"
# unmount filesystem
umount "${TMPDIR}"
losetup --detach "${LOOP_DEVICE}"
cat "${FSIMG}" > "${DISKIMG}"
# install syslinux on the image
syslinux "${DISKIMG}"
# all done :)
rm -rf "${TMPDIR}"
rm -f "${FSIMG}"