Fix the UUIDs in the target /etc/fstab
authorPatrick McCarty <patrick.mccarty@linux.intel.com>
Sat, 3 Aug 2013 00:54:46 +0000 (17:54 -0700)
committerPatrick McCarty <patrick.mccarty@linux.intel.com>
Mon, 5 Aug 2013 17:00:53 +0000 (10:00 -0700)
After the rsync, the installed /etc/fstab will contain the UUIDs from
the raw image and thus do not correspond with the UUIDs needed for the
target partitions.

The fix here is to iterate through the partitions after install, get the
UUIDs from the output of 'blkid', and substituting the old UUIDs with
the new ones.

Change-Id: Iee478c2fc93f5685891c0e7374f23c5e85b05610

scripts/system-installer

index 5434a0c..ac06a8c 100644 (file)
@@ -241,6 +241,25 @@ EOF
     /sbin/extlinux -i  ${TGTMNT}/boot/extlinux
 }
 
+function fixup_fstab {
+    local pnum=0
+    local devpnum="$((pnum+1))"
+    local tmp=""
+    local srcuuid=""
+    local tgtuuid=""
+
+    while [ "$pnum" -lt "$INSTALLERFW_PART_COUNT" ]; do
+        tmp="INSTALLERFW_PART${pnum}_UUID"
+        srcuuid=${!tmp}
+
+        tgtuuid=$(blkid ${TARGET_DEV}${devpnum} | sed 's/.* UUID="\([^"]*\)".*/\1/')
+        sed -i "s/.*\(UUID=\).*${srcuuid}\(.*\)/\1${tgtuuid}\2/" ${TGTMNT}/etc/fstab
+
+        pnum="$((pnum+1))"
+        devpnum="$((devpnum+1))"
+    done
+}
+
 function install_os {
     rsync  -WaHXSh --exclude='/dev/' --exclude='/lost+found/' --exclude='/media/*' --exclude='/sys/' --exclude='/proc/' --exclude="/tmp/" --exclude="/run/"  $SRCOSMNT/ $TGTMNT
 
@@ -250,6 +269,8 @@ function install_os {
     # TODO: switch to using systemd mount units instead of the fstab
     #rm ${TGTMNT}/etc/fstab
 
+    fixup_fstab
+
     if [[ $FILESYSTEM = "btrfs" ]]; then
         ROOTFLAGS="rootflags=subvol=tizen"
     else