Saturday, January 30, 2010

Getting Started with a Solaris 10 Appliance Image for VirtualBox

You can download a Solaris 10 (October 2009) Appliance Image for VirtualBox (works on VirtualBox versions 3.0 and above) here: http://www.sun.com/software/solaris/get.jsp#virtualbox which is a ~1.4GB download. I'm using VirtualBox 3.0.6 on Mac OSX 10.5.8.

Now you need to extract the downloaded zip to reveal two files:
Solaris_10_u8.ovf
and
Solaris_10_u8.vmdk

Launch VirtualBox and from the File Menu -> Import Appliance...
Specify the path to Solaris_10_u8.ovf and accept the defaults or you could customize them to suit your preferences.

After the import process is complete, the Solaris installer will ask for additional system information: hostname, networking, root password, etc. You should provide a root password when asked.

Once the installation is complete, you'll be presented with a login screen but you need to create a new user account that you'll use on a regular basis.

Create a New User Account
(1) Login as "root" with the password you specified during setup
(2) Open a Terminal (Launch -> Applications -> Utilities -> Terminal)
(3) Type:
useradd -c "Full Name" -m -d "/export/home/username" -s /bin/bash username
Command explanation:
"-c" simply creates a new user with the name: 'Full Name';
"-m" copies the default profile information from /etc/skel;
"-d" creates the home directory in '/export/home/username' and;
"-s" specifies the shell '/bin/bash'
The final part 'username' is the login name.
(4) Type: passwd username to set the account password otherwise the account will remain locked
(5) Logout as root
(6) Login using the new user account and password
(7) You can choose either of Sun Java Desktop or CDE as you window environment.

Installing VirtualBox Additions
From the VirtualBox File menu, choose Install Guess Additions... to mount the VirtualBox additions .iso as a disk drive on Solaris and will appear with an icon on your desktop.
From a Terminal, change to the disk drive can copy two files:
cp autorun.sh ~/autorun.sh
cp VBoxSolarisAdditions.pkg ~/VBoxSolarisAdditions.pkg

This step of copying the two files above is necessary because for some reason, I couldn't get the autorun.sh shell script to work out of the box as it gave an error "id: illegal option -- u"
To fix the error:
(1) Make autorun.sh writeable:
chmod +w ~/autorun.sh
(2) Edit the file using a 'sane' text editor (I had issues using Sun's version of the vi editor):
gedit ~/autorun.sh
(3) Look for the line `$pfexecbin id -u` and change to `$pfexecbin /usr/xpg4/bin/id -u` since the version of id the script attempts to use is /usr/bin/id which doesn't support the -u option.

(4) Save and close the file.

(5) Run the script:
~/autorun.sh

Alternatively, you could ignore the error and simply just type from the directory containing VBoxSolarisAdditions.pkg:
pkgadd -d ./VBoxSolarisAdditions.pkg
[This tip is from the blog post Solaris Guest Additions in VirtualBox on Mac OS X by Susan Morgan].

After installation, you need to log out and back in for the changes applied to be re-read by your desktop environment.

I hope this helps someone.

Update:
Even after I specified a valid hostname in the initial setup screen when running the Appliance Image for the first time, I still continued to have my Solaris hostname as "unknown". After some googling the fix is quite simple: create a file called /etc/nodename and in it put your desired host name there then reboot.
So on the Terminal you could simply type these four commands (as root) to set "solaris-vm" as your hostname:
(1) # cat > /etc/nodename
(2) solaris-vm
(3) <Ctrl> + D (end-of-file character)
(4) # reboot (to confirm your changes)

No comments:

Post a Comment