chromeos-common-script: Add rootdev_removable

rootdev_removable can be used to check if we booted from a removable
device.

BUG=b:154149017
TEST=boot from usb and `initctl emit fwupdtool-update` reports expected error

Change-Id: I8ffe62224a3ad654c249ced32b787c84a53a8d79
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform2/+/2774137
Tested-by: Daniel Campello <campello@chromium.org>
Auto-Submit: Daniel Campello <campello@chromium.org>
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Commit-Queue: Daniel Campello <campello@chromium.org>
diff --git a/chromeos-common-script/share/chromeos-common.sh b/chromeos-common-script/share/chromeos-common.sh
index efb4ffc..0ba26bb 100644
--- a/chromeos-common-script/share/chromeos-common.sh
+++ b/chromeos-common-script/share/chromeos-common.sh
@@ -358,6 +358,17 @@
   echo "${dev}"
 }
 
+# Check if rootfs is mounted on a removable device.
+rootdev_removable() {
+  local dst_drive="$(get_fixed_dst_drive)"
+  local root_drive="$(rootdev -s -d)"
+
+  if [ "${dst_drive}" != "${root_drive}" ]; then
+    return 0
+  fi
+  return 1
+}
+
 edit_mbr() {
   locate_gpt
   # TODO(icoolidge): Get this from disk_layout somehow.