mount_virt_disk.sh 489 B

123456789101112131415161718192021222324252627
  1. # ======检查是否以sudo运行=================
  2. uid=`id -u`
  3. if [ ! $uid == "0" ];then
  4. echo "请以sudo权限运行"
  5. exit
  6. fi
  7. # 检查是否设置ARCH环境变量
  8. if [ ! ${ARCH} ];then
  9. echo "请设置ARCH环境变量"
  10. exit
  11. fi
  12. DISK_NAME=disk-${ARCH}.img
  13. echo "Mounting virtual disk image '${DISK_NAME}'..."
  14. LOOP_DEVICE=$(losetup -f --show -P ../bin/${DISK_NAME}) \
  15. || exit 1
  16. echo ${LOOP_DEVICE}p1
  17. mkdir -p ../bin/disk_mount/
  18. mount ${LOOP_DEVICE}p1 ../bin/disk_mount/
  19. lsblk