How to Fix “FAT-fs Dirty Bit” Warning and Data Corruption Issues After EFI Partition Migration


2 views

When working with EFI System partitions (typically FAT32 formatted), you might encounter this persistent warning even after running fsck:

kernel: FAT-fs (sda1): Volume was not properly unmounted. Some data may be corrupt.
0x25: Dirty bit is set. Fs was not properly unmounted and some data may be corrupt.

The dirty bit (0x25 in FAT metadata) indicates improper unmounting, but doesn't necessarily mean actual corruption. Here's why the warning persists after fsck:

The standard fsck.vfat approach has limitations:

  • It only clears the dirty flag without deeper filesystem validation
  • FAT32 metadata might still contain inconsistencies
  • EFI partitions have specific structural requirements

Try this sequence for complete resolution:

# Unmount first
umount /dev/sda1

# Full FAT32 check with auto-repair
fsck.vfat -a -v /dev/sda1

# For stubborn cases, force check even if clean
fsck.vfat -f -v /dev/sda1

# Verify bootability (for EFI specifically)
grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=GRUB

If warnings persist, consider these deeper checks:

# Dump FAT32 metadata for inspection
dd if=/dev/sda1 bs=512 count=1 | hexdump -C

# Check partition alignment
parted /dev/sda unit s print

# Verify filesystem parameters
mkfs.vfat -n "EFI" -F 32 /dev/sda1

Note: The last command will recreate the filesystem - only use if you have backups!

To avoid recurrence:

  • Always unmount EFI partitions before system shutdown
  • Consider adding to /etc/fstab with proper mount options:
    /dev/sda1 /boot/efi vfat umask=0077,errors=remount-ro 0 1
  • Regularly check partition health with cron jobs

When migrating EFI System partitions in Linux, you might encounter this stubborn warning even after running fsck:

kernel: FAT-fs (sda1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.

What's particularly frustrating is when the warning persists after you've:

  1. Properly unmounted the partition
  2. Run fsck with correct parameters
  3. Selected the "Remove dirty bit" option

The conventional wisdom suggests that:

# umount /dev/sda1
# fsck -V /dev/sda1

Should resolve the issue. However, in EFI partition cases, we need to consider:

  • The partition's special role in system boot
  • Potential UEFI firmware interactions
  • Filesystem journaling characteristics

Try this more thorough approach:

# umount /dev/sda1
# fsck.vfat -a -w -t /dev/sda1
# fsck.vfat -r -v /dev/sda1

Key differences from basic fsck:

-a : Auto-repair (more aggressive than interactive mode)
-w : Write changes immediately (avoids cache issues)
-t : Test bad clusters
-r : Interactive repair
-v : Verbose output

If the warning persists, consider these advanced steps:

# dd if=/dev/sda1 of=/tmp/efi_backup.img bs=4M
# mkfs.vfat -F 32 -n EFI /dev/sda1
# mount /dev/sda1 /boot/efi
# rsync -av /tmp/efi_backup.img/mnt/ /boot/efi/

Important notes about this nuclear option:

  • Always create a full backup first
  • Verify backup integrity before proceeding
  • Reinstall GRUB or systemd-boot afterwards

To avoid this situation:

# Create proper unmount script:
#!/bin/bash
sync
umount /boot/efi
hdparm -Y /dev/sda

Monitor your system logs regularly:

# tail -f /var/log/kern.log | grep FAT-fs