sync
-/sbin/mkfs.ext4 -L ROOTFS ${TARGET_DEV}2
+/usr/sbin/mkfs.btrfs -L ROOTFS ${TARGET_DEV}2
squash_img=/run/initramfs/live/LiveOS/squashfs.img
mount -oloop,ro $SRCMNT/LiveOS/ext3fs.img $SRCOSMNT
mount ${TARGET_DEV}2 $TGTMNT
+/usr/sbin/btrfs subvolume create ${TGTMNT}/tizen
+/usr/sbin/btrfs subvolume create ${TGTMNT}/tizen-snapshots
+SUBVOLID=$(/usr/sbin/btrfs subvolume list $TGTMNT | grep 'tizen$' | awk '{ print $2 }')
+/usr/sbin/btrfs subvolume set-default $SUBVOLID $TGTMNT
-rsync --progress -WaAHXSzh $SRCOSMNT/ $TGTMNT/
+umount $TGTMNT
+
+mount ${TARGET_DEV}2 $TGTMNT
+SFILES=$(ls $TGTMNT)
+echo $SFILES
+
+rsync --progress -WaAHXSzh $SRCOSMNT/ $TGTMNT
mkdir -p ${TGTMNT}/boot/extlinux
cat > ${TGTMNT}/boot/extlinux/extlinux.conf << EOF
label tizen
menu label Boot Tizen
kernel ../vmlinuz
- append root=${TARGET_DEV}2 ro vga=current splash quiet
+ append root=${TARGET_DEV}2 ro vga=current splash quiet rootflags=subvol=tizen
menu default
EOF
-cp /boot/vmlinuz* $TGTMNT/boot/extlinux/vmlinuz0
-cp /boot/initramfs* $TGTMNT/boot/extlinux/initrd0.img
-cp /usr/share/branding/default/syslinux/syslinux-vesa-splash.jpg $TGTMNT/boot/extlinux/splash.png
+cp /boot/vmlinuz* ${TGTMNT}/boot/extlinux/vmlinuz0
+cp /boot/initramfs* ${TGTMNT}/boot/extlinux/initrd0.img
+cp /usr/share/branding/default/syslinux/syslinux-vesa-splash.jpg ${TGTMNT}/boot/extlinux/splash.png
cat /usr/share/syslinux/mbr.bin > ${TARGET_DEV}
-extlinux -i $TGTMNT/boot/extlinux
+extlinux -i ${TGTMNT}/boot/extlinux
umount $TGTMNT
umount $SRCOSMNT
umount $SRCMNT
+
+mount ${TARGET_DEV}2 $TGTMNT -o subvolid=0
+
+/usr/sbin/btrfs subvolume snapshot ${TGTMNT}/tizen ${TGTMNT}/tizen-snapshots/fresh-install
+
+umount $TGTMNT
sync
+
plymouth hide-message --text "Installing in to the hard disk now, this will take a few minutes..."
-plymouth display-message --text "Now remove the USB key and hit a key to reboot. Enjoy!"
+plymouth display-message --text "Now remove the USB key and hit R key to reboot. Enjoy!"
plymouth watch-keystroke --command="/usr/bin/test" --keys "rR"
echo "Rebooting..."
-exit 0
+/sbin/reboot