disk-selection.sh 822 B

1234567891011121314151617181920212223242526
  1. #!/bin/bash
  2. PS3="Select disk to install Raspbian: "
  3. select disk in `lsblk --include 8 --nodeps --output NAME --noheadings`
  4. do
  5. echo "________________________________________________________________________"
  6. lsblk --nodeps /dev/$disk --output TRAN,VENDOR,MODEL,HOTPLUG
  7. echo "________________________________________________________________________"
  8. lsblk /dev/$disk --output NAME,TYPE,FSTYPE,SIZE,LABEL,MOUNTPOINT
  9. echo "________________________________________________________________________"
  10. read -p "ARE YOU SURE TO OVERRIDE THIS DISK? (y/n) " -n 1 -r
  11. echo #newline
  12. if [[ $REPLY =~ ^[Yy]$ ]]; then
  13. echo "Proceeding with $sdcard"
  14. sdcard=/dev/$disk
  15. break
  16. fi
  17. done
  18. for part in \
  19. `findmnt --output SOURCE,TARGET --raw | grep $sdcard | cut -d" " -f2`
  20. do sudo umount --verbose $part
  21. done