umount_virt_disk.sh 394 B

12345678910111213141516171819
  1. # ======检查是否以sudo运行=================
  2. uid=`id -u`
  3. if [ ! $uid == "0" ];then
  4. echo "请以sudo权限运行"
  5. exit
  6. fi
  7. if [ ! ${ARCH} ];then
  8. echo "请设置ARCH环境变量"
  9. exit
  10. fi
  11. DISK_NAME=disk-${ARCH}.img
  12. LOOP_DEVICE=$(lsblk | grep disk_mount|sed 's/.*\(loop[0-9]*\)p1.*/\1/1g'|awk 'END{print $0}')
  13. umount -f ../bin/disk_mount/
  14. losetup -d /dev/$LOOP_DEVICE
  15. echo $LOOP_DEVICE