Installing Linux on the Sony PCG F304

I recently bought a Sony F304, and installed Debian GNU/Linux on it. It's taken me a bit of time and web-research, but I've now got all of the important bits working. I decided to leave Win98 on the machine, just in case I need it at some point (it's possible, I suppose), but I shrunk its partition to give most of the space to Linux. Even if you want an unsullied Linux machine, these instructions should still be useful.

Here are a few notes that I made after I was finished. I hope that they'll be useful, and possibly save others some time. They should be useful to you no matter which distribution you're using, and I'm reasonably sure that all of the Sony F-series work the same with respect to the hibernation partition. With that said, I can make no guarantees that you won't screw up your partition table and need to redo everything. I take no responsibility for what happens to your machine. I recommend that you get the partitioning done before you copy/download anything of importance to your drive.

Vaio shuts down randomly

Update 2004-06-02: I thought my vaio was dead and gone, as it would shut down randomly during use. The problem got worse, so that I could not even boot up anymore. It turns out this is a hardware bug which affects many Vaio owners. I noticed that resetting my BIOS to the factory defaults allowed me to get past the lilo menu without the computer shutting down immediately. Then I found a site describing the problem, and how you can work around it by passing the "no-hlt" argument to the kernel at boot time. As of this date, installing acpid also causes the shutdown (even when no-hlt is used), but apm seems to work ok. My options for kernel 2.6.6 are "no-hlt acpi=off apm=on".

Hibernation Mode and Partitioning

The Sony F-Series notebooks have a so-called hibernation or suspend mode in which the current state of the machine is saved to disk, allowing you to "freeze" your work and come back to it later.

The BIOS needs a pre-arranged place on the disk to save this information; it can use either a file within a partition or a desginated partition. My notebook came configured with both: there was a 200MB file inside the Win98 partition, and there was a special partition as well.

I've seen a lot of other people warn "Don't touch that hibernation partition", but I removed mine and found that it's not difficult to re-create it. This can be useful if you want to completely reshuffle the partitions on your disk.

Partition location is unimportant

First off, contrary to some pages I've read on the web, there's no magic about it being the fourth partition on the disk; mine is now the 5th partition now and it works fine from both Win98 and Linux. As long as you create the partition using the little tool phdisk.exe that comes with the machine (described below), the BIOS will know where to find it.

Size of hibernation partition

The partition (or file) needs to be as large as the amount of RAM in your machine plus a few MB for video ram, etc. However, when re-creating the hibernation partition I noticed that phdisk left a bit of free (unpartitioned) space between my last partition and the hibernation partition, presumably because the partition needs to start at an even offset on the drive. Therefore, you may need a bit more, and may need to try a few times until you get the optimal space usage.

Procedure

Pretty much any way you look at it, you'll have to re-partition the hard disk to get Linux installed. If you got a rescue backup CD with your notebook like I did, there's not much to worry about, since you can restore the entire hard drive to the state it was in when you bought it. See below for more details.

Don't spend any time actually configuring Linux until you're got everything partitioned nicely and you've checked that hibernation works from both Linux and Windows.

Recommended procedure:

  • Locate your Sony Product Backup CD - booting this CD allowed allowed me to restore my drive to the exact state it was in when I bought it (including the partition table, Windows 98 and all preinstalled apps). I only needed it because I deleted the hibernation partition and wasn't yet sure how to re-create it. However, if you don't have this CD or aren't willing to test its merit, I'd think twice about continuing.
  • From within Windows, run the disk defragmenter tool on the partition you want to shrink. This moves all of the data to the "front" of the partition, and ensures that you will actually be able to shrink the partition as much as space allows.
  • Get Win98 to boot into MS-DOS mode.
  • Use the tool "fips" to shrink the Win98 partition. The tool is included with most Linux distros and is well documented. Under Debian Slink, it's found on the first CD, in the directory /tools/fips20 . Make a boot disk like the docs explain, just in case.
  • Reboot (to DOS again). Run scandisk and make sure everything is still happy on your Windows partition.
  • Updated 2004-06-02: a linux-based utility called lphdisk is now available
    Use the phdisk.exe tool (found in c:\windows\command\phdisk.exe ) to remove both the hibernation file and the hibernation partition (We'll recreate it later, once the partitioning is all finished). Here's how to delete them:

        phdisk /delete /file
    phdisk /delete /partition

  • Reboot so that the BIOS picks up the changes (it's just safer that way)
  • Now pick your favourite tool for partitioning. I used cfdisk from within Linux by booting from my Debian CD, but Partition Magic or other tools should also work fine. partitioning. I deleted all but the first partition (win98) and then created a few for Linux. I left some free space at the end to re-create a hibernation partition. Here's how my table looked at this stage:
        hda1                    Primary   Win95 FAT32                       2000.75     
        hda2        Boot        Primary   Linux ext2                        2997.43
        hda5                    Logical   Linux ext2                         996.68
        hda6                    Logical   Linux Swap                          73.83
                                Logical   Free Space                         124.30
        
  • At this point I installed LILO on the MBR (Master Boot Record), and set it up to be able to boot either Windows or Linux. There are other HOW-TO documents that describe how to do this.
  • Once you can boot both OSs without problems, boot back to DOS, and run the phdisk.exe utility again. I tried to specify the size explicitly, but it told me I didn't have enough space. Then when I tried a smaller size it told me it can only create partitions of certain sizes, and listed them. But when I tried again without specifying a size, it created a partition of a size that it hadn't listed (what a smarmy program!)
        hda1                    Primary   Win95 FAT32                       2000.75
        hda2        Boot        Primary   Linux ext2                        2997.43
        hda5                    Logical   Linux ext2                         996.68
        hda6                    Logical   Linux Swap                          73.83
                                Logical   Free Space                          44.30
        hda4                    Primary   Unknown (A0)                        73.83
                                          Unusable                             7.39
        
    Like I already said, I think phdisk needs to create the partition at an even boundary of some sort, hence the 44 MB of space between my swap partition and the hibernation partition. You might want to play around until you get it to work out nicely. I could always go back now and make my swap parititon a bit bigger, to use up the space, but I haven't bothered to yet, as I don't anticipate ever needing that much.
  • Before continuing to install Linux, make sure that the hibernation partition works under both OSs. You'll want to enable APM (advanced power management) in your linux kernel and run 'apmd' (power management daemon) so that Linux can take appropriate action (like flushing the disk cache) just before entering hibernation mode.
  • Updated 2004-06-02: with recent (kernels 2.4.2x, 2.6.x) this is no longer a problem. There is a problem on kernels where the USB is enabled automatically whereby suspending and resuming multiple times causes the notebook to hang. To fix this, disable the USB device just after rebooting by inserting the following line somewhere in a boot script (the proc device has to be mounted for this to function, however):

    setpci -s 0:7.2 command=0

  • Finished!