#84 Change assumption that /dev/sda is root filesystem
Merged 2 years ago by pwhalen. Opened 2 years ago by ecurtin.
ecurtin/arm-image-installer main  into  main

file modified
+12 -2
@@ -194,11 +194,21 @@ 

  	exit 1

  fi

  

- if [ "$MEDIA" = "/dev/sda" ]; then

+ ROOTDISK="$(mount | grep "on / " | awk '{printf $1"\n"}')"

+ case "$ROOTDISK" in  

+   *nvme*)

+     ROOTDISK="$(echo $ROOTDISK | head -c 10)"

+     ;;

+   *sd*)

+     ROOTDISK="$(echo $ROOTDISK | head -c 8)"

+     ;;

+ esac

+ 

+ if [ "$MEDIA" = "$ROOTDISK" ]; then

  	echo ""

  	echo " ***********************************************************"

  	echo " ** WARNING: You have requested the image be written to sda."

- 	echo " ** /dev/sda is usually the root filesystem of the host. "

+ 	echo " ** $ROOTDISK is mounted as the root filesystem of the host."

  	echo " ***********************************************************"

  	echo " ** Do you wish to continue? (type 'yes' to continue)"

  	echo " ***********************************************************"

On the majority of new systems it's /dev/nvme0.
And /dev/sda is the first usb key inserted, which
is often where you want to write to. Make the
check smarter by checking what the device is
with the root filesystem of the host.

The sd in /dev/sda, /dev/sdb, etc. stands for SCSI Device, something I never thought about until I saw /dev/nvme0 on new laptops.

rebased onto 74827cd

2 years ago

Pull-Request has been merged by pwhalen

2 years ago
Metadata