LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 01-02-2016, 08:46 AM   #16
michaelk
Moderator
 
Registered: Aug 2002
Posts: 14,931

Rep: Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520

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.

https://en.wikipedia.org/wiki/File_A...on_Table#FAT32

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...

Last edited by michaelk; 01-02-2016 at 11:24 AM.
 
Old 01-02-2016, 11:15 AM   #17
iFunction
Member
 
Registered: Nov 2015
Posts: 185

Original Poster
Rep: Reputation: Disabled
Thanks for all your replies,

@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.

Thanks for all your input
and happy new year

iFunc
 
Old 01-02-2016, 11:37 AM   #18
michaelk
Moderator
 
Registered: Aug 2002
Posts: 14,931

Rep: Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520
Have you tried the command:

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.
 
Old 01-02-2016, 01:27 PM   #19
iFunction
Member
 
Registered: Nov 2015
Posts: 185

Original Poster
Rep: Reputation: Disabled
Ok, so this is getting really frustrating.

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.

What is my mac doing that I am not please?
 
Old 01-02-2016, 01:34 PM   #20
TxLonghorn
Member
 
Registered: Feb 2004
Location: Austin Texas
Distribution: Mandrake 9.2
Posts: 569

Rep: Reputation: 183Reputation: 183
So what happened when you tried
Code:
sudo mkdosfs /dev/sdX -s 128 -F 32 -I
("sdX" being your flash drive - maybe sdc?)
 
1 members found this post helpful.
Old 01-02-2016, 01:35 PM   #21
iFunction
Member
 
Registered: Nov 2015
Posts: 185

Original Poster
Rep: Reputation: Disabled
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.
 
Old 01-02-2016, 01:42 PM   #22
iFunction
Member
 
Registered: Nov 2015
Posts: 185

Original Poster
Rep: Reputation: Disabled
TxLonghorn, when I tried that, it formatted the entire drive as one thing with no partition in it. maybe that's where I was going wrong...

Ok just tried it on
Code:
sudo mkdosfs /dev/sda1 -s 128 -F 32 -I
and it worked!! Brilliant thank you. Once I have worked out the script to do this with just a click, I will post that as my solution.
 
Old 01-02-2016, 04:23 PM   #23
iFunction
Member
 
Registered: Nov 2015
Posts: 185

Original Poster
Rep: Reputation: Disabled
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.
 
Old 01-02-2016, 04:30 PM   #24
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,601

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
Quote:
Originally Posted by iFunction View Post
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.
 
Old 01-02-2016, 08:54 PM   #25
iFunction
Member
 
Registered: Nov 2015
Posts: 185

Original Poster
Rep: Reputation: Disabled
HiThere,

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 08:59 PM. Reason: Clarification
 
Old 01-02-2016, 09:07 PM   #26
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,601

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
Quote:
Originally Posted by iFunction View Post
HiThere,

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).

Last edited by jpollard; 01-02-2016 at 09:10 PM.
 
1 members found this post helpful.
Old 01-02-2016, 09:37 PM   #27
kilgoretrout
Senior Member
 
Registered: Oct 2003
Posts: 2,474

Rep: Reputation: 189Reputation: 189
Quote:
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:

http://techcosupport.com/press/maxim...-32-partition/
 
Old 01-02-2016, 11:17 PM   #28
iFunction
Member
 
Registered: Nov 2015
Posts: 185

Original Poster
Rep: Reputation: Disabled
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:
Code:
(echo d; echo o; echo n; echo p; echo 1; echo ; echo ; echo w) | sudo fdisk /dev/sda
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] USB drive fat32 format will not mount snakeman34 Linux - Newbie 5 09-05-2011 08:51 PM
How to Format a NTFS (USB) Hard Drive to FAT32 (or Ext3)? tomihasa Linux - Newbie 4 06-14-2009 06:29 AM
Format FAT32 > 32Gb in Linux for share with XP akafitz Linux - Newbie 1 07-06-2006 06:42 PM
SCSI Drive No Longer Available After FAT32 Format lplates Linux - Hardware 18 10-31-2004 03:10 PM
How to format my linux drive back to fat32 Underworld135 Linux - Newbie 5 10-19-2001 10:42 AM


All times are GMT -5. The time now is 08:14 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration