mkfs.vfat exits zero on fatal warning

Bug #1569576 reported by Ryan Harper
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
dosfstools (Ubuntu)
New
Undecided
Unassigned

Bug Description

1. $ lsb_release -rd
Description: Ubuntu Xenial Xerus (development branch)
Release: 16.04

2. $ apt-cache policy dosfstools
dosfstools:
  Installed: 3.0.28-2
  Candidate: 3.0.28-2
  Version table:
 *** 3.0.28-2 500
        500 http://archive.ubuntu.com/ubuntu xenial/main amd64 Packages
        100 /var/lib/dpkg/status

3. mkfs.vfat should exit with non-zero value if it cannot create enough clusters on the target device. This is fatal to compliant FAT filesystem parsers since cluster count is the *only* way to determine the FAT type (12, 16, 32).

$ sudo mkfs.vfat -S 4096 -F 32 /dev/vda1; echo ?
sudo: unable to resolve host ubuntu
mkfs.fat 3.0.28 (2015-05-16)
WARNING: Not enough clusters for a 32 bit FAT!
1

4. $ sudo mkfs.vfat -S 4096 -F 32 /dev/vda1; echo $?
sudo: unable to resolve host ubuntu
mkfs.fat 3.0.28 (2015-05-16)
WARNING: Not enough clusters for a 32 bit FAT!
0

Tools calling mkfs.vfat expect the tool to return non-zero values when it encounters and error.
Making a FAT32 filesystem on a device that is not big enough means that FAT parsers will fail to
recognize the device. In particular, UEFI expects a FAT32 partition and will fail to read the boot partition
if it's not formatted properly (ie, not big enough for 65526 clusters[A]).

mkfs.vfat defaults to 8 sectors per cluster, for 4k disks, we set sector size to 4k, which means
for -F 32, we have 65526 clusters * 8 * 4096 wihich is just under 2G, meaning to avoid the warning/error
-F 32 requires either a lower sectors per cluster, or a larger target device.

A. https://staff.washington.edu/dittrich/misc/fatgen103.pdf [Page 15]

ProblemType: Bug
DistroRelease: Ubuntu 16.04
Package: dosfstools 3.0.28-2
ProcVersionSignature: User Name 4.4.0-18.34-generic 4.4.6
Uname: Linux 4.4.0-18-generic x86_64
ApportVersion: 2.20.1-0ubuntu1
Architecture: amd64
Date: Tue Apr 12 20:10:06 2016
Dependencies:
 gcc-6-base 6-20160405-0ubuntu2
 libc6 2.23-0ubuntu2
 libgcc1 1:6-20160405-0ubuntu2
ProcEnviron:
 TERM=xterm
 PATH=(custom, no user)
 XDG_RUNTIME_DIR=<set>
 LANG=en_US.UTF-8
 SHELL=/bin/bash
SourcePackage: dosfstools
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Ryan Harper (raharper) wrote :
Ryan Harper (raharper)
description: updated
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.