Human Readable  

 

     
   
     

Multi-Booting With Firefox

© Copyright Darrell Anderson.

(Updated October 2005)

Introduction

The Firefox web browser is one of the better browsers, although there are several noticeable shortcomings. However, one of the more flexible aspects of Firefox is using the browser in a Windows and GNU/Linux multi-boot environment.

With some manual fine tuning, Firefox can be configured to function in both operating systems and share many of the same configuration files and options. This reduces overhead and minimizes the differences between the two environments.

An important difference is realizing that file paths are written differently between the two environments. Through diligence, however, you can share the file cache, bookmarks, as well as userContent.css and userChrome.css. If you have a shared FAT32 partition, you can share additional configuration files. Although these features can be shared, understand that the process is always manual in nature and each user is required to perform regular “spot checks” to verify everything is configured correctly. Use a file comparison tool to help control that effort. In Windows the WinMerge utility is a good tool and in GNU/Linux there are many options. For KDE users, such as myself, use Kompare, which is the KDE front-end to the diff tool.

Before trying to share these common configurations, first install Firefox in your primary operating system. Be sure that the basic installation works as expected as well as all extensions and themes.

Then manually create a user.js file for your primary environment. Although maintaining a common user.js would be great, doing so is impractical because of the difference in the way file paths are written. Therefore, the best approach is fine tune the user.js within the environment you are most comfortable or familiar. Get everything working seamlessly. Then copy the user.js file to your GNU/Linux profile. At that point, if all is working well, you need only edit those user preferences that contain file paths. Then maintain those files using your file comparison tool.

Because most multi-boot users migrate from Windows to GNU/Linux, this How-To is written from that perspective.

Bookmarks

The bookmarks file usually is the primary feature most people want to share between environments. Realize that the bookmarks file should be located in a shared FAT32 partition in order to update and change the bookmarks from either operating system. However, if you primarily use Windows and GNU/Linux occasionally, the bookmarks can be stored on an NTFS partition. Realize, however, that without additional effort you then will be unable to modify the bookmarks file from within GNU/Linux. Of course, your GNU/Linux distro must be configured to read FAT32 or NTFS partitions. To share your bookmarks file:

  1. Create a separate Windows folder to store your bookmarks file. Create this new folder anywhere outside the Windows Firefox profile you use. Preferably this location is on a shared FAT32 partition.
  2. Copy the bookmarks file from your Firefox profile folder to this new folder location.
  3. Using a text editor, edit user.js. The line you want to add or edit is:

    user_pref("browser.bookmarks.file");.

  4. Although the following text is only an example, modify that preference to point to the new folder location:

    user_pref("browser.bookmarks.file", "D:\\Firefox_Shared\\Bookmarks\\bookmarks.htm");.

  5. Save user.js.

Open Firefox and verify the bookmarks look correct and operate as expected. Then delete the bookmarks file from your Firefox profile directory. Repeat the test. If all is well then from this point forward your bookmarks file is stored outside your profile directory. This option also helps you if your profile corrupts. You need not worry about the bookmarks file being corrupted or lost as well.

File Caching

Like bookmarks, you should configure your file cache folder to a location outside your Firefox profile. If you use a shared FAT32 partition, then locating this folder to that partition means you can share your cache files. Following the bookmarks example, all you need do is add or edit the following preference:

user_pref("browser.cache.disk.parent_directory");.

Modify that preference to look something similar to the following:

user_pref("browser.cache.disk.parent_directory", "D:\\Firefox_Shared");.

One of the tricks to configuring the cache folder outside your Firefox profile is to realize that Firefox will create subfolders under the folder you create. For the above example, Firefox will create two new folders:

D:\\Firefox_Shared\Cache

D:\\Firefox_Shared\Cache.Trash

As before, open Firefox, surf, and then use your file manager/explorer to verify that cache files are being created in Firefox_Shared\Cache. When satisfied that your cache is being maintained properly, delete the Cache folder from your profile directory.

userContent.css and userChrome.css

As with your bookmarks file, create a separate folder outside your Firefox profile to store your userContent.css and userChrome.css files. Then copy those same files from your Firefox profile (located in the Chrome directory) to the new folder location.

Next edit your profile userContent.css file to include only one line. The following is an example, therefore modify for your own system as necessary:

@import "file://D|/Firefox_Shared/Chrome/userContent.css";

Likewise, edit your profile userChrome.css file to include only one similar line:

@import "file://D|/Firefox_Shared/Chrome/userChrome.css";

Of course, use the file path that is appropriate for your system. Save both files. Once again, test Firefox to verify that everything is functioning properly.

Downloads

If you use a shared FAT32 partition to store your bookmarks and cache, and your GNU/Linux distro is configured to write to that FAT32 partition as well as read, then you can use that same partition to create a common downloads folder. The user.js preference you want to add or edit is:

user_pref("browser.download.dir");.

Modify that line to something like:

user_pref("browser.download.dir", "D:\\Downloads");.

Final Preps Before Migrating

Next surf the web in order to create some additional profile files. You’ll want to create a cookies.txt, hostperm.1, history.dat, and formhistory.dat files. The cookies.txt file is where you current cookies are stored. Your white lists for cookies and images are stored in hostperm.1. Your surfing history is stored in history.dat. Form histories are stored in formhistory.dat. None of these files can be shared in a multi-boot environment like the previous files.

Migrating the Changes to GNU/Linux

After verifying everything is working as expected, boot into your GNU/Linux distro. If necessary next install Firefox and the same extensions and themes.

Then using whatever tools you are comfortable, copy the Windows Firefox profile user.js file to your GNU/Linux Firefox profile folder. Open the file using a text editor and modify the previously mentioned preferences using the correct file path syntax for GNU/Linux.

Within GNU/Linux you also will need to edit your userContent.css and userChrome.css files. Edit them both to use the @import statement, but using the correct GNU/Linux syntax for the file path.

Using the previous file path example, the configuration will look something like this:

@import "file:///mnt/fat32/Firefox_Shared/Chrome/userChrome.css";

@import "file:///mnt/fat32/Firefox_Shared/Chrome/userContent.css";

Start Firefox and test.

Sharing History, Cookies, Form Data, and White Lists

If you are comfortable copying, modifying, and installing Bash scripts and Windows batch files, and you maintain a shared FAT32 partition between the two environments, you can share the history, cookie, and white lists files between the two environments. As you can see from the attached scripts, the key is extracting the file date stamps, being able to synchronize those dates between the two systems, and using a temporary storage area on your shared FAT32 partition.

The script for updating files when starting GNU/Linux is written for KDE users and should be stored in your user ~/.kde/Autostart directory. Modify and revise as necessary for your system and desktop environment.

Sidebar: firefox_start

The script for updating files when exiting GNU/Linux is written for KDE users and should be stored in your user ~/.kde/shutdown directory. This directory does not exist by default and you might have to create the directory. Modify and revise as necessary for your system and desktop environment.

Sidebar: firefox_exit

Be sure to modify the user permissions to execute the scripts.

Use an additional script (batch file) for updating those files when booting into Windows. To execute the script when logging in be sure to store the file in your user profile Startup folder. Modify and revise as necessary for your system and desktop environment.

Sidebar: win_firefox_start

Fine Tuning the Differences

Some extensions, as well as some userContent.css and userChrome.css configurations will be different between the two operating systems. There is no easy way to adjust for those difference other than manual maintenance. To modify the userContent.css and userChrome.css files, simply add any necessary changes to the local profile after the @import declaration. For example, if you prefer to reverse the order of the dialog box OK and Cancel buttons, your userChrome.css would look something like this:

@import "file:///mnt/fat32/Firefox_Shared/Chrome/userChrome.css";

/* Reverse order of OK/Cancel buttons for GNU/Linux */

.dialog-button-box {-moz-box-direction: reverse !important; -moz-box-pack: right !important;}

.dialog-button-box spacer {display: none !important;}

One More Nicety

If you are on dial-up and use a hosts file to help you avoid DNS lookups to an external server for all of your bookmarks, and to avoid undesirable web sites, you also can synchronize that file in a multi-boot environment. Two additional scripts are necessary. The first script I place in my /usr/local/sbin directory because the script is administrative in nature and requires root privileges to succeed. My /usr/local file system is a separate partition on my system.

I named that script sync-hosts. The script requires a parameter of either local or remote. On boot-up I run that script from within my rc.local script.

Sidebar: sync-hosts

On shutdown I created a script that provides a similar purpose as rc.local. This script is a place for me to run personal and local shutdown tasks without continually editing or revising the original rc.d scripts. For my Slackware system, I named the script rc.shutdown and I run that script from the beginning of my rc.6 script.

Sidebar: rc.shutdown

Conclusion

Firefox is a flexible browser and hopefully as time passes the tool matures and becomes more flexible. In the mean time, multi-booters do possess several options to configuring Firefox similarly between Windows and GNU/Linux. Patience is required to successfully maintain that kind of operation.

Finis.

Table of Contents