Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/liveusb-to-liveusb.sh
blob: 3cc937ca6a06db967a1e15b68f187724a0af70f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash

cleanup() {
    [ -d "$MNT" ] && umount $MNT && rmdir $MNT
}

exitclean() {
    echo "Cleaning up to exit..."
    cleanup
    exit 1
}

DEV=$(readlink -f "$1")

livecd-iso-to-disk /dev/live $DEV

MNT=$(mktemp -d /media/mnttmp.XXXXXX) 
mount -o loop,rw "$DEV" $MNT || exitclean

cp -r /mnt/live/syslinux $MNT

USBLABEL=$(/sbin/blkid -s UUID -o value $DEV)
USBFS=$(/sbin/blkid -s TYPE -o value $DEV)
sed -i -e "s/root=[^ ]*/root=UUID=$USBLABEL/" -e "s/rootfstype=[^ ]*/rootfstype=$USBFS/" -e "s/overlay=[^ ]*/overlay=$USBLABEL/" $MNT/syslinux/syslinux.cfg

trap exitclean SIGINT SIGTERM

echo "Done."
cleanup