create fat filesystem with linux

From thelinuxwiki
Jump to: navigation, search

1. for gentoo users, emerge the package dosfstools

2. figure out the device name for you disk

If it a usb drive, I run "ls /dev/sd*" before and after I pug it in and see what changed. Otherwise I run cfdisk against a disk to verify geometry to indentify the correct drive. Usually my drives are of different sizes, so that method works well.

3. Use fdisk to create the partition:

here I am going to create a 250GB partion on my empty 1TB drive

example

# fdisk /dev/sdf                                                                                             ~

Welcome to fdisk (util-linux 2.24). Changes will remain in memory only, until you decide to write them. Be careful before using the write command.
Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0x906eeaeb.
Command (m for help): p Disk /dev/sdf: 931.5 GiB, 1000204886016 bytes, 1953525168 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0x906eeaeb
Command (m for help): n
Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): p Partition number (1-4, default 1): First sector (2048-1953525167, default 2048): Last sector, +sectors or +size{K,M,G,T,P} (2048-1953525167, default 1953525167): +250G
Created a new partition 1 of type 'Linux' and of size 250 GiB. <bar>Command (m for help): t Selected partition 1 Hex code (type L to list all codes): b If you have created or modified any DOS 6.x partitions, please see the fdisk documentation for additional information. Changed type of partition 'Linux' to 'W95 FAT32'.
Command (m for help): w The partition table has been altered. Calling ioctl() to re-read partition table. Syncing disks.


2. Create / format the filesystem

# mkfs.vfat -F 32 /dev/sdf1