[SOLVED] format 64Gb usb drive to Fat32 only gives 32Gb?
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
The actual maximum volume size for a FAT32 file system is 2TB. Microsoft imposed a 32GB limit starting with XP and you can download several windows applications that can format FAT32>32GB.
fdisk creates partitions but does not create file systems. Once you overwrite the existing master boot recorder with the initial mkfs command you need to create a new partition table. Then create a file system based on the above command using /dev/sdx1. gparted should work...
@suicidaleggroll thanks for your help and for the idea of using a usb extension, I will use that now anyway.
As for the situation, I had actually formatted the usb stick correctly but had not understand what I was reading. I was using the "get info" in File Manager which behaves slightly differently than it does in windows or OSX, so the 32K was the amount of space being used, I still haven't worked out getting that sort of info out of the command line. Never the less, on my mac it was now showing more understandable results, i.e. is was showing about:
32K (Kilobytes) of used space and
64Gb of free space
Before it was showing:
32Gb (Gigabytes) of used space and
64Gb of free space
What I was hoping to achieve was to write a small script that would do exactly this same formatting at just the double click of a button, but I am finding translating from a graphical interface tricky, that was why I was hoping to find the command line solution only. There are no variables involved, all 200 USB sticks are exactly the same for the exactly the same purpose, but we need to be able to reformat them easily due to the nature of the system we are using them for. So the idea was to write a script that would (on inserting the usb):
mount usb.
wipe and format usb to fat32 complete with event name,
eject usb drive,
display process completed message.
The bash side of things I can work my way round, however it is the part required in gparted that I can work out, this was why I was hoping that it could be done command line only.
mkfs.vfat -F32 /dev/sdx1 (replace x with the actual drive letter)
The -I from the previous command creates a superfloppy which is not required. The -n option creates a volume label. If these drives are going to be used on a windows PC then you should change the partition ID type from 07 to c.
I use fdisk to format drive to msdos, add partition and all seems fine.
In command line I then use
Code:
mkfs.vfat -n 'round01' -I /dev/sda1
And everything seems ok on the raspberry pi, as soon as I then put the stick in my mac, it says it's unreadable. Format it on the mac and it works fine on all systems.
By the way, in fdisk, I do the following:
p - to see what's there
d - to delete partition
o - to create new empty DOS partition table
n - to add new partition and use all defaults
t - to change partition type
b - for W95 FAT32
then
Code:
mkfs.vfat -n 'round01'
I did not use the -I sorry forgot to modify before posting.
I don't understand what is going on here, this worked on 3 usb sticks in a row, now I am back to the same problem again where it's there for linux but not for the mac?
Why is this not consistent? All the usb sticks have come fresh from a factory.
I don't understand what is going on here, this worked on 3 usb sticks in a row, now I am back to the same problem again where it's there for linux but not for the mac?
Why is this not consistent? All the usb sticks have come fresh from a factory.
Making the expanded allocations is not supported on all systems. The 32GB limit was imposed by Microsoft as the supported maximum.
Larger devices usually come with NTFS instead, or are partitioned into unit sizes less than or equal to 32GB.
Solved it. It seems that fdisk is required to do this whether the partition table is dos or not. I wrote this script and it works without any problems as such. In the meantime, here is the script to do just one specifict task: Use a Raspberry pi to format a 64Gb usb drive to FAT32 and name it "IFUNCTION".
Please bear in mind some of this is a dirty fix as there are some elements I still don't understand e.g. every raspberry pi I have used so far will put a usb drive to "/dev/sda" I am making the assumption that this is default if there are no other usb drives attached, if it defaults to a different place this script simply will not work. As a result I have chosen to reboot the raspberry pi once the process is complete in an attempt to flush the system and also the rpi won't mount an inserted usb drive at boot up (if inserted once booted it does mount automatically) which give a nice clean disconnect. Here is my script, I hope it helps someone somewhere:
Code:
#/bin/bash
sudo umount /dev/sda1
# If the drive is mounted while using fdisk, an error message is generated warning that a
# reboot is required before it can continue, making sure the drive is not mounted solves this
# however it will flag up a message if it is already not mounted, this is not a problem.
echo -e "o\nn\np\n1\n\n\nt\nb\nw" | sudo fdisk /dev/sda
# This command feeds the following commands to fdisk
# the -e option enables the use of escape characters
# NOTE '\n' is the new line escape code which separates
# the different parameters fed into fdisk the letter after
# is the parameter, no letter means we are using the default.
# o - sets up new empty dos partition table
# n - creates a new partition
# p - accepts default partition type , Primary
# 1 - accepts default partition, partition 1
# - accepts default start
# - accepts default end
# t - changes the partition format from default format 'linux' just created
# b - is the code for 'W95 FAT32' format 'l' will list them all in fdisk
# w - NOTE: this saves and exits, 'q' will exit without the format happening.
sudo mkdosfs -n 'IFUNCTION' /dev/sda1 -s 128 -F 32 -I
# This line formats the partition to FAT32 and names it.
reboot
Please do let me know of any errors or a more efficient way.
Kind regards
iFunk
Last edited by iFunction; 01-02-2016 at 07:59 PM.
Reason: Clarification
Solved it. It seems that fdisk is required to do this whether the partition table is dos or not. I wrote this script and it works without any problems as such. In the meantime, here is the script to do just one specifict task: Use a Raspberry pi to format a 64Gb usb drive to FAT32 and name it "IFUNCTION".
The only assumption the script is making is assuming the thing has a partition table... and that the first one is the 32G one. Many memory sticks do have a partition table... but partition 1 contains some Windows applications... and partition 2 is the rest of the device. My Kingston supplied devices had a small partition (fat16 I think it was) that had some stupid applications on it - including and autorun script until I repartitioned it.
Quote:
Please bear in mind some of this is a dirty fix as there are some elements I still don't understand e.g. every raspberry pi I have used so far will put a usb drive to "/dev/sda"
It is given "sda" if and only if it is the first (or only) device plugged into a USB. The USB controller is treated as a SCSI controller (hence the "sd" part). If two devices are plugged in at the same time, the first one gets sda, the second would get sdb. The ScanDisk is not a SCSI device... hence it gets the mmcblk name).
Depending on the OS version used, the system doesn't mount USB until well after the root device (which is the ONLY disk like device driver built into the kernel) gets mounted, and udev is started. And that is after the fstab is scanned for mountable devices. I'm not sure yet on debian jessie (which is the next version of Raspbian) as it is systemd based, and it does do network mounts (so it might do USB mounts if the device is plugged in - or hang if it isn't).
Fat32 does not support any filesystem larger than 32GB
That is not correct. Any windows operating system will not create a FAT32 partition greater than 32GB during the installation process. That was a design decision by Microsoft to force the adoption of NTFS. However, the theoretcial maximum partition size for FAT32 is measured in terabytes not gigabytes:
Also to add to kilgoretrouts post, I have just formatted 40 usb sticks to FAT32 and they all work like a charm.
UPDATE to my solution:
I did eventually start getting some problems, as using "\n" is quite a revolting way to program, so I have gone for an echo on each line instead and that solved the problem. I also found that deleting the partition first helped, fdisk line now reads:
To clarify: This script is used on a raspberry pi that is only there to provide images on a computer screen so there will only ever be a wireless keyboard dongle attached, so usb drive does always default to /dev/sda. As I said before this is a bit of a dirty fix, but as I know the environment it will be used in, and I will be there to baby sit any errors, it's not a problem.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.