O'Reilly logo

Ubuntu Hacks by Bill Childers, Kyle Rankin, Jonathan Oxer

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Hack #7. Move Your Windows Data to Ubuntu

Your files, bookmarks, and other settings are locked away in a Windows installation. Learn how to move them over to your new Ubuntu system.

So you're making the big move. You're ready to pack everything up and move from Windows to Ubuntu. The easy part is getting Ubuntu up and running. The trickier part is migrating all your data, which is spread out all over your Windows hard disk. Here's how to pack up all your stuff and make use of it on your new Ubuntu system.

Make Sure You Notify the Post Office

If you're switching from Outlook, you probably won't be able to directly import your mail settings into a Linux mail program. Your best bet is to install Thunderbird (http://www.mozilla.com/thunderbird/) on your Windows machine and import all your Outlook settings into Thunderbird. Once you've done that, you'll more easily be able to export your mail and contacts into formats that Linux mail programs can understand.


If your mail account is on an IMAP server, you won't need to worry about all this exporting and importing. Since IMAP keeps the mail on the server, all you need to do is configure your new mail client with your email server, login, and password information, and all your mail (your inbox and email folders) will appear on the new system. Because IMAP keeps everything on the server, you can access the same email account from multiple servers, and you'll always have the same email messages on each computer. However, if you've moved any mail into local folders, you will need to export and import it.

Transfer Outlook into Thunderbird

Before you transfer your Outlook email into Thunderbird, first make sure that Outlook is set to be the default mail application (if you've been using it for your mail application, it probably is). Open the Control Panel and double-click on Internet Options. Go to the Programs tab and make sure that Microsoft Outlook (or Outlook Express, depending on which one you use) is specified as the email program, and then click OK.

Next, launch Mozilla Thunderbird. Select No when it asks whether you want to make Thunderbird your default email application. If this is the first time you've run it, it will prompt you to import your mail and settings.

If not, select Import from the Tools menu. Now you're ready to import your mail. When the Import dialog box appears, select Mail and click Next. Choose Outlook or Outlook Express and click Next. When it's done, click Finish. Your mail is now sitting in Thunderbird.

Transfer your Thunderbird mail to Ubuntu

If you transferred your mail from Outlook, it will be sitting in a Local Folder called Outlook Mail. You should have a few folders there, including Deleted Items, Drafts, Inbox, Outbox, and Sent Items. If you expected a whole bunch of mail to be imported from Outlook but found nothing, check to see whether you are using IMAP for your email (see the earlier note about transferring your IMAP account).

To grab the mail folders from Thunderbird, you'll need to locate your profile folder. First, shut down Thunderbird, and then open a Windows Command Prompt. Next, change to your Thunderbird directory with this command:

 cd %APPDATA%\\Thunderbird

( APPDATA is a Windows environment variable that points to the currently logged-in user's Application Data directory.) You'll find a Profiles directory in there, and in that directory, there should be a directory with a funny name, such as pr4qpneu.default. This is your Thunderbird profile directory. In this directory, look for the subdirectory Mail\\Local Folders, and then look for your mail folders, which may be in yet another subdirectory.

For example, this directory contains some empty folders (such as Drafts, Sent, and Trash):

C:\\... \\Local Folders> dir
 Volume in drive C has no label.
 Volume Serial Number is 864B-4AB0

 Directory of C:\\Documents and Settings\\bjepson\\Application
Data\\Thunderbird\\Profiles\\pr4qpneu.default\\Mail\\Local Folders

03/12/2006  04:24 PM    <DIR>          .
03/12/2006  04:24 PM    <DIR>          ..
10/04/2005  05:11 PM                 0 Drafts
03/12/2006  03:07 PM             1,445 Drafts.msf
10/04/2005  06:36 PM             1,236 Junk.msf
03/12/2006  04:24 PM                27 msgFilterRules.dat
03/12/2006  04:24 PM                 0 Outlook Mail
03/12/2006  05:17 PM             1,185 Outlook Mail.msf
03/12/2006  04:29 PM    <DIR>          Outlook Mail.sbd
10/04/2005  05:11 PM                 0 Sent
03/12/2006  03:07 PM             1,443 Sent.msf
10/04/2005  06:36 PM             1,320 Templates.msf
03/12/2006  04:24 PM                 0 Trash
03/12/2006  05:17 PM             1,448 Trash.msf
10/04/2005  05:11 PM                 0 Unsent Messages
03/12/2006  03:07 PM             1,797 Unsent Messages.msf
              13 File(s)          9,901 bytes
         3 Dir(s)  67,812,487,168 bytes free

But the imported Outlook folders are in the Outlook Mail.sbd subdirectory, including a 13 MB Inbox folder (these are the files you want to copy over to your Linux system):

C:\\... \\Local Folders> dir "Outlook Mail.sbd" 
 Volume in drive C has no label.
 Volume Serial Number is 864B-4AB0

 Directory of C:\\Documents and Settings\\bjepson\\Application
Folders\\Outlook Mail.sbd

03/12/2006  04:29 PM    <DIR>          .
03/12/2006  04:29 PM    <DIR>          ..
03/12/2006  04:24 PM                 0 Deleted Items
03/12/2006  04:24 PM             1,212 Deleted Items.msf
03/12/2006  04:24 PM                 0 Drafts
03/12/2006  04:24 PM             1,205 Drafts.msf
03/12/2006  04:24 PM        13,094,192 Inbox
03/12/2006  04:44 PM            79,534 Inbox.msf
03/12/2006  04:24 PM                 0 Outbox
03/12/2006  04:24 PM             1,205 Outbox.msf
03/12/2006  04:24 PM                 0 Sent Items
03/12/2006  04:24 PM             1,209 Sent Items.msf
              10 File(s)     13,178,557 bytes
               2 Dir(s)  67,812,483,072 bytes free

These folders use the Unix mbox format and can be imported into most Ubuntu email programs. For example, you can basically reverse the process to move the folder from Thunderbird on Windows to Thunderbird on Linux: find your Local Folders directory in your Ubuntu ~/.mozilla-thunderbird directory, make sure that Thunderbird is not running, and copy the files into that directory. When you restart Thunderbird, the folders you copied should appear in your list of Local Folders.

In Evolution, you can select File→Import to bring up the Evolution Import Assistant. When prompted to choose the Importer Type, select Import a Single File and then specify the mbox file when prompted to choose a file. If you have trouble importing files into Evolution, you can copy them manually: exit out of Evolution, and copy the files to ~/.evolution/mail/local.

If you have any problems, check the MozillaZine article on importing and exporting mail at http://kb.mozillazine.org/Importing_and_exporting_your_mail. However, considering how complicated it is to move mail from one system to another, you should consider using IMAP, which eliminates all these steps the next time you need to move from one machine to another; with IMAP, all your mail and folders are stored on the server. Contact your system administrator, Internet Service Provider, or mail provider to find out whether they support IMAP.

Are You Bringing the Browser?

You'll be happy to hear that exporting and importing your browser settings will be simple compared to migrating email. If you're using Internet Explorer, you'll first need to export your cookies and bookmarks and then copy them over to your Ubuntu system. To export them, start Internet Explorer, and select File→Import and Export. This starts the Import/Export Wizard. You'll have to run it twice: once for your cookies and once for your favorites (bookmarks).

If you're using Firefox on your old system, you can locate your profile folder and grab the bookmarks.html and cookies.txt files. To find your Firefox profile directory, open up a Windows Command Prompt and issue this command:

cd %APPDATA%\\Mozilla\\Firefox\\Profiles

As with Thunderbird, you'll find a strangely named directory, such as 9yk75acu.default. Your cookies and bookmarks will be sitting in this directory.

Once you've grabbed your cookies and bookmarks, you can use your browser's import function to bring them over to Ubuntu. For example, with Firefox, you can import bookmarks by selecting Bookmarks→Manage Bookmarks, and then selecting File→Import. To copy your cookies over, you'll first need to close Firefox, then paste the contents of the exported cookies into your existing cookies.txt file in your Firefox profile directory on your Ubuntu system, located in ~/.mozilla/firefox.


Cookies that you've exported from Internet Explorer are a bit more complex: you'll need to edit the cookies.txt file and put a period before every cookie that begins with a domain name. For more information, see http://kb.mozillazine.org/Import_cookies.

Your Stuff, Your Music

Unless you've decided to put your documents elsewhere, Windows makes moving them to Ubuntu quite easy. Windows uses the My Documents folder to organize your documents—including music, video, and others—and most applications respect this organization (for example, iTunes organizes its files under My Documents\\My Music\\iTunes). The actual location of the My Documents folder varies by Windows version. For example, on Windows XP, it is on the system drive (usually C:) in \\Documents and Settings<username>\\My Documents.

Although it's easy to copy over the files, some files, such as multimedia files, will probably not play on Ubuntu without a little extra effort. See Chapter 3 for more information.

Your Little Black Book

To move your appointments and contacts over, it's best if you can get your data into the vCalendar or iCalendar format (for calendars) and the VCard format (for contacts). If you can do this, it will be simple to import into an application such as Evolution or Thunderbird.

Outlook will let you export items one at a time, but this is too tedious for importing many contacts or calendar items. The free OutPod (http://outpod.stoer.de/) is designed to export Outlook items to an iPod, but to accomplish this, it uses the vCalendar and iCalendar formats to store the data. To use it, simply run OutPod.exe and navigate to your list of calendar items or contacts (Outlook will probably ask for your permission to let OutPod access its data). Click in the list of contacts or calendars and press Ctrl-A to select all. Then click OutPod's Outlook menu and choose "Save Selected Items in One File."

Copy the .vcf (VCard), .ics (iCalendar), or .vcs (VCalendar) file over to your Ubuntu system, and import it into Evolution or Thunderbird (addresses only). For Evolution, choose File→Import to bring up the Evolution Import Assistant, and choose to Import a Single File when prompted. Select the file you want to import (you may need to specify the file type), as shown in Figure 1-5, and then continue through the Import Assistant to import the data.

Importing an iCalendar file

Figure 1-5. Importing an iCalendar file

Another utility you may find useful for exporting calendars from Outlook is the free Outlook to iCal Export Utility (http://outlook2ical.sourceforge.net).


If you're using Thunderbird on Windows, you can export contacts using the LDAP Data Interchange Format (.ldif). On your Windows machine, launch Thunderbird, select Tools→Address Book to bring up your list of contacts, and then select Tools→Export to export all contacts. When the Save As dialog appears, choose LDIF. You'll be able to import LDIF into Thunderbird and Evolution.

Am I Forgetting Anything?

As a last check, open up your Windows Control Panel, go to Add/Remove Programs, and review the list of programs. Do you see any that store their data in a nonstandard location? For example, anything with a keychain, such as GNU Privacy Guard or the PuTTY SSH suite, might be keeping some keys you can't live without.

GNU Privacy Guard keeps its files in the gnupg subdirectory of the user's Application Data folder. APPDATA is an environment variable that expands to the user's Application Data directory, so issuing the command:


in a Windows Command Prompt will reveal gnupg's location. PuTTY keeps its keys wherever you decided to put them. If you've been using Pageant, select Add Key, and it should pop up with an Open File dialog set to the most recent directory you used.

If you're a Cygwin (http://www.cygwin.com) fan, don't forget that it keeps its home directories in a separate location (usually C:\\cygwin\\home). You may have all kinds of important documents and dotfiles kicking around there!

You Could Just Hire a Mover

There are a few third-party applications available to help move from Windows to Linux, but not all of them support Ubuntu. If you have a lot of machines to migrate, you might want to check out one of these:

Brian Jepson

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required