====== VirtualBox ====== ===== Installation ===== apt-get install virtualbox ===== Auto start a virtual machine ===== Start a vm with VBoxManage startvm ===== Shut down a virtual machine ===== Enter the following at **Command:**: VBoxManage controlvm acpipowerbutton For this to work, you need to modify /etc/acpi/powerbtn-acpi-support.sh: #!/bin/sh /sbin/shutdown -h -P now "Power button pressed" Alternatively, set up SSH access to all virtual machines and send the **shutdown** command through SSH. ===== Shared folders ===== ==== Introduction ==== This explains how to share files and folders (directories) between host and guest. (Files are shared over a network, in other words, you access remote files. For virtual machines, the network between host and guest is virtual since they are on the same real machine. But the steps you take are similar to setting up file sharing over real networks.) ==== Required: Virtualbox Guest Additions ==== Before sharing folders, you must install the Guest Additions in the host, if they are not already installed. # apt-get update # apt-get install virtualbox-guest-additions-iso Make sure the iso image will get mounted with exec options. To do this, modify the default fstab entry for the cdrom and add **exec** after //user//. /dev/sr0 /media/cdrom0 udf,iso9660 user,noauto,exec 0 0 Check how your file systems are mounted with cat /proc/mounts ==== Creating a shared folder ==== - Create a folder on the host that you would like to share, for example ~/VirtualShare - Boot the Guest operating system in VirtualBox. - Select Devices -> Shared Folders... - Choose the 'Add' button. - Select ~/VirtualShare - Optionally select the 'Make permanent', 'Auto mount', and 'Read only' options - Reboot the guest system - Access to the shared folder on /media/sf_VirtualShare - Fix permissions to access the folder, for example for the apache userusermod -a -G vboxsf www-data ==== Prepare the folder ==== === Linux === With a shared folder named share, the folder can be mounted as the directory ~/host with either of the following commands: sudo mount -t vboxsf share ~/host # root only sudo mount -t vboxsf -o uid=$UID,gid=$(id -g) share ~/host # UID & root === Windows === On the Windows Guest, run net use x: \\vboxsvr\share Now anything placed in this folder should be visible from the host in the ~/share folder. See [[https://forums.virtualbox.org/viewtopic.php?t=15868|HOWTO: Use Shared Folders]] ==== Troubleshooting ==== This can be done more generically with the following: sharename="whatever.you.want.to.call.it"; sudo mkdir /mnt/$sharename sudo chmod 777 /mnt/$sharename sudo mount -t vboxsf -o uid=1000,gid=1000 $sharename /mnt/$sharename ln -s /mnt/$sharename $HOME/Desktop/$sharename ==== raw disks ==== * [[https://unix.stackexchange.com/questions/284704/verr-access-denied-when-trying-to-add-a-raw-disk-to-virtual-box|VERR_ACCESS_DENIED]]