How to convert from WBFS to FAT32 or NTFS

This tutorial will show you how to convert a partition:
   - without losing your games
   - without copying somewhere else and back
   - without ripping them again
   - do in a few minutes (with good PC experience)
   - do it without much experience


1. Introduction

WBFS partitions have been around for a long time. They were the earliest way to run Backups from USB
and SD. But they have some drawbacks. For example you can not store homebrew programs, movies or any
other types of files on them. To do that you would need to partition the drive. But in that case you
have to know beforehand how much space you will need for which purpose. Another Problem with WBFS is
that windows permanently asks to format it. One incautious click by a friend and everything is gone.

This was overcome by the ability to use FAT and later even NTFS and EXT2,3,4. FAT support is
included in most Loaders nowadays and has no drawbacks compared to WBFS.

One of the problems of WBFS that persists is its lack of proper filesystem utilities. If you still
have a legacy WBFS drive it is hard to convert to something else and can't be grown or shrunk in
size.

This tutorial will try to make it as easy and fast as possible to convert to FAT32. There these
problems do not exist.

You could of course rerip all you discs or use a WBFS Manager to copy all games to another drive
and back again. But this will need a LOT of patience in the first case or free space on your PC and
still a lot of time in the second.

Instead we will convert the drive directly, without copying all of its data, yet still retaining
all games. This is also known as "in place" conversion, and common in other filesystems (see eg.
"Partition Magic") The fact that most data remains untouched makes this process ridiculously fast,
compared to other methods. I converted a full 50GiB drive in 4.2 seconds. Thats over 10GiB/s!

While this tutorial will convert WBFS to FAT32, other filesystems are available from there. Windows
for example can already do FAT to NTFS without losing data (search for "convert" in Windows Help
(F1))


2. Tutorial

I suggest you first read this tutorial completely, then ask any questions and only then go ahead and
do it.

2.1 The Requirements

First you will need some programs: The converter itself is called "wbfs2fat" and available here in
the GBAtemp forum: http://gbatemp.net/t291320-wbfs2fat-py It will run under Windows and Linux (and
possibly more).

For Windows there is a pre packaged wbfs2fat.exe with everything you need.

On Linux you are probably already good too. The only things needed are "python 2.x" and "sudo". Both
are installed by default in many distributions. To run the GUI you will need "pyqt4" too. If you
miss one of them, open you package manager and search for them. They will be in there. Ask around if
you don’t find them.

Alternative the the .exe you can run the .py file on Windows too. Both native Python and Cygwin:
http://www.cygwin.com/'s are supported. But I think that's only interesting if you want to dig into
the code. Additional requirements for doing this are listed in the "readme.txt".

While not strictly a requirement I strongly suggest you get wiimms wwt+wit:
http://gbatemp.net/t182236-wwt-wit-wiimms-wbfs-iso-tools. Its used for most of the optional parts of
this tutorial.

I suggest you now use "wwt" to check the drive for any filesystem errors (option "CHECK" and if
you have time "VERIFY" too). I prefer using it but other WBFS Managers might offer that too.
Additionally you might want to copy "that game the dog ate" on you PC just to be absolutely sure.


2.2 GUI

Simply run wbfs2fat without any parameters or with "--mode gui". The other parameters are supported
too (see CLI if you want)

You get a window which lists all detected partitions.

image: http://pix.gbatemp.net/190003/w2f.main.png

Depending on system setup you might need to do it as administrator/root. Access denied errors here
on are a sign of this. To do this e.g. right click the icon and select "run as administrator" or use
"sudo" on Linux.

If the partition you want to convert is missing you can type its path into the "device" line and
click "scan"

Select the one you want to convert by clicking on it and click the "convert to Fat32" button.

Now you can adjust some options. The defaults should do fine but feel free to change them.

image: http://pix.gbatemp.net/190003/w2f.options.png

Click OK when you are done.

Wait a few seconds for it to complete. It will report its progress and any anomalies as it goes.
Check its output carefully for any errors.

image: http://pix.gbatemp.net/190003/w2f.convert.png

Once you see "W2F: Conversion completed" its done. Click "Close".


2.3 CLI

Alternative to the graphical one there is a command line interface too.

Run "./wbfs2fat.py --mode scan" to get a list of all WBFS partitions. If you only get "permission
denied" try running it as administrator, or on Linux run "sudo ./wbfs2fat.py --mode scan" instead.
It will give you a line for each WBFS partition, consisting of a device identifier, its size and the
number of games on it. Find the device name for the partition you want. For example "/dev/sdc2". If
your partition is listed twice, once without number, and once with a "1", just use the one without.
That's a slight oddity in cygwin.

To convert the partition run "./wbfs2fat.py --mode convert <dev> " along with any other options
you want. <dev> is the device name for the WBFS partition in question. For example running
"./wbfs2fat.py --mode convert /dev/sdc1 -b /cygdrive/d/ " will convert the partition /dev/sdc1 and
use /cygdrive/d/ (which is D:\) for its backup file. To see what additional options are available
run "./wbfs2fat.py --help"

Wait a few seconds for it to complete. It will report its progress and any anomalies as it goes.
Check its output carefully for any errors.


2.4 Finishing Touches

Once it is run through the partition is FAT32 and can be accessed normally. Before you go ahead
I suggest running all checks you like against it NOW. That is because using the drive normally
can overwrite parts anywhere on the drive. Including parts not in the backup. That is just normal
operation and not a problem per se, but it will make the backup invalid. Some suggestions are
chkdsk, fsck.vfat, the windows filesystem check (in the rightclick menu of the drive letter),... You
can check the games too, for example using "wit"s "VERIFY" function.

I advise against letting these tools "repair" anything, instead it is better to restore the backup.
Excepted from this rule is the uninitialized free cluster summary. It is expected and can be fixed
without repercussions, it's not really an error in the first place.

The games will be stored as .wbfs files splitted by ~4GiB. They are inside a folder named wbfs in
the root of the drive and are named ID6.wbfs (e.g. "E:\wbfs\RSPDS.wbfs"). Well if you enable the
automatic renaming that is. If not you will have to do it manually. Create the folder, move them,
and rename *.0 to*.wbfs, *.1 to wbf1, *.2 to *.wbf2 and so on.

That's it, you are done. Close wbfs2fat/cygwin/the console and try it on your wii. Don't forget to
unmount/eject it normally.


3. The Backup

During execution a line will be printed saying "WARNING: start of dangerous part" This line only
means that the first write has occurred. Any crash, abort or whatever before that did not change the
drive AT ALL. While they cause no further harm they might indicate a larger problem. I suggest you
ask for advice (e.g. here on GBAtemp).

To recover from a crash during the dangerous part a backup is created. It contains everything
that was overwritten in the process (only some megabytes anyway). If wbfs2fat detects an error it
automatically tries to restore the backup.

Restoring the backup manually is possible too. But doing so might be danderous. It simply does not
contain whatever data your later deleting/creating/changing/etc of files did change. It is only
intended in case wbfs2fat fails, not for later. There is simply no way to foresee which games you
might delete manually. Restoring a backup later will cause massive data loss. Especially after
things that move data around like defrag. But when used before writing to the partition with other
tools it carries no risk.

The backup function is the most tested part of the program. That's because it allows rapid resets
too. Copying its 6MiB back is A LOT faster than creating and filling a new 50GiB WBFS partition for
each test.

To restore the backup simply use the "restore Backup" button in the GUI or the "-m restore
--restore=BACKUP" CLI option. By default the backups are located in the folder from where you ran
wbfs2fat and named "wbfs.DEVICE.TIMESTAMP.back".

The backup is a complete image of the first N blocks of the drive, where N is whatever was needed
to contain the FAT metadata. Thus it can be restored easily using the image tool of your choice
too. For example using "dd if=<backup_file> of=<device>" (dd is available in cygwin and most Linux
Distributions by default)


4. Space

The conversion requires some free space (it's checked automatically). It will need approximatively
0.02% (2MiB per 10GiB) of the partition size plus one WBFS Block per game. Once the partition is
converted you can gain space back by scrubbing the games again (should net a gain on big partitions)
My suggestion is to use e.g. "wit CONVERT -Bz E:\wbfs\" but maybe other manager can do that to. You
can of course skip or postpone this step. In fact I suggest waiting, because it of course writes
data (see "The Backup).


5. Where to go from here

Now that your drive is FAT32 you can manipulate it by a variety of tools. These Tools include
Partition Magic, Parted Magic, "convert" and others. Using the internet you should find everything
you need.

Functions seen in better partitioning tools include:
   - resizing of partitions without losing data
   - joining/merging of two partitions into one that contains the files and space of both
   - splitting of one partition into two while dividing the files and space between them as you like
   - changing the filesystem again (e.g. NTFS) without losing data.

If you only want to go on to NTFS, Windows has everything you need. It can already change a
partition from FAT to NTFS without losing data. The tool is named "convert" and runs from the
Windows Command console("cmd"). Search Windows Help (F1) for a detailed explanation of "convert".


6. Misc

You can test wbfs2fat on filesystem images first. Simply enter its filename instead of a device
name. No idea how to test/mount the resulting Fat32 image under Windows. Under Linux use "mount -o
loop IMAGE SOMEDIR"

I hereby grant licence to host this howto to everyone, given that he
   - includes a notice of the original authorship
   - marks any changes as such
   - includes a link to the original source (the 3. one below) to allow users to receive updates
   - includes a link to wbfs2fat (eg. the 2. one below (because of updates too))   
   - only includes download links to wbfs2fat which are compliant with its licence

If you have a reason to want different terms simply ask, my mind is not set in stone.

Please post comments to wbfs2fat itself (as opposed to this guide) in the discussion thread.


7. Links

Homepage/Discussion Thread: http://gbatemp.net/t291320-wbfs2fat-py
Detailed Tutorial/Howto: http://gbatemp.net/t292391-how-to-convert-from-wbfs-to-fat32-or-ntfs
GUI demo video: http://www.youtube.com/watch?v=2YqSNQnnvcI
