# Creating a FAT32 partition

## Tsuki

I've finally got fed up with having all my important files on an NTFS partition, I've decided to format it FAT32.  (ext3 is tempting, but I figure that if I do need to use Windows again, FAT32 is the best choice.)

Using fdisk in Linux, I removed the old partition and created a new one (and rebooted, as it asked).  The new partition is formatted as type "W95 FAT32 (LBA)".  Here's the full output from fdisk:

```
Disk /dev/hdc: 82.3 GB, 82348277760 bytes

255 heads, 63 sectors/track, 10011 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System

/dev/hdc1               1       10011    80413326    c  W95 FAT32 (LBA)
```

So far so good.  Now I'm trying to mount it - my fstab file contains the following line:

```
/dev/hdc1               /mnt/documents  vfat            defaults,uid=tsuki,gid=users      0  0
```

When I "mount /mnt/documents" I get the following error:

```
mount: wrong fs type, bad option, bad superblock on /dev/hdc1,

       or too many mounted file systems
```

...can anyone help a poor Linux newbie out here?  What am I doing wrong?  (There are only four mounted filesystems, I assume this isn't too many!)

P.S. Sorry if this is in the wrong forum!

----------

## Admiral LSD

Nothing, and I mean nothing, could ever tempt me to format my Windows drives as FAT32 again. Given a choice between data integrity and cross-OS compatibility I'll choose data integrity every time.

----------

## saccory

You have to create a filesystem on the partition: 

```
mkfs.vfat -F 32 /dev/hdc1
```

 This is comparable to the format command under DOS/Windows. Fdisk just divides your harddisk into partitions.

Warning: All data on /dev/hdc1 will be lost!

----------

## molander

 *saccory wrote:*   

> You have to create a filesystem on the partition: 
> 
> ```
> mkfs.vfat -F 32 /dev/hdc1
> ```
> ...

 

The "-F 32" is essential as otherwise it will use a 16bit fat size.  I am suprised 32bit (Actually 28bit I believe) is not the default nowadays. 

Who would actually be using a partition under 2 gig anyway?  :Wink: 

----------

## Tsuki

Ah, thanks!  I'd assumed that setting the type in fdisk would have done that - but thinking about it, I should have remembered having to use mke2fs and mkswap during the install ^_^;

----------

## Pythagoras1

the only expirences i made with fat/vfat were that sometimes windows couldn't read files written by linux. as a result i wasn't able to use the exchange partition between both os. even floppy disks and usb mass storages suffer this bug/feature.

the windows error was something like Could not open. File not found. when i tried to open a file.

Is this a known issue, since this happens on ALL gentoo boxes i tried it on?

----------

## yngwin

 *Pythagoras1 wrote:*   

> the only expirences i made with fat/vfat were that sometimes windows couldn't read files written by linux. ...
> 
> Is this a known issue, since this happens on ALL gentoo boxes i tried it on?

 

I've never had such a problem.

----------

## molander

 *yngwin wrote:*   

>  *Pythagoras1 wrote:*   the only expirences i made with fat/vfat were that sometimes windows couldn't read files written by linux. ...
> 
> Is this a known issue, since this happens on ALL gentoo boxes i tried it on? 
> 
> I've never had such a problem.

 

Me neither. I perform those types of functions all day long. It is possible that when the original partion was formatted the binary was broken that performed it. I dont use any filesystem tools other than what is available in linux but hat could be another culprit (Norton, Windows itself, defrogger, scandisk).

----------

## Cintra

Hei all

Problem I'm having is with fat32 filenames being shortened to 8-bits.. have hunted everywhere for the reason, which is no doubt obvious to someone.

Its making use of this shared 'win partition' a lot less valuable to me, and recently made a hash of a 35MB SUN java download...  :Sad: 

regards

----------

## molander

 *Cintra wrote:*   

> Hei all
> 
> Problem I'm having is with fat32 filenames being shortened to 8-bits.. have hunted everywhere for the reason, which is no doubt obvious to someone.
> 
> Its making use of this shared 'win partition' a lot less valuable to me, and recently made a hash of a 35MB SUN java download... 
> ...

 

Could you do an "fdisk -l /dev/hda" (or whatever the HD is) and post it? I am curious what partition id you are using. I used to have this problem about 6 years ago too.

----------

## Cintra

Hei molander

Thanks for answering.. here are all 3 disks, hdb as you see has the fat32 partition. 

btw, the same thing happens with an usb flashdisk in fat16 (?) format.

bash-2.05b# fdisk -l /dev/hdb

Disk /dev/hdb: 160.0 GB, 160041885696 bytes

255 heads, 63 sectors/track, 19457 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System

/dev/hdb1   *           1          73      586341   83  Linux

/dev/hdb2             801       19457   149862352+   f  W95 Ext'd (LBA)

/dev/hdb3              74         800     5839627+  83  Linux

/dev/hdb5             801         862      497983+  82  Linux swap

/dev/hdb6             863         866       32098+  83  Linux

/dev/hdb7             867         928      497983+  82  Linux swap

/dev/hdb8             929        1536     4883728+  83  Linux

/dev/hdb9            1537        2022     3903763+  83  Linux

/dev/hdb10           3104       14211    89224978+   b  W95 FAT32

/dev/hdb11          14212       19457    42138463+  bc  Unknown

Partition table entries are not in disk order

bash-2.05b# fdisk -l /dev/hda

Disk /dev/hda: 160.0 GB, 160041885696 bytes

16 heads, 63 sectors/track, 310101 cylinders

Units = cylinders of 1008 * 512 = 516096 bytes

   Device Boot      Start         End      Blocks   Id  System

/dev/hda1   *           1       94733    47745148+   7  HPFS/NTFS

/dev/hda2           94765      138526    22055859    5  Extended

/dev/hda3           94733       94765       16065   83  Linux

/dev/hda5           94765       96837     1044193+  82  Linux swap

/dev/hda6           96837      119149    11245468+  83  Linux

/dev/hda7          119151      138526     9765472+  83  Linux

Partition table entries are not in disk order

bash-2.05b# fdisk -l /dev/sda

Disk /dev/sda: 66 MB, 66224128 bytes

2 heads, 32 sectors/track, 2021 cylinders

Units = cylinders of 64 * 512 = 32768 bytes

   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1        2022       64672    4  FAT16 <32M

I have also checked XP files on dvd in udf/InCD format, and they have long filenames OK.

regards

ps. just mounted the ntfs disk and that shows long filenames ok

----------

## Sastraxi

Usually means it's loading the FAT16 and not the FAT32 driver (though I could be mistaken).

----------

## Toris

Yes, I had the same problem happen with me - either remove the DOS FAT support from your kernel, or mount the partition as 'vfat' instead of anything else, like 'auto'. As auto likes to mount it as DOS FAT instead of the more recent, long filename supporting, vfat.

----------

## Cintra

Thank you very much Sastraxi and Toris

vfat instead of auto did the trick  :Very Happy: 

regards

Edit: it did the trick with the harddisk but not the flashdisk  :Sad: 

----------

## Pythagoras1

it didn't make the trick at me. some files copied on vfat can't be read by windows (2000). the whole directory i copied on this drive didn't work. Windows said "The directory may be deleted or moved" but it's still there and Linux can access it complainless. i'll copy the floppy image on bugzilla as soon as possible.

----------

## Pythagoras1

https://bugs.gentoo.org/show_bug.cgi?id=54428

----------

## mlybarger

this is an interesting thread.

over the weekend, i've been installing/setting up gentoo on my laptop.  i shrunk the xp partition down, and created a fat32 shared drive using qtparted.  i put some mp3's using XP on the new partition before using it under gentoo.  i mounted the new partition (/dev/hda2) as vfat under gentoo.  good to go.  i  copied some photo albums to the partition.  i can see the files there under linux just fine.   i boot to xp, and they don't even show up at all. no errors, nothing.  all the files are under /mnt/hda2/albums (or under XP at E :Smile: .  even DIR /A under the XP cmd prompt doesn't show the folder there.  i've never really encountered this before.  i've used lots of USB Mass storage devices, copying files from linux to be later used ok by windows boxes (though mostly ME).  

i have a separate issue on this laptop with the USB Mass storage devices.  i haven't been able to  mount an of them. they're saying too many filesystems open, or it says /dev/stick is not a block device.  i'm using udev to handle the nice dev names for me. i stick the device in to the usb, and the /dev/stick shows up, but some reason it's not a block device.  odd.

btw, i'm using the gentoo-dev-sources from a 2004.1 networkless install, which ever version that is (2.6.4?)

[edit] after coming back to the machine later, it seems that Xp can see the files now that gentoo put onto the vfat shared partition.  strange.

----------

## Kevin72594

I don't seem to have the mkfs.vfat command.  Where would I go about getting it?   Thanks

EDIT: I just found it, it's in dosfstools.  I love how I find it right after I post after about a half hour of searching   :Embarassed:     thanks anyways

----------

## srs5694

 *Pythagoras1 wrote:*   

> the only expirences i made with fat/vfat were that sometimes windows couldn't read files written by linux.

 

I've experienced that in the past, but only with hard disk partitions that were created and written to first by Linux. If the partition is created in Windows and/or if Windows is the first to write files to the partition, I've had no such problems. I've also never had this problem with floppies. OTOH, I've not investigated this problem in depth, and my last experience with it was literally years ago.

On another matter, there seems to be some confusion in some posts in this thread about certain terminology. FAT varies in two orthogonal ways: FAT size (12-, 16-, or 32-bit, aka FAT-12, FAT-16, or FAT-32; note that in this context, "FAT" refers to a specific critical data structure in the FAT filesystem) and long filename (LFN) support (short, aka "8.3," filenames; VFAT long filenames; and UMSDOS long filenames). Linux's drivers auto-detect the FAT size; there's no such thing as separate FAT-32 vs. FAT-16 drivers. There is a mount option to force the driver to use a particular FAT size, though. Where the Linux does use separate drivers is in the long filename arena. The "msdos" filesystem type code implements 8.3 filenames, the "vfat" driver implements VFAT long filenames, and the "umsdos" driver implements UMSDOS long filenames. (UMSDOS is a somewhat rarely-used way to store Linux long filenames, file permissions, file ownership, and other features on a FAT filesystem). Note that these two issues (FAT size and LFN support) are entirely independent; you can have 12-bit FATs with VFAT (as in a floppy disk), 32-bit FATs without LFNs (rare, but do-able), or any other combination. Also, the LFN support is handled at mount time by the OS support. DOS can read a VFAT or UMSDOS disk just fine, but it'll only see 8.3 filenames. Linux or Windows can take a DOS floppy and mount it using LFN options, in which case existing filenames won't be changed but LFN files can be added to the disk.

----------

## Pythagoras1

well.... i created the file system with the windows 2000 management console and i'm shure that i wrote files on it with windows at first.

----------

## Pythagoras1

http://bugme.osdl.org/show_bug.cgi?id=2946

----------

## Corona688

 *Cintra wrote:*   

> Thank you very much Sastraxi and Toris
> 
> vfat instead of auto did the trick 
> 
> regards
> ...

  I had the same problem with my flashdisk.  The filesystem itself may be limited to short filenames, not just the linux filesystem driver.  I solved it by formatting my flash disk with 'mkfs.vfat' instead of 'mkfs.msdos', I didn't think there was a difference until the msdos one started butchering long filenames.

----------

## tscolari

Just ressurecting the topic. But i got a problem here...

Im reinstalling all my gentoo to my new HD and im going to make a fat32 partition to use in the both OS. 

But, i dont have that mkfs.vfat file...

i tryed this also:

mkfs -t vfat -F 32 /dev/hdb6

but returned a error saying that it could not find the mkfs.vfat file...

what should i do to have this file here?

----------

## codergeek42

 *tscolari wrote:*   

> Just ressurecting the topic. But i got a problem here...
> 
> Im reinstalling all my gentoo to my new HD and im going to make a fat32 partition to use in the both OS. 
> 
> But, i dont have that mkfs.vfat file...
> ...

 You need to emerge sys-fs/dosfstools.

----------

