--- live-medium-install 2014-01-06 23:48:11.000000000 +0100 +++ live-medium-install.ch 2014-01-07 23:52:31.825147351 +0100 @@ -23,6 +23,10 @@ _TARGET="/dev/sda" +_PERSISTENCE="Yes, I want persistence." + +_SIZE="100MB" + # Dependencies if [ ! -e /sbin/parted ] then @@ -144,6 +148,40 @@ ;; esac +cat << EOF + +###################################################### +Do you want to use persistence option? +Please enter: 'Yes, I want persistence.' +(default: ${_PERSISTENCE}) + +EOF + +# Ask for _PERSISTENCE + +echo -n ": " +read _READ + +_PERSISTENCE=${_READ:-${_PERSISTENCE}} + +case "${_PERSISTENCE}" in + 'Yes, I want persistence.') + echo "What size? (default: ${_SIZE})" + # Ask for _SIZE + + echo -n ": " + read _READ + _SIZE=${_READ:-${_SIZE}} + + ;; + + 'No I do not make persistence.') + ;; + *) + echo "Invalid persistance selection of ${_PERSISTANCE} , abort." + exit 1 + ;; +esac # Display warning cat << EOF @@ -212,11 +250,16 @@ dd if=/dev/zero of=${_TARGET} bs=1024 count=1024 # Make a single partition -echo "Starting parted command to make lablel and partition..." +echo "Starting parted command to make label and partition..." #parted -s -a optimal ${_TARGET} mklabel gpt -- mkpart primary ext4 1 -1 #parted -s -a optimal ${_TARGET} mklabel msdos -- mkpart primary ext4 1 3000 #parted -s -a optimal ${_TARGET} -- mkpart primary ext4 3000 -1 -parted -s -a optimal ${_TARGET} mklabel msdos -- mkpart primary ext4 1 -1 +if [ "${_PERSISTENCE}" = "Yes, I want persistence." ] +then + parted -s -a optimal ${_TARGET} mklabel msdos -- mkpart primary ext4 ${_SIZE}+1 -1 +else + parted -s -a optimal ${_TARGET} mklabel msdos -- mkpart primary ext4 1 -1 +fi # Set the block device to boot. echo "Starting parted command to enable boot..." @@ -225,7 +268,18 @@ # Make new filesystem on the new partitions. echo "Making filesystem..." mkfs.ext4 -L Firmware ${_TARGET}1 -#mkfs.ext4 -L persistence ${_TARGET}2 + +if [ "${_PERSISTENCE}" = "Yes, I want persistence." ] +then + echo "adding partition for persistence" + parted -s -a optimal ${_TARGET} -- mkpart primary ext4 1 ${_SIZE} + mkfs.ext4 -L persistence ${_TARGET}2 + mkdir /mnt2 + mount ${_TARGET}2 /mnt2 + echo "/ union" >> /mnt2/persistence.conf + umount /mnt2 + rmdir /mnt2 +fi # Mount the target filesystem echo "Mounting file system to allow saving of webboot files..." @@ -286,7 +340,16 @@ menu default linux /live/vmlinuz initrd /live/initrd.img - append boot=live config vga=normal video=vesa quiet splash +EOF + +if [ "${_PERSISTENCE}" = "Yes, I want persistence." ] +then + sh -c 'echo "\tappend boot=live config vga=normal video=vesa quiet splash persistence" >> /mnt/boot/extlinux/extlinux.conf' +else + sh -c 'echo "\tappend boot=live config vga=normal video=vesa quiet splash" >> /mnt/boot/extlinux/extlinux.conf' +fi + +cat >> /mnt/boot/extlinux/extlinux.conf << EOF label live-failsafe menu label Live (failsafe)