summaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
Diffstat (limited to 'share')
-rwxr-xr-xshare/hydra/bootless59
1 files changed, 5 insertions, 54 deletions
diff --git a/share/hydra/bootless b/share/hydra/bootless
index 8eb268a..65ff1e7 100755
--- a/share/hydra/bootless
+++ b/share/hydra/bootless
@@ -310,72 +310,23 @@ function hydra_bootless_device {
# Generate a bootless disk image
function hydra_bootless_image {
local output="$1"
- local size="$2"
if [ -z "$output" ]; then
output="bootless.img"
fi
- if [ -z "$size" ]; then
- # TODO: calculate minimum size. Hint:
- # du --exclude='.git' -hs ${BOOTLESS_DIR}
- size="200"
- fi
-
# Set folder
hydra_bootless_folder
- # Set sudo config
- local sudo
- if [ "`whoami`" != 'root' ]; then
- sudo="sudo"
- fi
-
- echo "Creating an empty image..."
- dd if=/dev/zero of=$output bs=1M count=$size
-
- echo "Partitioning image..."
- parted -s -- ${output} mklabel msdos
- parted -s -- ${output} mkpart primary ext2 2 -1
- parted -s -- ${output} set 1 boot on
-
- echo "Creating device mappings..."
- tmpdir=`mktemp -d`
- mapping="`$sudo kpartx -av ${output}`"
- if [ "$?" != "0" ]; then
- echo "Error: failed to create device mapping for \"${output}\" (errno: $?)."
- exit 1
- fi
-
- # Set devices
- device="`echo $mapping | head | awk '{ print $8 }'`"
- subdevice="/dev/mapper/`echo $mapping | head | awk '{ print $3 }'`"
-
- # Create filesystem
- $sudo mke2fs ${subdevice}
-
- # Mount
- $sudo mount ${subdevice} ${tmpdir}
- if [ $? != 0 ]; then
- echo "Error: failed to mount \"${subdevice}\" filesystem in \"${tmpdir}\" (errno: $?)."
- exit 1
- fi
-
# Copy data
+ tmpdir=`mktemp -d`
$sudo rsync -Cav ${BOOTLESS_DIR}/ ${tmpdir}/boot/
- # Install grub
- #$sudo grub-install --root-directory=${tmpdir} ${device} --force
- $sudo grub-install --boot-directory=${tmpdir} ${device} --force
- if [ $? != 0 ]; then
- echo "Error: grub-install failed (errno: $?)."
- exit 1
- fi
+ # Make rescue disk
+ grub-mkrescue -o ${output} ${tmpdir}
- # Finalize
- $sudo umount ${tmpdir}
- $sudo kpartx -dv ${output}
- $sudo rm -rf ${tmpdir}
+ # Cleanup
+ rm -rf ${tmpdir}
echo "Image saved at ${output}"
}