Entries Tagged as 'VirtualBox'

Ubuntu 10.04/11.04: Mount a second drive at boot time

DriveShare MountJust recently I installed a second HD into my Ubuntu machine at work. I had created a LOT of VirtualBox Virtual Machines for testing the Railo installers on Windows and various other versions of Linux, and this was taking up the majority of my space on my main drive. To fix this, I installed a second drive (another 250GB) and moved over all my VirtualBox files to this second drive. Once I did that, I created a symlink from my home ".VirtualBox" directory to the directory that was on my second drive.

The default behavior for Unbuntu 10.04 is to not mount a drive until you click on it in your "Places" menu. That's generally fine for me and for most other folks, but annoying when I have things I use frequently on there. I want this second drive to always be mounted so I can use it whenever I want without having to click on it first. Other reasons compelled me to do this, like the fact that I had a desktop app icon mapped to this drive and it wouldn't show up unless I mounted the drive. Silly.

Here are the steps I took to mount the drive by default every time I rebooted my Ubuntu Desktop:

  1. First, create a directory to mount the second drive. I put mine in /media/driveshare:

    $ sudo mkdir /media/driveshare
  2. Next, you'll need to know your drive's system label. You can see that using the FDISK tool:

    $ sudo fdisk -l

    Here are my results:
    ---------------------
    Disk /dev/sda: 250.1 GB, 250059350016 bytes
    255 heads, 63 sectors/track, 30401 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x000d4017

       Device Boot      Start         End      Blocks   Id  System
    /dev/sda1               1       30401   244196001   83  Linux

    Disk /dev/sdb: 250.1 GB, 250059350016 bytes
    255 heads, 63 sectors/track, 30401 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x000ebf9b

       Device Boot      Start         End      Blocks   Id  System
    /dev/sdb1               1       29164   234259798+  83  Linux
    /dev/sdb2           29165       30401     9936202+   5  Extended
    /dev/sdb5           29165       30401     9936171   82  Linux swap / Solaris
    -----------------------

    You can see my set up is a bit unusual. My main drive appears to be on "sdb" and my "extra" drive appears to be "sda". You can tell by which drive has the swap partition. This probably has to do with how I plugged them into the motherboard. So... in my case, I will need to mount "sda1" to my "/media/driveshare" folder.
  3. Create a backup of your FSTAB file, just to be on the safe side:

    $ sudo cp /etc/fstab /etc/fstab.bak
  4. Now edit your FSTAB file with your preferred editor. I like "vim":

    $ sudo vim /etc/fstab
  5. ...and add your system's equivalent to the following line:

    /dev/sda1 /media/driveshare ext3 defaults 0 0

    Note that I specified my filesystem as EXT3. You will need to change this if you formatted using a different file system. I think the default in Ubuntu 10.04 is EXT4, but using EXT4 with VirtualBox caused an annoying error to pop-up, so I simply used EXT3 when I formatted this particular drive.
  6. After that, you can reload your FSTAB with the following command:

    $ sudo mount -a

Do you see your drive mounted? Unmount it (by right-clicking it and selecting "unmount"), and try the above command again. If it's mounted, then you're all set!

UPDATE: I've tested and this works great on Ubuntu 11.04 as well. Doesn't look like anything has changed in recent releases.

abolition-dr