Skip to content

Instantly share code, notes, and snippets.

@yuuichi-fujioka
Created April 17, 2014 04:14
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save yuuichi-fujioka/10952389 to your computer and use it in GitHub Desktop.
Save yuuichi-fujioka/10952389 to your computer and use it in GitHub Desktop.
install apt-get package to qcow2 image
sudo apt-get install qemu-utils
sudo modprobe nbd
sudo qemu-nbd --connect=/dev/nbd0 /full/path/to/qcow2/image/file
sudo mkdir /mnt/ubuntu
sudo mount /dev/nbd0p1 /mnt/ubuntu
sudo mount -t proc proc /mnt/ubuntu/proc/
sudo mkdir /mnt/ubuntu/run/resolvconf
sudo cp /etc/resolv.conf //mnt/ubuntu/run/resolvconf/
sudo chroot /mnt/ubuntu apt-get update
sudo chroot /mnt/ubuntu apt-get install foo -y
sudo umount /mnt/ubuntu/proc
sync
sudo umount /mnt/ubuntu
sudo qemu-nbd --disconnect /dev/nbd0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment