Linux on Sony VAIO PCG-FRV28
by Stuart D. Gathman
Mar 26,2009 Dell had stopped selling low end laptops with Ubuntu, and a customer needed a linux laptop to do those simple things that Windows refuses to do, like share printers with itself (for use with SSH tunneling). With Dell out of the picture as a low cost computer vendor, we went for used, and the customer sent me a Sony VAIO PCG-FRV28 by Next Day Air with 512M ram, 40G disk, and 2.8Ghz Pentium 4 CPU. This laptop had a severely infected copy of Windows XP (including the infamous "You need to install AntiVirus" virus) , and would need a reinstall of Windows anyway - so it was selected to get a new OS instead. I would then configure a login with icons for remote access to their order entry application.
The Initial Attempt
I decided to use Fedora 9 since it was ultra stable at the moment, and put in the F9 LiveCD to boot. This would also let me check out the hardware and send it back if there were any serious incompatibilities. The BIOS did not boot the CD, but skipped directly to XP on the hard disk (which immediately began insisting that I needed to connect to the internet and install Antivirus). Ok, so booting from CD was disabled in the BIOS. I restarted, and guessed F2 as the BIOS setup key. This was a good guess, except the BIOS had a password.
Attempting to Unlock the BIOS
I called the customer and asked for the password. After a flurry of memos, it was finally determined that nobody knew who had set the password, or what the password was. (Note to self: when purchasing a used PC computer, make sure you can get to the BIOS setup screen.) I did some online research and tried the factory backdoor passwords for Phoenix BIOS, no joy. Sony has changed the backdoor password from the Phoenix default, and I found no mentions of a Sony backdoor password. The customer provided a handful of likely passwords, which also did not work. I should have shipped the computer back at this point, but I am a glutton for punishment.
If you can boot to DOS, and run DEBUG, there is a simple real mode io sequence to corrupt the CMOS, provoking most BIOS implementations to reset to factory defaults and clear any password. Since I could not do that, there is also a free (as in beer) Windows program called "KILLCMOS" that will do something similar (if you have Admin privilege on Windows - which most end users do to avoid having to deal with an Admin account). It also installs Spyware (definitely not Free) - not a problem since we are going to wipe Windows anyway. However, I was scared off by a report of KILLCMOS bricking someones Sony laptop.
Removing the Hard Drive
Some laptops go so far as to lock the hard drive with the BIOS password at poweroff - unlocking it at startup. Defeating this requires risky measures like pulling the battery while Windows is running (which could easily damage hardware). Any secrets on the drive are unencrypted, however, and are "easily" recovered by simply moving the platters to another drive of the same model in a home clean room (or more expensive techniques like laser scanning of the platters). It was easy enough to test this, however. I removed the drive and attached it to a USB/IDE converter, and plugged it into my Fedora 10 desktop. Nope, not locked.
Installing Fedora without the installer
Partitioning the Drive
The drive was connected via USB to /dev/sdb on my desktop. I used
# fdisk /dev/sdb
to inspect the partition table. There was a 5GB Sony Diagnostics partition, which I left alone since it could be useful, and some Windows partitions, which I deleted. I then allocated a 200M boot partition on hdb2 as Linux and the remainder of the drive as an LVM physical volume on hdb3. I used
# mke2fs -j /dev/hdb2
to format a filesystem on the boot partition and
# pvcreate /dev/hdb3
to format a physical volume (PV) on the LVM partition. I used
# vgcreate rootvg /dev/hdb3
to add the PV to a Volume Group (VG) named "rootvg". (If you are following my example - make sure that "rootvg" is *not* the name of any existing volume group on the system you are using. Use "vgs" to list them.) I used
# lvcreate -L 15G -n f10 rootvg
to allocate a root filesystem,
# lvcreate -L 1G -n swap rootvg
to allocate some swap, and
# lvcreate -L 16G -n home rootvg
to allocate a "/home" filesystem. These were all formatted with
# mke2fs -j /dev/rootvg/f10 # mkswap /dev/rootvg/swap
respectively. I noted the UUID reported by mkswap for use below. I would deal with moving /home to the 3rd LV after the system was booting.
Copying the System
I mounted the filesystems with
# mount /dev/rootvg/f10 /mnt # mkdir /mnt/boot # mount /dev/sdb2 /mnt/boot
# rsync -ravHxX /boot/ /mnt/boot
to copy /boot and
# rsync -ravHxX --exclude=/home/\* --exclude=/var/cache/yum/\* / /mnt
to copy the system, minus user data.
Tweaking the Copy
Fedora mounts filesystems by UUID, and I wanted to stay with that scheme, so I obtained the UUIDs of the filesystems with
# tune2fs -l /dev/sdb2 | grep UU # tune2fs -l /dev/rootvg/f10 | grep UU
Using vim (or your favorite plain text editor), I edited /mnt/etc/fstab to insert the UUIDs of /, /boot, and swap. Next I edited /mnt/boot/grub/grub.conf to change the root UUID. I also changed "root (hd0,0)" to "root (hd0,1)" in grub.conf since I had preserved the Sony Diagnostics in the first partition and copied /boot to the second partition. If you are following my example, I hope you know how to use cut & paste, or the "!!" command in vim. I edited /mnt/etc/passwd, /mnt/etc/group, /mnt/etc/shadow, /mnt/etc/gshadow to remove the users and groups that were on my /home (and not copied).
I edited /mnt/boot/grub/device.map, and changed the map line to
This tells grub to install the loader to access blocks currently mounted via /dev/sdb as BIOS drive 0x80. Then I used
# grub-install --root-directory=/mnt /dev/sdb
to install the MBR and grub loader on the laptop drive. Then I changed /mnt/boot/grub/device.map back to "(hd0) /dev/sda", which would be correct when using grub on the laptop.
An important function of initrd is to load the kernel modules necessary to read the disk to mount the root filesystem. (The kernel and initrd were loaded by grub using BIOS calls.) Unfortunately, I did not know what IDE controller was on the laptop. I didn't know how to get the PCI id information out of Windows.
I made a few trial and error guesses (installing and removing the drive each time), but eventually hit upon the strategem of copying the isolinux directory from the LiveCD to /mnt/boot and adding an entry to /mnt/boot/grub/grub.conf to load the LiveCD kernel and initrd0. This initrd autodetected the IDE controller, and attempted to mount the CD (which would have let me do a LiveCD install as I originally intended), but it failed with "head select" errors (more on that later). But the LiveCD initrd helpfully drops you to a root shell, and I used "lsmod" to discover that the "pata_ali" module was required to access the hard disk (and CD).
# mkinitrd --with=pata_ali --fstab=/mnt/etc/fstab /tmp/initrd-220.127.116.11-170.2.35.fc10.i686.img 18.104.22.168-170.2.35.fc10.i686
to create the customized initrd using the then current kernel version. (The trial and error attempts included a variety of guessed pata_* drivers - none of which were correct.) When this completed with no errors, I moved it into position with
# mv /tmp/initrd-22.214.171.124-170.2.35.fc10.i686.img /mnt/boot
After all these preparations, I did
# umount /mnt/boot # umount /mnt # vgchange -an rootvg
to unmount everything on /dev/sdb. (Also unmount anything automounted on your desktop.) Then I unplugged the USB, disconnected the laptop drive, and reinstalled it in the laptop. Powering it on brought up grub! During the trial and error attempts to discover the required IDE driver, the kernel would load, but fail after reporting "volume group rootvg not found" and failing to find the root filesystem. With the proper driver, however, Linux proceeded through its boot proceedures (where kudzu discovered lots of hardware changes - doh!). Since linux keeps the hardware clock in UTC, and Windows keeps it in localtime (as nearly as it can manage this logically impossible task), the filesystem timestamps were in the future, triggering filesystem checks. When this was all complete, however, up came the Gnome login!
With no users, you cannot use the Gnome login, so I Pressed Ctrl-Alt-F2 to switch to a text console, and logged in as root on the laptop. I formatted /dev/rootvg/home and mounted it as /home, adding it to /etc/fstab. I added some users with "groupadd" and "useradd", and was then able to login to the GUI. The sound was autodetected by ALSA (ALI5451) and worked well. The graphics adapter (ATI Radeon IGP 3x0M) and display (1024x768 LCD) were auto detected flawlessly by xorg. The ethernet port worked out of the box. There was no builtin wireless installed. The 3D performance is lackluster (450 FPS in glxgears), but sufficient for games like "Neverball".
The CD drive
The CD drive was evidently broken all along (was shipped with no cardboard or scratch CD), so having the BIOS password wouldn't have helped anyway. It is a MATSHITA Model UJ-810, and recognized by Fedora 10. Any attempt to read a CD, however, results in
Mar 29 12:39:41 rafael kernel: sr: Sense Key : Hardware Error [current] Mar 29 12:39:41 rafael kernel: sr: Add. Sense: Head select fault
getting logged to /var/log/messages. To be really sure, I should have tried reading a CD in XP before wiping it - but I didn't think of it.
I tried an RT73USB chipset USB dongle (ASUS WL-167G), and an RTL8180L based PCMCIA wireless card (Gigafast WF721-AEX), both of which worked out of the box. Note that manufacturers will change chipsets without changing the model number (really evil, but what can you do about it?), so always plug the device into a non Windows computer (including Mac) to discover the PCI or USB id and lookup the chipset.