Setting up a Linux system in VirtualBox

These notes tell you how to quickly install a CentOS 5 virtual machine on your Macintosh, using the free Virtualbox package. A disk image has been prepared with a basic OS installation, and access to your Mac file system, and you can then add software as needed.

Initial setup

Copy the disk image file over to your Mac from the /home/rsir/vbox/ area on the Linux systems - use MacFusion or plain sftp. It will have a name like CentOS_53_32bit.vdi. Create a folder on your Mac - for example in Documents - and place the .vdi file there. These instructions assume you have moved the .vdi file to ~/Documents/VirtualBox/

Note that these drive image files are quite large, and each time you run VirtualBox it's likely the image will be changed in some manner. It would be sensible to omit the folder where you store your Virtualbox disk images from Time Machine backups, otherwise Time Machine will rapidly fill your backup disk. You can still back up the drive images using SuperDuper, which should provide an adequate level of security provided you are not making constant changes to the virtual machine setup.

Configure VirtualBox

Launch the VirtualBox application, and click on the New button which is in the top left of the window. A Wizard dialog box will appear to guide you. Click Next to continue.

screenshot Provide a name for the Virtual Machine, and specify the OS type (Linux/Red Hat). Then click Next.

screenshot Specify the amount of RAM to dedicate to the virtual machine. A good typical value is 512MB though your specific needs may dictate a larger allocation. If 512MB proves too little then it is easy to increase the allocation later on. After setting the RAM size, click Next.

screenshot Now you need to point VirtualBox to the disk image file to use. By default it will offer to create a new disk image, but since we have a pre-prepared one this is not necessary. So check Use existing hard disk, and then click on the small folder icon.

screenshot The Virtual Media Manager will appear. Click the Add button, then navigate to - and select - the .vdi file. The screen will then appear something like the image on the right, indicating that we have a virtual 10GB hard drive. Select the CentOS_53_32bit.vdi line and click Select, which will return you to the previous screen, which will now reflect your selected disk image. Then click Next.

screenshot You will be presented with a summary screen. Review this information and then click Finish to complete the process. At this point you will be returned to the main screen, which will now list your new Linux VM. We need to make one more change to the setup and then you can boot the VM.

screenshot Scroll to the bottom of the Details section and click on Shared Folders. The dialog from the right appears, showing only the text Machine Folders. Click on the small icon to the right which has a folder with a plus sign, and enter the following details in the Add Share dialog which appears (replacing yourusername with your Mac username) - Folder Path = /Users/yourusername/, and Folder Name = machome. Then click OK twice to get back to the main screen, at which point you may click the Start icon in the toolbar to boot the VM.

Running Linux, and Mac file access

The VM is setup with only a root account, so it will be necessary to configure a regular user account. Robert or Ian can provide assistance with this, and for security the default root password must be changed too. The system is set to share your Mac IP address, so it does not need additional network configuration. Robert or Ian can also assist with installing any software which you may need on the VM, as well as show you how to update the OS.

You have full read/write access to the files on your Mac using the folder sharing set up earlier. Just cd /machome and you will be in your Mac home area. This will let you operate on files without having to copy them into the 'home' area on the Linux virtual hard drive. It also allows you to delete your Mac files with a misplaced rm command, so exercise caution!

Last updated Tuesday August 18, 2009