Linux & FreeBSD on a Sony VAIO PCG-R505R/GK

Setting up a triple-boot configuration: Windows 2000 Professional, Gentoo Linux 1.4, FreeBSD 5.0

Last update: 5 May 2003

Ulrich Plate


Open source operating systems are a more benevolent regime to take over any kind of computer, no doubt about that. Windows gets worse the more you use it, forgotten DLLs sleep in dark corners of the OS, only to bite you in the hand when you dare touch them. Installing and uninstalling software should be forbidden by law, the only way it really works for a considerable amount of time is when you stay away from anything but the preinstalled software. On the other hand, both Linux and Unix make you go through the hardships of an initial installation (because it's still very hard to find vendors for pre-installed Linux or BSD PCs), but they run a much tighter ship in terms of security, they allow you to do modifications to your liking, and they generally make you feel good about doing The Right Thing®. However, I don't condone deleting legacy operating systems. This article isn't being written for alt.os.linux.advocacy, if you're merely here to take a good warm bloodbath at a public Microsoft slaughterfest, you've definitely come to the wrong place.

Why a triple-boot laptop? Because I didn't know what else to do with the disk space. Frankly, 30 GB in a portable computer are more than I would know how to fill. Besides, playing around with each OS is nothing but fun, great inflight entertainment if you travel a lot. On the downside of things, I don't get much done on it anymore, either Gentoo or FreeBSD are constantly doing their rsync/cvsup thing, I haven't even gotten around to test some of the applications I've installed. I'll keep this a work in progress, whenever I can think of something to add I will. I don't think I'm going to install any other OS variants on this particular machine, so if you're looking for advice on how to install S olaris, 0S/2, Be0S or whatever else you'd like to put on your Vaio, I'm afraid I can't really help you all that much.

I would have needed an overview like this one myself, preferrably shortly after the R505 hit the market in the summer of 2001. At the time, it was indisputably the fastest, sleekest, sexiest notebook PCs available, and the urge to put a more reputable OS on an otherwise perfect machine must have been very strong in the first adopters of a Linux or Unix installation. Unfortunately, nearly all the records of early installation attempts still to be found on the web show only cries of desperation, testimony of disappointing evidence that Sony hadn't left much in terms of supported hardware for any operating systems but the one it was shipped with. Almost two years later, most of these issues have been settled for good, and Linux and BSD now support almost everything that looked problematic last year. Maybe nobody needs this document anymore, but just in case somebody does: here's your cheat sheet for your personal choice of Open Source operating systems for this ludicrously expensive, beautiful, moody machine - a prom queen among notebooks.


Sony's R505 series had been designed as a slightly more futuristic successor to the legendary original 505 series, and as an ultra-light alternative to Sony's own larger laptops, those with pretty much the same specs, but bigger screens and 3 kg of weight or more... The R505R/GK, precisely, was the first model to ship with Windows 2000 Professional, sporting an 850 MHz Coppermine CPU, 128 MB RAM and a 30 GB harddisk, enough to make any other laptop/notebook look just kludgy and clumsy in comparison. The docking station was included when I purchased it from one of the discount shops in a sinister back-alley of Akihabara, Tokyo's electric town, for less than 250,000 JPY (roughly 2000 USD at the time).

Docking stationIt's not nearly as much fun without the detachable base, because it has a CD-RW/DVD-ROM built in, as well as a floppy drive, and it also accomodates the serial and parallel ports, USB and Ethernet and additional monitor, firewire and USB jacks, even though they're partly just replicated from the main unit (impossible to use both Ethernet jacks at the same time, for example). Since I didn't want to carry CD-ROM and floppy drives with me all the time, I was very happy about leaving all the peripherals plugged into the base whenever I traveled with my highly portable 1.2 kg main unit. Which essentially was equipped with everything it needed while away from the mother ship, one PCMCIA slot, two USB ports, yet another i.Link jack, Audio and VGA output, a built-in modem and RJ-45 port hidden behind a fragile looking, but sufficiently robust soft plastic cap. And a slot for a memory stick, of course: It is a Sony after all...


I started being less enthused when I gradually discovered all the things that were evidently missing, but had been overlooked or didn't feel so bad when I first looked at the machine in the shop: No built-in microphone, no IrDA port - how was I supposed to synchronise with my mobile phone or my Zaurus PDA? - and worst of all: no TV out jack! There's a DVD drive built into the base, for crying out loud, how could they not honour the fact that most users will inevitably wish to plug their cleverly designed notebook into a big TV set, rather than watching the Matrix on a 12" screen? But I got even more furious about the things that were there, but turned out to be so horribly misdesigned that I started to wish I hadn't bought the thing in the first place... The CD-RW/DVD-ROM combo drive, for example, is a Matsushita UJDA710, the most disgraceful drive globally available. Imagine me spotting it two weeks after the purchase on a blacklist maintained at http://forum.firmware-flash.com, as one of only a handful of drives whose manufacturers did everything in their power to make it impossible for the firmware flashers to revoke the region protection encoding. Fortunately, that particular problem has been settled, they came out with a flash tool to make the drive RPC-1 in January 2003.

Hardware Specifications Overview

CPUIntel Pentium III (Coppermine) 850 MHz
RAM384 MB SDRAM (128 MB original configuration)
Drive30 GB Toshiba MK3017GAP ATA
CD/DVDMatsushita UJDA710 (CD-RW/DVD-ROM)
LCD Screen12.1" XGA TFT (4 MB VRAM)
Graphics controllerIntel 82815 CGC
NICIntel Pro/100 VE
AudioIntel i810 (AC'97 compliant)
ModemConexant Ambit SoftK56 Data/Fax ICH Modem
IEEE 1394Texas Instruments TSB43AA22
Cardbus BridgeRicoh Co Ltd RL5c475

Windows 2000 Professional

Deleting Windows was not part of the agenda this time, unlike my first Linux installation on a Vaio 505EX/64 last year, when space constraints on merely 2 GB worth of hard disk space dictated getting rid of the legacy system before installing Mandrake at the time. Besides, W2K Pro isn't all that bad, it's stable, which in Microsoft-user speech means I never actually had to reinstall it, in over a year of operation... The network management is comparatively pleasant, it must have been a radical step forward for Microsoft to design a system that doesn't need to reboot when the user changes its IP address. I'm going to continue to use W2K for a number of desktop publishing purposes, namely applications not available for any of the Unices or even fully functional in Windows emulators, Adobe on top of the shameful list. I am aware that keeping Windows around for desktop publishing doesn't sound right to professional DTP people, and I would have to agree: investing in a Macintosh may be a wise choice at some point.

Sometime around spring 2002, Sony started offering to upgrade this model to Windows XP, and I even bought the CD and everything. I chickened out of it for two reasons: the booklet that came with the upgrade CD made crystal clear that I would have to erase the entire W2K installation including all installed software to be able to do it, something I was absolutely not prepared to do under any circumstances (mainly because of my WiFi/PPPoE/whatnot driver collection that has accumulated over time, leftovers from the various locations on this planet where it had to go online, some of those drivers would be almost impossible to restore).

The other reason was Microsoft's shiny new End User License Agreement... Have you READ that thing?


Resizing an NTFS partition isn't something you do without trembling hands and sweaty palms, especially if you intend to keep its contents. I had the relative ease of mind that results from using Partition Magic (v7.0), and resizing went without a hitch. But then I made a big mistake, by allocating space for a second primary partition with the same tool. I should have left what was to become the FreeBSD slice out of the equation altogether, because even if it gets flagged as unallocated, Windows still sees it as D:, and this seems to screw up the disk layout once Linux and BSD have rearranged their own space. Be that as it may, I cannot use Partition Magic anymore, unless I do what it suggests in the screenshot. Which of course I have no intention to do, because I'm not going to jeopardize the other partitions just for that. That's why the steps below don't show how I actually did it, but how I would do it, now that I know I should have limited the use of Partition Magic to the absolute minimum...

Partition Magic error message

I originally had two Windows partitions, C: with 12 GB and D: 18 GB, but C: was already almost filled up with the usual cruft, not a chance to reduce that amount. So the idea was to keep a W2K partition, but inflate it to 15 GB to have a little extra, and to redistribute the rest among Gentoo and FreeBSD. Out of experience, Gentoo requires a little more space than other Linux distros, at least until you get around to cleaning those stale distfiles. So I decided to use 8 GB for Linux and 5 GB for FreeBSD, the original intention being a proof of concept more than actual plans to excessively use FreeBSD on that machine. As it turns out I'm currently using it more than the other two OSs on the Vaio, but that's a different story.

Here is how to go about allocating space and the creation of filesystems, the steps are:

  1. Resize C:, delete D:, using Partition Magic or any other Windows software that can deal safely with NTFS

  2. First install Linux, use fdisk to create a primary partition at /dev/hda2 that's later going to turn into a FreeBSD slice, and as many extended partitions (/dev/hda5 and up) as you want for Linux

  3. During the FreeBSD installation, use the disk label editor that is part of sysinstall to create partitions for FreeBSD in /dev/hda2, now more appropriately called a slice, /dev/ad0s2

And here's the final partition table design I ended up using:

BIOS partition Table entries Mountpoints Space allocation File system OS installed
First primary C:\   15 GB NTFS Windows 2000 Professional
Second primary /dev/ad0s2a
/dev/ad 0s2f
5 GBUFS FreeBSD 5.0-rc2
Extended /dev/hda5
8 GB ext3 Gentoo Linux 1.4-rc2

Gentoo 1.4-rc2

I need to summarily apologize to a lot of mailing lists, support forums, newsgroups and IRC channels... I've been pestering many people with my CD-ROM drive's complete inability to boot from anything at all, only to discover at long last that my drive has a problem of its own: laser drift, apparently... While it certainly is true that these Firewire CD-ROM drives can't boot properly, at least I should have gotten to a shell prompt, which would be sufficient to get a network installation out of the starting blocks, especially for something as modular and flexible as Gentoo. I have heard reports that the Gentoo 1.2 ISO does lets you boot into a shell, but the 1.4 LiveCD definitely doesn't. By the way, there's a wealth of reading material for people with similar hardware in the archives of the Linux-Sony mailing list and the collection of Vaio-related installation testimonials hosted by Louis M. Seigal. Larry the CowSo, I knew this wouldn't be as easy as any of the desktop installations I've done before. Especially to people not too much in a hurry I can recommend my strategy: Sit back, watch the mailing list, wait until all the weird hardware issues involved are being taken care of by the kernel development, and then move in for the kill.

Which boot medium?

The Gentoo LiveCD being out of the question for the purpose of this installation, I decided to try tomsrtbt first, the neat little single-floppy Linux distribution recommended by many people, including the official Gentoo documentation at some point. Alas, it doesn't work any more... Tom's uses a 2.2 kernel, and apparently that doesn't allow you to chroot into a 1.4 Gentoo tarball. I used that method with 1.2 tarballs last year, but had to look for alternatives now. After some groping around the web and asking around the Gentoo forums, I settled for Slackware 8.1 boot floppies. They did provide me with the most complete environment, but I had to unpack the bzip2'ed Gentoo tarballs on a separate host before I could wget them onto the Vaio, because Slackware didn't have bzip2 on the floppies, and I had to use the eepro100 driver for the built-in NIC because that's the only one available (it works, but the e100 would actually be more appropriate). Anyway, you can use pretty much whatever boot floppies you want, just make sure the essential tools are present, like chroot, fdisk, and especially support for the file systems you want to use. I didn't want ReiserFS or any other fancy filesystems, so the Slackware floppies served me well, but if you do, better look around for more luxurious boot media.

Netbooting is an alternative, of course, if you manage to get GRUB to netboot the Vaio from a boot server somewhere in your LAN, things may work even better. This is very well documented on the main Gentoo website, I encourage you to try that instead if it doesn't look too far beyond your abilities.

Partitioning the disk

With the NTFS partition out of harm's way, the Linux utility fdisk is the preferred tool to set up the remainder of the disk for both Linux and FreeBSD. Not much to keep in mind except that if you're planning to mount the Linux partitions from within FreeBSD, you better not choose any of the fancier filesystems like Reiser or XFS. Much like support for NTFS in Linux is experimental at best, FreeBSD is very unhappy about anything not formatted as plain old ext2 or journalised ext3, I'm afraid.

     fdisk /dev/hda          
Partition 5 for boot, 6 for swap, 7 for root
     ext2fs /dev/hda5 
Boot partition doesn't need a journalised filesystem
     ext2fs -j /dev/hda7

Kernel configuration

Gentoo, for reasons I don't feel to be entirely accurate, has a reputation of being the modern geek's choice, nothing fit for the noobie. But it has a significant advantage over the so-called user-friendly distros when it comes to unpredictable hardware, like the cursed Firewire CD-ROM drive in the R505's docking station, for example. Rather than trusting an automated installer routine to correctly configure all system components, Gentoo leaves you with the task of making all necessary steps during the kernel configuration. In a system jock-full of fishy hardware like the Vaio, this may even be the safer approach...

For my initial kernel I used Lostlogic's (aka Brandon Low, the former Gentoo kernel maintainer) lolo-sources (2.4.20), which are a heavily patched testbed or precursory stage of the Gentoo sources proper - at the time of the installation the Gentoo sources were lagging behind by one minor release number... Here are some of the important elements of a 2.4.20 kernel that supports all the hardware in the R505 and the docking station:

     #CONFIG_PREEMPT is not set
If you want to use your built-in modem, you can't run a pre-emptible kernel because the Conexant driver modules (hsflinmodem, 5.03.27 in my case) unfortunately don't compile if you do. I'm only using it for sending faxes, but still, I'd hate it if any of the hardware in the system was unaccessible. You need to emerge hsflinmodem, then run hsfconfig. Your modem will appear as /dev/ttySHSF0
Sony Programmable I/O drivers for the jog dial built into the touchpad. You need to emerge sonypid and spicctrl on top of that. See below for further details.
#CONFIG_EEPRO100 is not set
Do not use the eepro100 drivers for the motherboard NIC after you've finished the installation. eepro100 was written for a completely different NIC and works only by accident, the real McCoy is Intel's E100 driver, make sure you use that for your kernel.
     #CONFIG_PCMCIA is not set
For Wireless LAN cards, the PCMCIA kernel support has to be switched off in favour of a separately emerged pcmcia-cs package. Wireless support needs to be enabled, but no individual drivers should be built in or as modules.

Wireless LAN PCMCIA Card

If you're wondering why you weren't supposed to configure any modules for WLAN or even PCMCIA during the kernel build: The pcmcia-cs ebuild contains a lot more than just the kernel modules, and you could possibly mix them together, but rumour has it it's better avoided... The procedure is simple, though.

emerge pcmcia-cs
rc-update add pcmcia default
cp /etc/init.d/net.eth0 /etc/init.d/net.eth1

Edit /etc/conf.d/net and add an interface, like that:


Upon your next reboot the card manager will get started and watch your slot for anything you might want to shove in there, and as soon as the WLAN card pops in, the cardmgr wakes up and configures the NIC. My /etc/modules.autoload reads like this:


And don't forget to re-emerge the pcmcia-cs package if you upgrade your kernel, or you'll be scratching your head like I did when the modules didn't get loaded any longer after a kernel recompile...

If you happen to work in an office that protects its WLAN with WEP, you have to add a configuration string to your startup scripts. In that case you had better emerge the wireless-tools and do it via iwconfig:

emerge wireless-tools
iwconfig eth1 essid NAME key [n] s:XXXXX [n] s:XXXXX [n] s:XXXXX [n] s:XXXXX

I have no idea whether it was clever or not, but I added this string directly to /etc/init.d/net.eth1 (right after it checks for eth0 to be up or not). There may be a canonical way to do this, but if there is, I don't know of it.

Jog dial

Sony introduced a hybrid scroll wheel and function caller device in most of their Vaio notebook models that looks like the little jog dial you'd rather expect in a PDA or a mobile phone. On the R505 it's simply integrated into the touchpad. Very useful for scrolling up and down web pages, but you can also use it to access a menu for setting brightness and volume or launching applications. Sony Programmable I/O is a kernel option you need to compile in, and then you want the utilities:

emerge sonypid
emerge spicctrl
emerge sjog

A device /dev/misc/sonypi will get created if everything goes right, but before it'll actually work in a non-root user environment, you will have to add a line to /etc/devfsd.conf:

REGISTER ^misc/sonypi PERMISSIONS root.root 0666

And then it's just a matter of telling your favourite window manager to launch sjog along with its own startup:

ln -sf `which sjog` ~/.kde/Autostart/sjog

If you want to change the default menu that pops up when you press the middle button, just edit /etc/sjogrc to your liking. My only problem with sjog: I can't use the knob as a third mouse button, making copy/paste operations or opening URLs in Phoenix tabs rather cumbersome. I'm working around this via 3-button-emulation in /etc/X11/XF86Config:

    Option "Emulate3Buttons"
    Option "Emulate3Timeout"    "50"

Pressing both buttons on the touchpad at the same time now pastes highlighted text like it's supposed to. Not the most elegant method, but at least I don't have to use the clipboard all the time.

Bootloader installation

I could have tried to be nice to Windows and use the NT bootloader to load GRUB for Linux and the FreeBSD loader, but I use GRUB to boot everything including the kitchen sink, so the chainloader entries for W2Kand BSD go in here. Very straightforward, worked right out of the box. Here's my grub.conf:

default 0
timeout 10
title=Gentoo Linux 1.4
root (hd0,4)
kernel /bzImage root=/dev/hda7

title=FreeBSD 5.0
root (hd0,1,a)
kernel /boot/loader

title=Windows 2000 Professional
rootnoverify (hd0,0)
chainloader +1

FreeBSD 5.0-rc2

A radical contrast to the many times I've installed Linux in general and Gentoo in particular, on various hardware in all stages of obedience, this was my first FreeBSD installation ever, and I had really been looking forward to this one. Living in Japan, the number of people in my immediate environment using FreeBSD rather than Linux is higher than anywhere else on the planet, and you risk bumping into quite a few even at Tokyo Linux User Group meetings. Because of the tricky hardware this would end up on, I was planning to wait for the final release of 5.0 (from FreeBSD's CURRENT branch), and I wouldn't have had to wait for long, it was only a few days away at the time of most of this writing. But the dynamics of the first week in January being what they are in Japan (i.e. a complete absence of anything dynamic, really), I decided to prevent boredom by letting the Gentoo installation pull me along and do it all in one smooth go.

BeastieFreeBSD doesn't have an answer to the Firewire CD-ROM mess in the Vaio, either, but this eventually mattered even less than for the Gentoo installation. FreeBSD has a set of boot floppies for 5.0 ready to use for this exact purpose: Get the kernel to spin in RAM and do the installation onto your disk entirely via FTP over the network. Easier said than done: I downloaded the two floppy images that are needed to get the bare minimum running (KERN and MFSROOT), dd'ed them from my Linux desktop to floppies:

     dd if=/tmp/{floppyimage} of=/dev/fd0

And then had no ends of fun booting from those, because every time I did, I'd run into a strange "kernel module if_pw.ko Baystack 660 not found" error, followed by a kernel panic and a frozen Vaio. Hmm. Somebody on alt.os.unix.freebsd suggested that Unix needs absolutely flawless floppies, meaning my five-year-old DOS-formatted 2HD BASF disks are almost certain not to qualify, but eventually, after the third or fourth fruitless attempt and much rapping of the floppy on the edge of my desk, I accidentally went into the BIOS at the next startup, remembered all of a sudden to uncheck "Plug and Play OS", and this time it booted all the way through. Phew.

FreeBSD sysinstall

I went for the standard installation and started by formatting the slice for FreeBSD, dev/ad0s2. The Disk Label Editor knows of a standard partitioning scheme if you just hit "A" after selecting the slice you're going to use, very convenient.

Without any hope to mount a CD for the remainder of the installation, sysinstall proved to be a fabulous tool to run the installation via the network. The kernel had picked up my NIC, and I had manually added an IP address via ifconfig and a gateway in /etc/resolv.conf. I went about the entire installation with that fixed IP address, although I discovered inside the sysinstall menu that I could have just set DHCP to yes. I changed that later, but for the moment I set Media type in the installation options to FTP, chose an FTP-mirror to install from, and then could only watch in amazement how the system got sucked into the machine without much interference from my side. I installed X without KDE or Gnome because I wanted to give a genuine more BSDish window manager a try (settled for WindowMaker in the end), and didn't touch any other binary packages, either, but rather went for the FreeBSD ports collection. Knowing where Gentoo's Portage has its roots, ports just had to be a natural choice, even for someone as unfamiliar with FreeBSD as I am.

XF86config was easy, I just copied the refresh values from my Gentoo installation, made WindowMaker from ports and was set to go. Using sysinstall for the final touches of setting up a user and services to be activated upon boot, the entire installation was done in a matter of hours (including the download), once the boot floppies had decided to give up the struggle. Much faster than Gentoo, all in all...

PCMCIA worries

The CardBus manager in 5.0 is different from the old 4.x method, and occasionally still good for a bumpy ride. Even though I didn't even have a card in the slot, dmesg showed:

cbb0: Unsupported card type detected 

Thanks to the awesome FreeBSD-Mobile mailing list, the solution was quickly found: Simply tell the kernel to use interrupts outside of the usual range, because the Vaio's BIOS apparently sets it to something funny. Add this instruction to your /boot/loader.conf and you're set to go:


I still haven't managed to get things unloaded and reloaded whenever I remove cards from the PCMCIA slot, but at least I can boot with my WLAN card in the slot and get it recognised by the kernel.

WLAN configuration

My antique Orinoco Silver card is automatically recognised as device wi0 when I boot. It usually suffices to start DHCP on that interface, and that's done in the standard FreeBSD way, by adding a line to /etc/rc.conf:


But if your WLAN environment uses WEP, you need to add a separate script in /etc called start_if.DEVICE and fill it with the encryption instructions (via ifconfig, not wicontrol, because someone told me the latter is being deprecated):

ifconfig wi0 ssid IBSS_NAME wepmode on weptxkey 1 wepkey 1:XXXXX wepkey 2:XXXXX wepkey 3:XXXXX wepkey 4:XXXXX

The Orinoco card works as expected after that. Oddly, a Prism-based card I tried to use in the same setup (Netgear MA401) accepts these ifconfig instructions, crypto keys and all, but DHCP times out during bootup (and dhclient fails when started manually, too). Unfortunately, I haven't figured out what happens, all I know is that it does work in Linux without changes to the configuration files.

Upgrading FreeBSD

In a matter of days after I installed the last release candidate, FreeBSD announced 5.0-RELEASE. Being unfamiliar with upgrading a BSD, Scott Robbins'page helped me a lot to get things going. After running -RELEASE for a few weeks, I've changed to -CURRENT in the hope of getting a few hardware issues solved over time (network cards etc.). By the way, Scott also has a page on Japanese input methods that is extremely helpful, especially for FreeBSD.

Important links (last verified to be unbroken on 5 May 2003)