executable_debian-chroot.sh 643 B

12345678910111213141516171819202122232425
  1. #!/usr/bin/env bash
  2. image="$1"
  3. qcow="$2"
  4. # Create mount direcroty
  5. echo mkdir /tmp/"$image"
  6. # Load kernel module
  7. echo modprobe nbd
  8. # Mount QEMU image
  9. echo qemu-nbd -c /dev/nbd0 /srv/virt/"$qcow"
  10. echo mount /dev/nbd0p1 /tmp/"$image"
  11. # Mouch chroot requisites
  12. echo mount --bind /dev /tmp/"$image"/dev
  13. echo mount --bind /dev/pts /tmp/"$image"/dev/pts
  14. echo mount --bind /dev/shm /tmp/"$image"/dev/shm
  15. echo mount --bind /srv/share /tmp/"$image"/mnt
  16. echo mount --bind /tmp /tmp/"$image"/tmp
  17. echo mount --bind "$XDG_RUNTIME_DIR" /tmp/"$image"/var/run/user/1000
  18. echo mount -t proc none /tmp/"$image"/proc
  19. echo mount -t sysfs sys /tmp/"$image"/sys