Salut \o
Hummm … regardes les sources de grub.
On retrouves cette fonction :
static struct grub_fat_data *
grub_fat_mount (grub_disk_t disk)
{
struct grub_fat_bpb bpb;
struct grub_fat_data *data = 0;
grub_uint32_t first_fat, magic;
if (! disk)
goto fail;
data = (struct grub_fat_data *) grub_malloc (sizeof (*data));
if (! data)
goto fail;
if (grub_disk_read (disk, 0, 0, sizeof (bpb), &bpb))
goto fail;
if (grub_strncmp((const char *) bpb.version_specific.fat12_or_fat16.fstype, "FAT12", 5)
&& grub_strncmp((const char *) bpb.version_specific.fat12_or_fat16.fstype, "FAT16", 5)
&& grub_strncmp((const char *) bpb.version_specific.fat32.fstype, "FAT32", 5))
goto fail;
data->logical_sector_bits =
fat_log2 (grub_le_to_cpu16 (bpb.bytes_per_sector));
if (data->logical_sector_bits < GRUB_DISK_SECTOR_BITS)
goto fail;
data->logical_sector_bits -= GRUB_DISK_SECTOR_BITS;
data->cluster_bits = fat_log2 (bpb.sectors_per_cluster);
if (data->cluster_bits < 0)
goto fail;
data->cluster_bits += data->logical_sector_bits;
data->fat_sector = (grub_le_to_cpu16 (bpb.num_reserved_sectors)
<< data->logical_sector_bits);
if (data->fat_sector == 0)
goto fail;
data->sectors_per_fat = ((bpb.sectors_per_fat_16
? grub_le_to_cpu16 (bpb.sectors_per_fat_16)
: grub_le_to_cpu32 (bpb.version_specific.fat32.sectors_per_fat_32))
<< data->logical_sector_bits);
if (data->sectors_per_fat == 0)
goto fail;
data->num_sectors = ((bpb.num_total_sectors_16
? grub_le_to_cpu16 (bpb.num_total_sectors_16)
: grub_le_to_cpu32 (bpb.num_total_sectors_32))
<< data->logical_sector_bits);
if (data->num_sectors == 0)
goto fail;
if (bpb.num_fats == 0)
goto fail;
data->root_sector = data->fat_sector + bpb.num_fats * data->sectors_per_fat;
data->num_root_sectors
= ((((grub_uint32_t) grub_le_to_cpu16 (bpb.num_root_entries)
* GRUB_FAT_DIR_ENTRY_SIZE
+ grub_le_to_cpu16 (bpb.bytes_per_sector) - 1)
>> (data->logical_sector_bits + GRUB_DISK_SECTOR_BITS))
<< (data->logical_sector_bits));
data->cluster_sector = data->root_sector + data->num_root_sectors;
data->num_clusters = (((data->num_sectors - data->cluster_sector)
>> (data->cluster_bits + data->logical_sector_bits))
+ 2);
if (data->num_clusters <= 2)
goto fail;
if (! bpb.sectors_per_fat_16)
{
grub_uint16_t flags = grub_le_to_cpu16 (bpb.version_specific.fat32.extended_flags);
data->root_cluster = grub_le_to_cpu32 (bpb.version_specific.fat32.root_cluster);
data->fat_size = 32;
data->cluster_eof_mark = 0x0ffffff8;
if (flags & 0x80)
{
unsigned active_fat = flags & 0xf;
if (active_fat > bpb.num_fats)
goto fail;
data->fat_sector += active_fat * data->sectors_per_fat;
}
if (bpb.num_root_entries != 0 || bpb.version_specific.fat32.fs_version != 0)
goto fail;
}
else
{
data->root_cluster = ~0U;
if (data->num_clusters <= 4085 + 2)
{
data->fat_size = 12;
data->cluster_eof_mark = 0x0ff8;
}
else
{
data->fat_size = 16;
data->cluster_eof_mark = 0xfff8;
}
}
if (data->num_sectors <= data->fat_sector)
goto fail;
if (grub_disk_read (disk,
data->fat_sector,
0,
sizeof (first_fat),
&first_fat))
goto fail;
first_fat = grub_le_to_cpu32 (first_fat);
if (data->fat_size == 32)
{
first_fat &= 0x0fffffff;
magic = 0x0fffff00;
}
else if (data->fat_size == 16)
{
first_fat &= 0x0000ffff;
magic = 0xff00;
}
else
{
first_fat &= 0x00000fff;
magic = 0x0f00;
}
if (bpb.sectors_per_fat_16)
data->uuid = grub_le_to_cpu32 (bpb.version_specific.fat12_or_fat16.num_serial);
else
data->uuid = grub_le_to_cpu32 (bpb.version_specific.fat32.num_serial);
if ((first_fat | 0x8) != (magic | bpb.media | 0x8))
goto fail;
data->file_cluster = data->root_cluster;
data->cur_cluster_num = ~0U;
data->attr = GRUB_FAT_ATTR_DIRECTORY;
return data;
fail:
grub_free (data);
grub_error (GRUB_ERR_BAD_FS, "not a FAT filesystem");
return 0;
}
Bon du coup, on se rend compte que c’est une erreur assez générique qui désigne qu’il y a eu un problème dans cette fonction.
En gros, le BPB donne des informations que grub ne trouve pas cohérente (où alors il y a un problème d’allocation…). Ça peut venir du BIOS (stupid BIOSes ! 🤣) ou du support en lui même qui est mal « configuré ».
Vérifie que tu n’as pas une clé branchée à ton PC. Sachant que parfois, d’autres périphériques USB se permettent de faire également clé USB (pour stocker leur configuration par exemple), c’est le cas de certaine clé 4G.
Si tu es sous Fédora, tu peux lancer ces commandes et nous donner le résultat.
$ lsblk -f
$ fdisk -l
# parted -l
Les trois servent un peu à la même chose. lsblk
va lister. Ben les block devices.
fdisk
et parted
vont lister les partitions. C’est bien d’avoir deux avis différents