Mount a shared drive in virtualbox

This is mainly because I keep forgetting the commands for this…

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


Then add this line to your /etc/rc.local file so that it auto-mounts when you start up your vm.

Add a new drive to Centos Virtualbox Guest

I run into this a lot and always forget what the steps are…

With the guest powered off you will need to open VBx manager, right click on your guest name that you want to add the drive to and go to SETTINGS.

Click STORAGE and then either click IDE or SATA controller to highlight it. Then you will click the little drive icon next to it. I always choose new disk at the next little pop up. Follow the prompts….
If you get to this step and that icon is ghosted out make sure your guest is powered off. As of right now I dont think there is a way to hot-add a drive in VBx.

I choose VDI and DYNAMICALLY ALLOCATED, give it a name and a size. I ususally go with about 50GB since all of my VMs are for experimental use and I likely wont use that whole amount.

From here thats all you have to do in VBx itself. Next you will want to start up your gest and mount the drive…

Once you get logged in follow these steps…
sudo fdisk -l
Make sure you see your new drive here. It might be listed as something like /dev/sdb Then do the following….

mkdir /mnt/newdisk
mount -t ext3 /dev/sdb1 /mnt/newdisk
cd /mnt/newdisk

to mount automatically on boot, add disk to /etc/fstab my /etc/fstb for example, i added last line

LABEL=79d3d2d4 / ext4 defaults,noatime 0 0
LABEL=e21a3e10 /boot ext3 defaults,noatime 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
tmpfs /dev/shm tmpfs defaults 0 0
proc /proc proc defaults 0 0
sysfs /sys sysfs defaults 0 0
/dev/sdb1 /mnt/newdisk ext3 defaults 0 0