Create btrfs filesystem on install
authorWilliam Douglas <william.douglas@intel.com>
Thu, 21 Feb 2013 20:22:57 +0000 (12:22 -0800)
committerWilliam Douglas <william.douglas@intel.com>
Thu, 21 Feb 2013 20:22:57 +0000 (12:22 -0800)
Have the rootfs be created as a btrfs partition. Also create two
subvolumes, one to host the tizen install and one to host the tizen
subvolume snapshots. The installer will set the tizen subvolume as
the default subvolume and take a snapshot of it after install.

Oh and fix reboot not working right.

Signed-off-by: William Douglas <william.douglas@intel.com>
packaging/pc-installer.spec
scripts/install.sh

index 40a5699..c895c91 100644 (file)
@@ -8,6 +8,7 @@ Source:         %{name}-%{version}.tar.xz
 Requires:       rsync
 Requires:       plymouth
 Requires:       syslinux-extlinux
+Requires:       btrfsprogs
 
 %description
 Installs a system from a live USB stick to a local hard-disk.
index 205c39d..6f0f3a7 100644 (file)
@@ -44,7 +44,7 @@ EOF
 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
 
@@ -56,8 +56,18 @@ mount -oloop,ro $squash_img $SRCMNT
 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
@@ -81,23 +91,30 @@ menu clear
 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