Here is How I installed VirtualBox CD in Ubuntu Server from command line.
I have presented here the steps through which I was able to
Step 0: Download and install Virtual Box Guest Additions for enabling shared folder and some other tasks.
Step 1: Create new CD/DVD controller if not present. This option is generally not needed if you have not changed anything after install. You can skip to step 2.
- Click the Virtualbox session and click settings
- Click Storage
- Click Controller: Ide Controller under Storage Tree
- There are small icons of cd and Hard disk with plus (+) sign
- Click on the + sign with cd to add CD/DVD image
- On the prompt, click Leave Empty. You can optionally mount VirtualBoxGuestAdditions.iso image on the prompt. But for now you can safely click leave empty
- Now click ok and close
Step 2: Install Guest Additions
- Start the VirtualBox Session with Ubuntu Server
- On the top menu, click Devices > Install Guest Additions. This will add the VirtualBoxGuestAdditions.iso cd to the cd drive.
- Find this cd image in the guest Ubuntu server OS. It might be present in
/dev/cdrom or /dev/disk/by-label/VBOXADDITIONS_x.x.x.x
where x are any numbers which represent the VirtualBox version.
- Make a new folder where you want to mount the cd. e.g.
sudo mkdir -p /mnt/cdrom
- Type following command to mount the cd to that folder
sudo mount /dev/disk/by-label/VBOXADDITIONS_x.x.x.x /mnt/cdrom
- Now the image is mounted to folder /mnt/cdrom
Step 4: Browse the CD and run the installation script
- Browse the cd by going to /mnt/cdrom
cd /mnt/cdrom
- Run the shell script related to the version of linux or windows you are in. for x86 Ubuntu you can run
sudo ./VBoxLinuxAdditions.run
Here is how I shared MAC OS X folder with Ubuntu Guest OS in VirtualBox
Step 5: Define shared folder- Click Devices on the menu
- Click Shared Folders ...
- Click + sign
- Click Folder Path > Other
- Browse the folder and click Choose
- Give it a share name e.g. hostshare
Step 6: Mount the shared folder
- Find your userid by typing id in the command prompt of guest
id uid:0(root) gid:0(root) groups:0(root).
You need uid of the user account for you to be able to write to the mounted folder. Here uid is 0 for root. It might be different for your case. - Mount the share by following command
sudo mount -t <type> -o <share name> <path where it is to be mounted> e.g. sudo mount -t vboxsf -o uid=0 hostshare /mnt/share
The /mnt/share folder must be present before above command is executed. - Now you can browse the files in that folder.
- Optionally you can mount it automatically by adding following line to the file /etc/fstab
<sharename> <mount folder> vboxsf uid=0,gid=0 0 0 (with your uid and gid) e.g. hostshare /mnt/share vboxsf uid=0,gid=0 0 0
The values of uid and gid can be found by executing the id command as described above.