The theory was good.
Gentoo's implementation of its ebuild/portage system is a bunch of
confusing files, scripts and shell variables. When software is built, errors
and warnings fly by ignored. For businesses, dozens of different executables
on the same number of machines makes an administration and debugging
nightmare. Even on identical hardware, there's no guarantee that any two
builds will be the same. Not surprisingly, it is not possible for most hardware
vendors to offer Gentoo support.
Even though Gentoo is not aimed at business, trails behind
even the Slackware Linux in the market
(PegaSoft Download Poll), and is struggling
to keep going with site outages and internal quarrels
("Gentoo attempts to deal with developer conflicts",Linux.com),
some small companies prefer to use Gentoo. If your number of servers is
small, squeezing out a competitive amount of extra performance may be worth
the risk of bad support and administration headaches.
Regardless if you think Gentoo is genius or
madness, a manual install represents the ultimate challenge to boot
Linux on VirtualBox.
This document assumes you have a basic understanding of
setting up a Linux computer, such as how to build a kernel and how to format a
disk partition. "Host" refers to the operating system running VirtualBox,
in this case, Windows Vista. "Guest" refers to the operating system running
within VirtualBox, in this case, Gentoo Linux. I use "gentoo #"
as a root Gentoo prompt but your actual prompt may be a different one.
-
Install The Virtualization Software
VirtualBox is released under two different licenses. The pre-built binaries
are for evaluation purpose or non-commercial use. The source code is released
under an open source license. For prolonged use in a business setting,
consider installing this open source (or OSE) version of VirtualBox. The
main VirtualBox site does not provide the OSE binaries but they
are available on third-party sites like
http://vboxwin32.sourceforge.net.
This document is based on the pre-built version of VirtualBox 3.0.8.
VirtualBox and Gentoo are both being constantly updated,
sometimes several times a week. Some of these instructions may vary
slightly as new versions are released.
Run VirtualBox and click on the "New" icon. If there's no "Gentoo" option,
use OS Type Linux/Linux 2.6. Use the recommended base memory size.
Follow the instructions, creating a new, dynamically expanding virtual disk
a minimum of 8 gigabytes to be the primary hard disk.
![[Screenshot of VirtualBox Disk
Configuration Dialog]](pictures/virtualbox_disk.jpg)
Figure: Screenshot of VirtualBox Disk Configuration Dialog |
There are a lot of other possibilities here, such as simulating multiple
processors or having a second hard drive shared between different virtual
machines. However, these settings above are suitable for most people.
You have now created a space in which Gentoo will run but the space is
still empty.
-
Preparing the disk
Download Gentoo LiveCD. VirtualBox can actually boot off the ISO
disk image so burning a LiveCD is optional. Remember that VirtualBox
is (at the time of writing) a 32-bit i386 emulator only (not x86_64) so choose
the correct download Live disk type. You can actually run programs compiled
for x86_64 processors but some x86_64 install disks may detect a
"i386" computer system and refuse to install.
Put the LiveCD disk in your computer
and start the virtual machine in VirtualBox. The virtual machine should load
and VirtualBox will prompt you for a boot device. Chose the drive with
the LiveCD (or the path to the ISO image file, if you didn't create a CD).
![[Screenshot of Select Boot Device Dialog]](pictures/virtualbox_bootdevice.jpg)
Figure: Screenshot of Select Boot Device Dialog |
At the LiveCD boot: prompt, type gentoo-nofb (the kernel
without a frame buffer,
Wikipedia).
Once the Gentoo LiveCD is loaded and you have a Linux shell prompt, you need to
format the disk simulated by VirtualBox. On the LiveCD I used, it
was named /dev/hda (though it might be named /dev/sda in the
future). You can probably function with one partition and use a
swap file, but I followed the Softer Blue instructions and created three
partitions (boot, root and swap partitions). Remember which partition is for
which task as this will be important later. Use the fdisk command to
create the partitions. Here's an example of the partitions:
Linux Name Mount Point Space fdisk Partition
/dev/hda1 /boot 40 MB primary partition 1
/dev/hda2 swap 2 GB primary partition 2
/dev/hda3 / remainder primary partition 3
If you used "hda", like I had to, make all references to your /dev/hda
partitions on the LiveCD as /dev/sda on
your virtual machine. Grub, for example, will not recognize /dev/hda1
when booting up on your virtual machine. It must be /dev/sda1. The
same with mounting drives on startup with /etc/fstab. If
you do use the /dev/hda prefix, grub will show a message cannot
open root device "hda1" and there will be a kernel panic when starting the
virutal machine.
Format the partitions with mke2fs (for ext2) or mke2fs -j
(for ext3) as required
(ext2fs Home Page)).
Use mkswap to initialize the swap partition.
gentoo # mke2fs /dev/hda1
gentoo # mkswap /dev/hda2
gentoo # mke2fs -j /dev/hda3
-
Create the basic Root Device and Portage Instance
You now have a formatted but empty simulated hard drive for your Gentoo
guest machine. In most Linux distributions, your install program would take
care of this for
you, as well as the network setup, assignment of the hostname and other basic
configuration issues. Gentoo requires a manual configuration. See the
Gentoo Linux x86 Handbook
for general information on installing Gentoo.
![[Fedora Welcome Screen]](pictures/virtualbox_fedora_welcome.jpg) Figure: Fedora on VirtualBox - Don't Expect an Easy Gentoo Install |
Before starting, check the date and time make sure they are correct using the date command. Do this to avoid tar warnings on file dates.
Mount the root partition on /mnt/gentoo. Download the stage3
compressed tar file from a Gentoo mirror. I used http://mirrors.kernel.org/gentoo. You
can use
the links text browser to select a mirror and save the tarball. Or use wget
if you know the path.
Move the compressed tar file to /mnt/gentoo and
untar (tar xfpj) it to get your basic root file system image.
Second, change directory to the /mnt/gentoo/usr directory.
Download the latest portage tarball from the snapshots directory (it will
contain "latest" in its name) from the same mirror site. Untar it to get
your basic definitions for the Gentoo installer, emerge.
Copy the resolv.conf file created by the LiveCD to your Gentoo
virtual machine. This contains the basic DNS settings.
gentoo # cp -L /etc/resolv.conf /mnt/gentoo/etc/
-
Enter the Non-Functioning Virtual Machine
You have a rudimentary install of Gentoo but it is not able to boot yet. The
next step is to enter the virtual machine, mounted by the LiveCD, and finish
setting it up. You'll need to do this whenever you're trying to get the virtual
machine working. First, boot the Live CD (if you're following these
instructions in sequence they you've already done this) and then:
gentoo # mount -t proc proc /mnt/gentoo/proc
gentoo # mount /dev/hda3 /mnt/gentoo
gentoo # mount /dev/hda1 /mnt/gentoo/boot
gentoo # swapon /dev/hda2
gentoo # chroot /mnt/gentoo /bin/bash
(/mnt/gentoo may already mounted from step 3.)
You are now inside the virtual machine while running of the Gentoo kernel
provided by the LiveCD.
-
Basic Gentoo New Installation Setup
Configure your timezone. For example,
gentoo # cp /usr/share/zoneinfo/EST5EDT /etc/localtime
gentoo # date
Set your host and domain name. Depending on your LiveCD disk, you may not
have vi/vim available so you'll have
to use sed (or, possibly, the nano editor). So type carefully.
gentoo # cd /etc
gentoo # echo "127.0.0.1 gentoo.is.virtualized gentoo localhost" > hosts
gentoo # sed -i -e 's/HOSTNAME.*/HOSTNAME="gentoo"/' conf.d/hostname
gentoo # hostname gentoo
gentoo # hostname -f
gentoo.is.virtualized
Update the portage directory for the most up-to-date version of available
packages.
gentoo # emerge --sync
gentoo # emerge portage
-
Build the Kernel
Now you need to build a Linux kernel for your virtual machine. Download the
kernel sources.
gentoo # emerge gentoo-sources
Run menuconfig and edit the kernel settings.
gentoo # make menuconfig
Here are some recommended settings. The names may vary depending on your
kernel version:
- file systems / ext2 support (for the /boot partition) (on)
- file systems / fusefs support (if you are using SSHFS) (on)
- tickless system (on)
- high resolution time (OFF)
- symmetric multi-processing support (OFF)
- machine check exception (OFF)
- cpu type (use your host's CPU as reported by Windows Vista)
- 64-bit memory and I/O (OFF)
- high memory support (OFF)
- power management support (on)
- suspend to ram and standby (OFF)
- hibernation (OFF)
- serial ata and parallel ata drivers (on)
- ata sff support (on)
- intel esb, ich, piix3...support (on)
- device drivers / network device support / amd pcnet32 pci support (on)
- device drivers / network device support / intel pro/1000 gigabit eithernet (on - i think?)
- device drives / MacIntosh device drives (OFF)
- device drivers / virtualization (OFF)
- graphic support / direct rendering manager (on)
- mouse ps/2 mouse (on)
Tip:For long tasks, like kernel building
or using emerge to install large packages, consider turning off the console
screen blanking feature to make it easier to monitor your progress:
gentoo # setterm -powersave off -blank 0
|
Install the new kernel on the /boot partition.
gentoo # make && make modules_install
gentoo # cp arch/i386/boot/bzImage /boot/kernel
You'll need to boot the virtual machine to find out if the new kernel works, but
there are more tasks to do before you can boot the kernel.
-
Other First-Time System Configuration
Edit /etc/fstab and add the 3 partitions so they mount when the virtual
machine starts. Remember to
use /dev/sdaN not /dev/hdaN.
The network configuration can be difficult. You can use NAT (or "IP masquerading", you can "get out" from the
virtual machine but you can't "get into" it from the outside), or bridging. I'll
discuss bridging in Part 16.
For a basic setup, use NAT. As long as the drivers are loaded for your virtual network card, and
you have DHCP installed (emerge dhcp), it should work automatically. This is the setting I
used. If you need to configure the network, the file is /etc/conf.d/net.
Enable the network card you have chosen to emulate in VirtualBox. It is better
to configure it as a built-in kernel driver than a module. If your eth0 network
device doesn't appear in ifconfig, it might
be because the kernel module wasn't loaded. Use modprobe or rebuild
your kernel with the driver built-in.
Use /etc/init.d/net.eth0 start to start the network service after a
reboot.
Set your root password with passwd.
Make sure /etc/conf.d/clock is set to the correct timezone.
-
Installing the Boot Loader (Grub)
A boot loader will run your new kernel when the virtual machine starts
(GNU Grub Home Page).
gentoo # emerge grub
Edit /boot/grub/grub.conf. Remember to use
/dev/sdaN not /dev/hdaN.
title=Gentoo
root (hd0,0)
kernel /boot/kernel root=/dev/sda3
Run grub and install the bootloader with
grub> root (hd0,0)
grub> setup (hd0)
grub> quit
You should now be able to boot into your virtual machine. Stop the virtual
machine with VirtualBox, remove the LiveCD from the computer's hard drive and try starting the
virtual machine. If it fails, use the LiveCD and follow step 4 to
chroot into the non-functioning virtual machine to do diagnostics and
fix the configuration problems.
-
Installing Your Applications and VirtualBox Guest Additions
At this point you are now running on your Gentoo in VirtualBox.
Wish you had a mouse for your VirtualBox console window? Set it up now, if
you would like to.
gentoo # emerge gpm
gentoo # /etc/init.d/gpm start
gentoo # rc-update add gpm default
Now if you click on your VirtualBox console, a dialog appears. Click on the
"Capture" button to capture the mouse. Press the right Ctrl key to release the
mouse, returning control to Windows Vista. This will give you basic
copy-and-paste capabilities within the console but to copy to/from Windows,
you'll need the VirtualBox Guest Additions. We'll enable those in this Part.
Create an /etc/portage/package.use file with the requirements for
Network Time Protocol (if you want NTP...this may be redundant if your
Windows Vista desktop is configured to use NTP already):
echo "net-misc/ntp caps" >> /etc/portage/package.use
Update /etc/make.conf for the VirtualBox guest additions and
global USE flags for Gnome
(Gnome Home Page) and KDE
(K Desktop Environment Home Page):
INPUT_DEVICES="keyboard virtualbox evdev"
VIDEO_CARDS="virtualbox"
USE="qt3 qt4 arts kde X dbus gtk hal gnome truetype"
Update your minimal software configuration for the changes in USE
flags (this may take a while):
gentoo # emerge -avN world # (Any time the USE entry changes)
Add the following to /etc/portage/package.keywords for the guest
additions and Eclipse (if you want Eclipse):
# GUEST ADDITIONS
=app-emulation/virtualbox-guest-additions-3.0.8
=x11-drivers/xf86-input-virtualbox-3.0.8
=x11-drivers/xf86-video-virtualbox-3.0.8
# ECLIPSE
dev-java/eclipse-ecj
dev-util/eclipse-sdk
=dev-java/junit-4.4*
=dev-java/ant-core-1.7*
=dev-java/sat4j-core-2.0*
=dev-java/ant-eclipse-ecj-3.4*
=dev-java/swt-3.4*
=dev-java/ant-1.7*
=dev-java/javatoolkit-0.3*
=dev-java/sat4j-pseudo-2.0*
=dev-java/asm-3.1*
=dev-java/ant-apache-bcel-1.7*
=dev-java/ant-junit-1.7*
=dev-java/ant-apache-bsf-1.7*
=dev-java/ant-commons-net-1.7*
=dev-java/ant-apache-log4j-1.7*
=dev-java/ant-nodeps-1.7*
=dev-java/ant-commons-logging-1.7*
=dev-java/ant-swing-1.7*
=dev-java/ant-javamail-1.7*
=dev-java/ant-antlr-1.7*
=dev-java/ant-trax-1.7*
=dev-java/ant-apache-resolver-1.7*
=dev-java/ant-jdepend-1.7*
=dev-java/ant-apache-regexp-1.7*
=dev-java/ant-apache-oro-1.7*
=dev-java/ant-jsch-1.7*
The problem of setting up X Windows requires a little explanation.
VirtualBox has the ability to create a miniature Gentoo desktop drawn within
the VirtualBox window (where your text console currently resides). This
occurs automatically with some Linux installations like Fedora (see Figure).
VirtualBox Guest Additions are software patches that need to be installed
on the virtual machine to make X Windows, shared folders, the mouse and
keyboard work with improved features and more seamless integration with the
host operating system.
The basic instructions are located at the
VirtualBox Gentoo as Guest WIKI.
Add the following to /etc/portage/package.keywords as described
above, changing the version number: 3.0.8 should be replaced with your version
number of VirtualBox.
gentoo # emerge virtualbox-guest-additions xf86-input-virtualbox xf86-video-virtualbox
gentoo # rc-update add virtualbox-guest-additions default
Gentoo reported a value when starting the guest additions. In fact, they
started successfully.
gentoo # /etc/init.d/virtualbox-guest-additions --verbose start
* Caching service dependencies ... [ ok ]
* Starting VirtualBox guest additions ...
* Loading kernel modules and creating devices
* Starting the vboxadd system service
* Failed to start VirtualBox guest additions
gentoo # ps -ef | grep vbox
root 3482 1 0 09:23 ? 00:00:02 /usr/sbin/vboxadd-service
root 4010 3603 0 13:44 pts/3 00:00:00 grep --colour=auto vbox
I viewed the virtualbox-guest-additions start script and confirmed that
vboxadd-service was the last program started by the guest additions.
The next step is to configure X Windows.
gentoo # cd /etc/X11/
gentoo # cp xorg.conf.example xorg.conf
Edit the xorg.conf file, commenting out the Device and
InputDevice sections, adding the configurations for the VirtualBox devices.
#Section "InputDevice"
# Identifier "Mouse2"
# Driver "mouse"
# Option "Protocol" "MouseMan"
# Option "Device" "/dev/mouse2"
#EndSection
Section "InputDevice"
Identifier "Mouse0"
Driver "vboxmouse"
Option "Protocol" "PS/2"
Option "Device" "/dev/input/mice"
Option "ZAxisMapping" "4 5 6 7"
EndSection
[...more lines in between...]
Section "Device"
# The Identifier must be present.
Identifier "Card0"
Driver "vboxvideo"
# Identifier "Generic VGA"
[...]
Section "Screen"
Identifier "Screen 1"
Device "Card0" # Use VirtualBox
[...]
Section "ServerLayout"
InputDevice "Mouse0" "CorePointer" # Use VirtualBox
[...]
Comment out any of the other examples.
This should allow you to start X Windows, using the VirtualBox window as
you display. Unset DISPLAY (if it exists) and start a basic X Windows
desktop with the command "startx".
Configuring a Gnome or KDE desktop is beyond the scope of this article.
Look at the Gentoo documentation
(Gnome Config HOWTO and the
KDE Config HOWTO).
Although having a miniature desktop looks interesting, what I
really wanted was my real desktop to display both my Vista and Gentoo
windows. This would use my full screen to its greatest
advantage.
First, install the basic X Windows environment on Gentoo (this will take a while as there are a lot of files to build).
gentoo # emerge gnome-light kde konsole kedit
gentoo # env-update && source /etc/profile
Once X Windows is built, install an X Windows display package for Windows.
This type of software will enhance Windows and manage your Gentoo X applications.
There are two popular alternatives: Cygwin/X and Xming.
X Windows with Cygwin/X
To use Cygwin as your display device, go to the Cygwin home page and
download the Cygwin installer. After you start the installer, make sure
you install the basic X Windows packages as described in the Cygwin/X
documentation
(Cygwin/X User Guide/Installing): usually xinit, xserver plus some optional packages. Don't worry about fonts: these will come from Gentoo.
Get your Windows Vista IP number by opening a command prompt and type
ipconfig. In the virtual machine, redirect X Windows to use Cgywin with export DISPLAY="windows_ip:0" at your
Gentoo prompt.
Start Cygwin and then start X Windows (e.g. startxwin.bat). Close Cygwin's
xterm window (the one that appears in order to verify X is running) and then
run a virtual machine X
application to see if it works.
gentoo # konsole &
Tip: for bridged networking, the virtual machine will appear as another
computer to Cygwin. To permit the virtual host to connect, install "xhost"
and run:
cygwin # export DISPLAY="your_windows_host_ip:0"
cygwin # xhost +
This can be placed within your Cygwin .bash_profile file so that it runs
each time you start Cygwin. |
X Windows with Xming
Xming (Xming Home Page)
is a stand-alone X Windows server for Windows. You might chose Xming if
you don't want to install the Cygwin environment. Download and run the Xming
installer and install XLaunch and Xming. You don't need to install SSH.
Get your Windows Vista IP number by opening a command prompt and type
ipconfig. In the virtual machine, redirect X Windows to use Cgywin with export DISPLAY="windows_ip:0" at your
Gentoo prompt.
Run XLaunch and use the default settings except be sure to turn off access
control. Then run a virtual machine X application to see if it
works.
gentoo # konsole &
Congratulations! You have X Windows cohabiting with Windows Vista.
-
Adding Standard X Windows Fonts
Gentoo installs a minimal set of fonts by default. Add some additional
font sets to give you some options for reducing your eyestrain.
gentoo # emerge media-fonts/corefonts
gentoo # emerge media-fonts/ttf-bitstream-vera
gentoo # emerge media-fonts/font-bh-ttf
gentoo # emerge media-fonts/terminus-font
gentoo # emerge media-fonts/artwiz-aleczapka-en
gentoo # emerge media-fonts/dejavu
gentoo # emerge media-fonts/freefonts
gentoo # emerge media-fonts/unifont
Two other possibilities are media-fonts/arkpandora and
media-fonts/liberation-fonts: these are alternatives to the corefonts. There are other fonts sets as well, including international fonts.
-
Creating Shared Directories (Folders)
Creating a shared directory--one that can be accessed by both Windows and
Gentoo--is essential to work with data files using applications
on both systems. This eliminates the problem of copying files into and out
of Gentoo to make them accessible to Gentoo's applications.
The VirtualBox guest additions permit a directory sharing between
Windows and Gentoo. For example, sharing your Windows (and/or Cygwin)
home directories.
Stop the virtual machine. In the Settings / Shared Folders section, create
any shared folders you want Windows to share with Gentoo.
Start the virtual machine. Create a mount point (for example,
/mnt/windows). Check to see if the shared folders are accessible
by mounting them.
gentoo # mkdir /mnt/windows
gentoo # mount -t vboxsf virtualbox_sharename /mnt/windows
gentoo # umount /mnt/windows
I will explain how to automatically mount these directories on startup in
Part 14 below.
-
Install Core Applications
Remember that using emerge may take a long time (possibly hours or days,
depending on your computer and Internet connection) to install everything.
Again, you may want to disable the console screen saver if you have not done so
already.
These are some suggestions for software or web development tools:
gentoo # emerge lynx # text web browser
gentoo # emerge slocate # GNU locate command
gentoo # emerge app-arch/p7zip # 7-zip archiver
gentoo # emerge zoo # file archiver
gentoo # USE="cli" emerge php # PHP language
gentoo # emerge dev-lang/gnat-gcc # GCC Ada
gentoo # emerge dev-java/sun-jdk # Sun java
gentoo # emerge ruby # Ruby language
gentoo # emerge htmltidy # HTML verifier
gentoo # emerge cvs # a source control systems
gentoo # emerge subversion # another source control system
gentoo # emerge dev-util/git # still another source control system
gentoo # emerge sys-fs/sshfs-fuse # mount via SSH(requires fusefs in kernel)
gentoo # emerge postgres # an open source database
gentoo # emerge mysql # open source version of mysql
gentoo # emerge gvim # vi-based graphical editor
gentoo # emerge anjuta # Gnome desktop IDE
gentoo # emerge kdevelop # KDE desktop IDE
gentoo # emerge konquerer # a web and file browser
gentoo # emerge bsh # Java shell
gentoo # emerge wipe # secure file removal
gentoo # emerge curl # file transfers
gentoo # emerge unison # file transfers
gentoo # emerge mailx # text mail reader
gentoo # emerge pine # text mail reader
gentoo # emerge traceroute # network diagnostic command
gentoo # emerge net-misc/ntp # NTP to update your clock
gentoo # emerge mc # Midnight Commander
Use emerge --search PACKAGE to see if package names
containing the phrase "PACKAGE" are
available, where package is the name you are interested in.
To install Sun's Eclipse IDE, there's some manual changes required. Read the
Eclipse on Gentoo Wiki at
http://www.gentoo-wiki.info/Eclipse.
[KB: Updated 09/10/20]: Note: It may be easier simply to download a pre-built
version of Eclipse for x86 Linux than try to use emerge. The following instructions
attempt to do it the hard way:
gentoo # emerge layman
gentoo # layman --fetch
gentoo # layman --add java-overlay
gentoo # emerge eclipse-sdk
Eclipse will fail with the URL you need to use to get the old version of java.
Download the Java bin file using Firefox in Vista and move the file to the
directory shared with Gentoo (in this example, /mnt/windows).
gentoo # mv /mnt/windows/j2sdk-1_4_2_19-linux-i586.bin /usr/portage/distfiles/
gentoo # emerge eclipse-sdk
To finish Eclipse, enable "Classic Update" in the preferneces.
When you're done installing applications, you may need to edit some /etc configuration files. Gentoo
will install multiple versions. emerge will show warnings about this.
Run dispatch-conf to see the differences: usually merging is the best option but
you may want to keep one file but not another.
Finally, check your /etc/init.d services to choose which services run at startup. Some may not be applicable to a virtual machine.
gentoo # rc-update show
gentoo # rc-udpate add hald default
gentoo # rc-update add dbus default
gentoo # rc-update vixie-cron default
(Other versions of Linux may use chkconfig or a similar command.)
-
Accessing Remote Directories
Create a new account for yourself using adduser, if you have not already
done so.
If you are doing development and you need to work with other computers,
you could simply use SSH to log into the remote computer and edit files with
at the shell prompt. A better way would be to share the directories with
your virtual machine so you can edit the files directly with your X Windows
based tools.
There are several methods you can use to accomplish this:
NFS - It's clunky. It's old. It's insecure.
Export
the remote Linux directory using NFS and mount it with mount -t nfs.
Samba - You can mount a Windows share on Linux
using mount -t smbfs (if you've enabled smbfs in the kernel) or use
smbmount.
SSHFS - Use SSHFS to mount directories over the
SSH protocol. This is also a safer alternative over using NFS on an insecure
network (like the Internet) and it doesn't require any root access.
If you've installed SSHFS, you can log into your
non-root user account and mount a home directory on a computer called
"REMOTE_COMPUTER" onto a directory called "dev" in your local home this way:
gentoo $ sshfs ken@REMOTE_COMPUTER: ~/dev
The directory can be unmounted with fusermount -u ~/dev.
Using SSHFS over the Internet may take one or two seconds to update a file,
creating false file update warnings in some editors.
Alternatively, maybe a remote mounted directory is not required:
ssh -Y - This tunnels X application displays
back to your desktop. But this requires the X application to be installed
on the remote computer, and it defeats the usefulness of your Gentoo virtual
machine.
unison - Synchronize the files on the remote computer using a tool like unison or rsync.
subversion - User your source control system, checking out the files to the remote computer using a tool like cvs or subversion or git.
There are other methods as well but this is beyond the scope of this
document.
-
Automating Your Startup Process
You cannot mount your shared Windows directories at boot time using
/etc/fstab. The shared directories require the VirtualBox
guest additions and these run after the fstab is processed.
Instead, you need to add necessary mount commands to your
/etc/conf.d/local.start file (the Gentoo equivalent
to rc.local) which is executed after the guest additions
are installed.
Also, use local.start adjust the time on startup.
/bin/mount -t vboxsf kburtch /mnt/windows # Mount kburtch VB share
/usr/sbin/ntpd -q # Update the clock
Update the startup process to mount any SSHFS directories in your .bash_profile in your home directory:
# No screen blanking when logging into the main console
if [ `tty` = "/dev/tty1" ] ; then
setterm -powersave off -blank 0
fi
# If mount folder "dev" in my home directory is empty, mount remote home directory
# onto it (assumes "dev" exists)
if [ -d ~/dev ] ; then
TMP=`ls -l ~/dev | wc -l`
if [ $TMP -lt 2 ] ; then
echo "Mounting dev..."
sshfs ken@REMOTE_COMPUTER: ~/dev
fi
fi
Log into your home account and verify it worked:
gentoo # su - ken
Mounting dev...
gentoo $ df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda3 7122792 4533864 2227108 68% /
udev 10240 136 10104 2% /dev
/dev/sda1 99521 8807 85575 10% /boot
shm 182888 0 182888 0% /dev/shm
kburtch 302077948 74804484 227273464 25% /mnt/windows
ken@REMOTE_COMPUTER: 57803996 39441360 15426356 72% /home/ken/dev
Add settings for all users to /etc/profile, the global
shell profile file. Add the lines (as required) to the end of the file:
# Direct X to use Windows' Cygwin/X display
export DISPLAY=YOUR_WINDOWS_IP_HERE:0
On Windows Vista, you can automatically start VirtualBox by adding a shortcut to it
in the startup directory
C:\Users\USERNAME\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup.
Alternatively, you can try turning VirtualBox into a Windows Vista service. Instructions are at
http://thelivedevil.com/virtualbox/how-to-run-virtualbox-as-service-in-windows/.
Add updatedb (for slocate) to your crontab to update the locate database on a
daily basis.
-
Try It Out
Create a new account for yourself using adduser and switch to the account with
the su command.
To run a new terminal session:
gentoo $ konsole &
or
gentoo $ gnome-terminal &
Tip: Create a new profile with the colours and fonts of your choice (bitstream
vera sans mono is a good choice for a terminal font) then you can add
--window-with-profile="YOUR_PROFILE_NAME to Gnome terminal or
--profile="YOUR_PROFILE_NAME in the KDE Konsole terminal.
Now you can do something like opening two different tabs at once, with
different colors, one running the screen terminal utility and one
logging into a different computer
gentoo $ gnome-terminal --geometry="95x45" \
--window-with-profile="PROFILE_NAME1" --command="screen" \
--tab-with-profile="PROFILE_NAME2" --command="ssh USER@MACHINE" &
I recommend putting frequently used commands into a shell script or a shell
alias to make it easy to set up your work environment. |
To start a file browser (without the full desktop):
gentoo $ /usr/bin/nautilus --browser --no-desktop &
Without --no-desktop, Gnome's Nautilus browser will attempt to open a whole
Gentoo desktop over top of Vista's desktop, which is probably not what you want.
Nautilus can also be used to browse your remote directory mounted with SSHFS
and open files using your Gentoo machine.
If you prefer KDE, you can try running Konqueror for the same tasks but for
some reason Konqueror didn't show my SSHFS mounted folder.
To start an Integrated Development Environment (IDE):
gentoo $ kdevelop &
or
gentoo $ anjuta &
or
gentoo $ /usr/lib/eclipse-3.4/eclipse &
-
Upgrading to Bridged Networking
This virtual machine was configured using NAT (ie. IP masquerading) so that, to
the outside world, Gentoo looks like a part of your host machine. If you used
bridging instead, Gentoo will look like a separate computer. This will allow
your Windows computer to access the virtual guest over the network.
In VirtualBox, Bridged networking is an option under settings / networking.
Change the setting from "NAT" to "Bridged". Restart the Gentoo virtual
machine.
On the Gentoo virtual machine, start the SSH service. Check your new IP
address (if you're not using DHCP, you may have have
the configure the Gentoo networking settings.
gentoo # /etc/init.d/sshd start
[...some things happen...]
gentoo # ifconfig
eth0 Link encap:Ethernet HWaddr 08:00:27:f0:9f:27
inet addr:192.168.1.123 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fef0:9f27/64 Scope:Link
[...some other things displayed...]
Try logging in.
cygwin $ ssh ken@192.168.1.123
The authenticity of host '192.168.1.123 (192.168.1.123)' can't be established.
RSA key fingerprint is 8b:4f:bc:94:0f:ee:17:fa:d4:2f:65:e4:78:19:9a:56.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.123' (RSA) to the list of known hosts.
Password:
Mounting dev home directory as ~/dev...
gentoo $
Now you'll be able to open remote desktops, run a web server, or perform
other server computer tasks. For a developer, this is like having your own
private sandbox to work with.
To direct X Windows to use your Windows desktop, remember to disable
the X security settings (or, at least, to authorize access by the Gentoo
IP number since it now appears to Windows to be different computer on the
network.
-
Next Steps
Sound is also possible with VirtualBox. It emulates one or more common
sound cards. You'll need to install support for the sound card in your
Gentoo kernel and rebuild the kernel. Then install sound support in Gentoo.
See
Gentoo Alsa Sound Guide.
To install Fedora Linux on a Windows Vista computer running
VirtualBox took, perhaps, 1 hour. To install Gentoo took closer to a
full week but I ended up with a virtual machine custom-built
for my CPU. Maybe it proved my Linux skills but, like installing Gentoo on
a server computer, I have to question whether the advantages are worth the costs.