2010年1月

If you have an Ubuntu installation, and want to check what version it is, you have a number of options. The most "right" way I've found is to simply look at the /etc/lsb-release file, which should tell you explicitly what version of Ubuntu is installed, its codename, and its version number.

Or, if you like the command line, run lsb_release -a

Of course, you could do a number of other things instead, like looking at /etc/apt/sources.list to see what version of Ubuntu you're pulling packages from. But I thought the above method was nice, and not often mentioned.

1. How to change the UUID for a vdi (Disk Image) file?

[vbox@myhost HardDisks]$ VBoxManage internalcommands setvdiuuid mydisk.vdi
VirtualBox Command Line Management Interface Version 3.0.2
(C) 2005-2009 Sun Microsystems, Inc.
All rights reserved.

UUID changed to: ee32ff3a-1e86-4387-a753-a51d1528a0fe

2. How to delete eth0, eth1, eth2...?

(1) Edit /etc/udev/rules.d/rules.d/70-persistent-net.rules
delete lines, like eth0, eht1, eth2...

(2) In VirtualBox, set Network as Bridge Adapter, reset the MAC address, restart the Linux.

If you need to set the static IP address, go to /etc/network/interfces, edit the last several lines.

3. How to setup AutoStart Headless Virtual Machines in CentOS or RHEL?

Add following lines in /etc/rc.local

su vbox -c "VBoxHeadless -startvm vmachine1 -p 4000 &"
su vbox -c "VBoxHeadless -startvm vmachine2 -p 4010 &"

Remarks:
vbox: The user to start the virtual machine.
vmachine1: The name of the virtual machine.
4000: Port the VRDP server bonded to.

For more information about VBoxHeadless, please type VBoxHeadless --help.

4. How to Re-compile VirtualBox Kernel in CentOS or RHEL:

(1) When you run VirtualBox and get following errors:

(2) When you run following command, you get another error:

/etc/init.d/vboxdrv setup

[vbox@myhost ~]$ sudo /etc/init.d/vboxdrv setup
Stopping VirtualBox kernel module [ OK ]
Recompiling VirtualBox kernel module [FAILED]
(Look at /var/log/vbox-install.log to find out what went wrong)

Makefile:152: *** Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR= and run Make again. Stop.

(3) Solution: Please install following packages in CentOS or RHEL:

yum groupinstall "Development Tools"
yum install kernel-devel

vbox@myhost ~]$ sudo /etc/init.d/vboxdrv setup
Stopping VirtualBox kernel module [ OK ]
Recompiling VirtualBox kernel module [ OK ]
Starting VirtualBox kernel module [ OK ]

For more reference, please visit http://wiki.centos.org/HowTos/Virtualization/VirtualBox

5. How to enable VT-x/AMD-V hardware acceleration?

When you started your VirtualBox and got following error, it meant that you have not enabled the VT-x/AMD-V hardware acceleration which is required for VirtualBox running on a 64-bit server.

The solution is restarting your server and enter to BIOS configuration interface and find following option and enable it.

Advanced Processor Options --> Intel (R) Virtualization Technology --> Enable.

After the server's boot up, start the VirtualBox again, you should not meet the above error again.

For more information about VT-x and AMD-V, please read http://en.wikipedia.org/wiki/X86_virtualization.

If you have a SMTP email server and you want to test if it is working properly, you can following the steps below to test it.

user_name@myhost:~$ telnet 127.0.0.1 25
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
220 myhost ESMTP Sendmail 8.14.3/8.14.3/Debian-9ubuntu1; Sat, 16 Jan 2010 17:28:30 -0800; (No UCE/UBE) logging access from: localhost(OK)-localhost [127.0.0.1]
HELO myhost
250 myhost Hello localhost [127.0.0.1], pleased to meet you
MAIL FROM:
250 2.1.0 ... Sender ok
RCPT TO:
250 2.1.5 ... Recipient ok
DATA
354 Enter mail, end with "." on a line by itself
Subject: Test

Test
Test
Test

.
250 2.0.0 o0H1SUjV016265 Message accepted for delivery
quit
221 2.0.0 npu40 closing connection
Connection closed by foreign host.
user_name@myhost:~$

If you can receive the above email properly, it means you can send email from the localhost. Next step, you can try to telnet it external IP address, like 192.168.0.123, to check if it can relay emails through the external IP address.

Remove a Service:
# update-rc.d -f apache2 remove
cd /etc/init.d
# update-rc.d -f apache2 remove
Removing any system startup links for /etc/init.d/apache2 ...
/etc/rc0.d/K09apache2
/etc/rc1.d/K09apache2
/etc/rc2.d/S91apache2
/etc/rc3.d/S91apache2
/etc/rc4.d/S91apache2
/etc/rc5.d/S91apache2
/etc/rc6.d/K09apache2

Add a Service:
# update-rc.d apache2 start 91 2 3 4 5 . stop 09 0 1 6 .
Adding system startup for /etc/init.d/apache2 ...
/etc/rc0.d/K09apache2 -> ../init.d/apache2
/etc/rc1.d/K09apache2 -> ../init.d/apache2
/etc/rc6.d/K09apache2 -> ../init.d/apache2
/etc/rc2.d/S91apache2 -> ../init.d/apache2
/etc/rc3.d/S91apache2 -> ../init.d/apache2
/etc/rc4.d/S91apache2 -> ../init.d/apache2
/etc/rc5.d/S91apache2 -> ../init.d/apache2