Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jeremejazz/6dedbe8cdd9da33e090019a041567de6 to your computer and use it in GitHub Desktop.
Save jeremejazz/6dedbe8cdd9da33e090019a041567de6 to your computer and use it in GitHub Desktop.

Revisions

  1. @estorgio estorgio revised this gist Aug 1, 2019. 1 changed file with 1 addition and 1 deletion.
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    *Update 7/28/2019: An [updated version](https://gist.github.com/estorgio/0c76e29c0439e683caca694f338d4003) of this guide for Ubuntu Server 18.04 LTS is now available. Feel free to check it out.*
    *Update 7/28/2019: An [updated version](https://gist.github.com/estorgio/0c76e29c0439e683caca694f338d4003) of this guide for **Ubuntu Server 18.04 LTS** is now available. Feel free to check it out.*

    # Mounting VirtualBox shared folders on Ubuntu Server 16.04 LTS

  2. @estorgio estorgio revised this gist Jul 28, 2019. 1 changed file with 2 additions and 0 deletions.
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    *Update 7/28/2019: An [updated version](https://gist.github.com/estorgio/0c76e29c0439e683caca694f338d4003) of this guide for Ubuntu Server 18.04 LTS is now available. Feel free to check it out.*

    # Mounting VirtualBox shared folders on Ubuntu Server 16.04 LTS

    This guide will walk you through steps on how to setup a VirtualBox shared folder inside your Ubuntu Server guest. Tested on Ubuntu Server 16.04.3 LTS (Xenial Xerus)
  3. @estorgio estorgio revised this gist Sep 11, 2017. 1 changed file with 1 addition and 1 deletion.
    Original file line number Diff line number Diff line change
    @@ -25,7 +25,7 @@ sudo apt-get install build-essential linux-headers-`uname -r`
    ```
    12. Run installation script for the guest additions:
    ```
    /media/cdrom/./VBoxLinuxAdditions.run
    sudo /media/cdrom/./VBoxLinuxAdditions.run
    ```
    13. Reboot VM
    ```
  4. @estorgio estorgio revised this gist Sep 11, 2017. 1 changed file with 1 addition and 1 deletion.
    Original file line number Diff line number Diff line change
    @@ -21,7 +21,7 @@ sudo mount /dev/cdrom /media/cdrom
    11. Install dependencies for VirtualBox guest additions:
    ```
    sudo apt-get update
    sudu apt-get install build-essential linux-headers-`uname -r`
    sudo apt-get install build-essential linux-headers-`uname -r`
    ```
    12. Run installation script for the guest additions:
    ```
  5. @estorgio estorgio created this gist Sep 11, 2017.
    85 changes: 85 additions & 0 deletions Mounting VirtualBox shared folders on Ubuntu Server 16.04 LTS.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,85 @@
    # Mounting VirtualBox shared folders on Ubuntu Server 16.04 LTS

    This guide will walk you through steps on how to setup a VirtualBox shared folder inside your Ubuntu Server guest. Tested on Ubuntu Server 16.04.3 LTS (Xenial Xerus)

    ## Steps:
    1. Open VirtualBox
    2. Right-click your VM, then click **Settings**
    3. Go to **Shared Folders** section
    4. Add a new shared folder
    5. On **Add Share** prompt, select the **Folder Path** in your host that you want to be accessible inside your VM.
    6. In the **Folder Name** field, type `shared`
    7. Uncheck **Read-only** and **Auto-mount**, and check **Make Permanent**
    8. Start your VM

    9. Once your VM is up and running, go to **Devices** menu -> **Insert Guest Additions CD image menu**

    10. Use the following command to mount the CD:
    ```
    sudo mount /dev/cdrom /media/cdrom
    ```
    11. Install dependencies for VirtualBox guest additions:
    ```
    sudo apt-get update
    sudu apt-get install build-essential linux-headers-`uname -r`
    ```
    12. Run installation script for the guest additions:
    ```
    /media/cdrom/./VBoxLinuxAdditions.run
    ```
    13. Reboot VM
    ```
    sudo shutdown -r now
    ```
    14. Create "shared" directory in your home
    ```
    mkdir ~/shared
    ```
    15. Mount the shared folder from the host to your ~/shared directory
    ```
    sudo mount -t vboxsf shared ~/shared
    ```
    16. The host folder should now be accessible inside the VM.
    ```
    cd ~/shared
    ```
    ## Make the mount folder persistent
    This directory mount we just made is temporary and it will disappear on next reboot. To make this permanent, we'll set it so that it will mount our `~/shared` directory on system startup

    1. Edit fstab file in /etc directory
    ```
    sudo nano /etc/fstab
    ```
    2. Add the following line to fstab (separated by tabs) and press Ctrl+O to Save.
    ```
    shared /home/<username>/shared vboxsf defaults 0 0
    ```
    3. Edit modules
    ```
    sudo nano /etc/modules
    ```
    4. Add the following line to `/etc/modules` and save
    ```
    vboxsf
    ```
    5. Reboot the vm and log-in again
    ```
    shutdown -r now
    ```
    6. Go to your home directory and check to see if the file is highlighted in green.
    ```
    cd ~
    ls
    ```
    If it is then congratulations! You successfully linked the directory within your vm with your host folder.

    ## Bonus:
    How to point apache's web directory to our folder in the host.
    1. Remove apache's old `html` directory (WARNING! Backup your data if necessary)
    ```
    sudo rm -rf /var/www/html
    ```
    2. Add a symbolic link in its place
    ```
    sudo ln -s ~/shared /var/www/html
    ```