5

Is it possible to install GRUB on fat32 partition during installation of Ubuntu 16.04?

When I try to do this during installation, then the following error is printed:

The file system type fat32 cannot be mounted on /boot, because it is not a fully-functional Unix file system. Please choose a different file system, such as ext2.

I need it for dual boot (with Windows together) and I want to edit the GRUB config from Windows to change the default OS on boot screen without any issues with file system drivers on Windows.

I sure it is a common task.

Also I often see GRUB on fat32 in some examples (bootable usb flash drive etc), so I think it is possible in principle to install GRUB on fat32.

9
  • I don't think you can install Ubuntu into a FAT32 file system, but as you write, it is possible to install grub into a FAT32 file system (the grub configuration and drivers). The bootloader itself goes to the head of the drive in BIOS and the EFI partition (which has a FAT32 file system) in UEFI mode. But I think you have to tell us more about what you are creating and when the error output is printed in order to give more detailed help.
    – sudodus
    Jul 20, 2017 at 15:24
  • 1
    I believe grub2 works with just about any file system. But you will have to manually maintain your grub.cfg file as then grub is not really part of the Ubuntu install and automatically updated with new kernel or other configuration changes. I primarily directly install grub2 only to directly boot ISO. BIOS and UEFI are somewhat different commands. You can just set Windows as default boot and before grub timeout press shift key to choose Ubuntu or any other grub entry.
    – oldfred
    Jul 20, 2017 at 15:50
  • grub does not need to be on a FAT32 partition in order to launch windows
    – ravery
    Jul 20, 2017 at 16:44
  • 1
    "I need it for dual boot (with Windows together)" No.
    – Rinzwind
    Jul 20, 2017 at 17:11
  • @Rinzwind OK, I need it not for dual boot. But still I need it for another reason. Jul 20, 2017 at 18:40

2 Answers 2

3

From what you said you want to do, reorder the default boot order, the best mechanism for that is to renumber/rename the files in /etc/grub.d to put the (Windows?) boot first (30_os-prober to 06_os-prober for instance). Then the update-grub will rewrite the grub.cfg the way you want it, and will keep that order for every update. Editing grub.cfg directly is not recommended because it is frequently rewritten by kernel updates.

Now you can install grub to a FAT filesystem, but not during the Ubuntu install. I did that once when I wiped out the Windows MBR on a disk and had no way to reinstall it, so I used grub for the bootloader, putting the boot directory on a small FAT tools or recovery Windows partition. Note, that I was not trying to dual boot with this setup, so I didn't need to worry about grub.cfg updates.


Don't confuse how the Ubuntu install limits grub to what grub can do if run manually. Install Ubuntu to your ext4, accept default grub install (MBR and grub files in /boot/grub). Run Ubuntu, and mount your FAT at /mnt (assuming your description of FAT at second partition):

sudo mount -tvfat /dev/sda2 /mnt 

Create a directory there named boot

sudo mkdir /mnt/boot 

Manually install grub to the FAT partition:

sudo grub-install --boot-directory=/mnt

Your grub install now runs off files on your FAT partition, and you can edit them from Windows. Watch out for any "garbage" like carriage returns Windows editors may put into your grub.cfg file (Ubuntu and most unixes just use the line-feed as the line terminator). Updates of kernels however will cause the new grub information to be put into /boot/grub/grub.cfg, so you will need to edit your FAT grub.cfg, or copy the new grub.cfg over to FAT and edit it again (or the new kernel will not show up in the boot menu).

0
2

Referring to ubfan1s solution, you can permanently mount your FAT partition on /boot, so your kernel and initrd updates go to the right place and you don't need to copy anything yourself.

Assuming your FAT partition is /dev/sda2, execute the following commands to

  • Move your linux and initrd images to a temporary dir
  • Append an entry for your FAT partition to /etc/fstab
  • Mount it and move the files from the temp dir to FAT
  • Update the GRUB files
  1. part=/dev/sda2
  2. sudo mkdir /boot_ && sudo mv /boot/* /boot_
  3. echo $(sudo blkid | grep $part | grep -Eo ' UUID="[[:alnum:]-]+"' | sed -E 's/[" ]//g') /boot auto nosuid,nodev,nofail 0 0 | sudo tee -a /etc/fstab
  4. sudo mount /boot && sudo mv /boot_/* /boot && sudo rm -r /boot_
  5. sudo grub-install ${part%[0-9]*} && sudo update-grub

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .