Installing Linux on FAT32


FAT is a very simple filesystem. Earlier versions didn't even support filenames longer than 8.3, let alone any permissions (you can't do this on Windows to this day!) or links. However, people have wanted to install Linux next to the existing Windows installation without reformatting for years.
Two approaches exist: making an ext image on an existing partition or storing the installation on FAT partition. You may know the first one from Wubi, program made by Canonical to create an Ubuntu image. The second one, however, disappeared completely with Linux kernel 2.6 since most people were already using Windows XP with NTFS partitions. It's called UMSDOS.
UMSDOS was created without Microsoft's LFN in mind, so it handles longer filenames differently than Windows. That's why UVFAT = UMSDOS + VFAT was created. Of course, it doesn't mean you can just pick any Linux distribution from kernel 2.4 era, choose UVFAT and be fine, that would be too easy - UVFAT isn't even selectable during compiling a vanilla kernel.


I use it on my Pentium III laptop with already pretty unusual hard disk configuration: out of 40 GB, 4 GiB is used as bootable FAT32 partition with BOTH Windows 98 and Windows 2000 installed on it and the rest is an another FAT32 partition for games and stuff. If I just made ext3 partition for Linux, it wouldn't be as unique and using LOADLIN would be pointless. If I made a system image, it'd always take more space than necessary.


We'll need:

Since using uvfatsync on installed system is required, first it must be installed as an image. During Mandrake 9.2 installation, choose Custom disk partitioning, Switch to advanced mode and create a file partition on a partiton different than the destination one, otherwise, you won't be able to mount that partition as uvfat. During package selection, in Programming, choose patch, gcc and libncurses5-devel. At the end, make a liLO boot floppy if you want to use LOADLIN.
After installation is complete, it's time to patch and compile a kernel. Patch it, using command:

$ patch -p1 < uvfat_emd_fatde_cache7-2.4.19_2002-08-28.diff

(assuming uvfat_emd_fatde_cache7-2.4.19_2002-08-28.diff is in folder with kernel source, in Mandrake it's in /usr/src/linux and in Debian it needs to be extracted from /usr/src/kernel-source-2.4.19.tar.bz2)
This command should pass without any problems, if it fails at anything, you have wrong kernel downloaded. After that, it's time to config kernel using:

$ make menuconfig

In File systems, select UVFAT support. I also recommend selecting DEVFS and mounting it at boot, it'll save a lot of space on a destination partition. You can play with other options in this config, but be prepared for recompiling a bunch of times. Once it's finished, save and run:

$ make dep
$ make bzImage
$ make modules
# make modules_install
# make install

…and with that, a new kernel will be available to use after reboot. You can choose to create initrd using:

# mkinitrd /boot/initrd-$(kernel).img $(kernel)

replacing $(kernel) with your kernel version (2.4.22-41mdkcustom if you use kernel from Mandrake, 2.4.19 if from Debian, 2.4.24 if vanilla). It's optional and changes UVFAT behaviour:

You can switch between these two by simply moving files, folders and --LINUX5.--- while in Windows/DOS. Reboot your machine and, unless you messed up config badly, you'll get your new kernel running. In order to move system to UVFAT partition, edit /etc/fstab and in line with destination partition change vfat to umsdos, for example:

/dev/hda2	/mnt/win_d	umsdos	defaults	0	0

where /dev/hda2 is your root partiton. Remount it:

# mount -o remount -t umsdos /dev/hda2

Now, compile umsdos_progs. To do that, extract the archive, in include/ums_config.h set BE_UVFAT to 1 and then type:

$ make
# make install

Use the just-compiled program:

# uvfatsync /path/to/partition/where/you/want/system

If you don't want to use initrd, add /linux at the end (folder must exist before that). With that, Linux can be moved using:

$ cd /path/to/partition/where/you/want/system
# cp -a /bin /boot /etc /home /lib /opt /root /sbin /usr /var .
# mkdir dev
# chmod --reference=/dev dev
# mkdir proc
# chmod --reference=/proc proc

Again, without initrd, the first line is longer by "/linux". Making dev and proc is crucial, otherwise system won't boot. In the target system, edit etc/fstab. Without initrd like this:

/dev/hda2	/	umsdos	defaults	0	0

And with initrd like this:

none	/		umsdos	defaults	0	0
none	/DOS	umsdos	defaults	0	0

With that, your system is ready. Reboot and boot using kernel from FAT32 partition. Example for LOADLIN:

LOADLIN D:\linux\boot\vmlinuz root=/dev/hda2

You can add vga parameter to specify initial screen resolution (vga=791 is 1024x768x16, for example) or initrd=D:\boot\initrd-$(kernel).img.
If everything was done correctly, system boots successfully. That means the system image installed at the beginning can be safely removed.

Valid HTML 4.01 StrictValid CSS!