LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices



Reply
 
Search this Thread
Old 10-08-2005, 10:28 AM   #1
guldo
Member
 
Registered: Aug 2003
Location: Morio Cho
Distribution: debian sid
Posts: 124

Rep: Reputation: 15
Formatting a usb drive


Hello.
I have a usb key I'd like to use.
So far it's been used on Windows (not by me), but it no longer works...
(don't know the details)

What I've tried is to erase all partitions and create a new one.
Unfortunately:
(parted) mkpartfs primary vfat 0% 100%
Error: Unable to open /dev/sda - unrecognised disk label.


What can I do to fix it?

Thanks
 
Old 10-08-2005, 02:14 PM   #2
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 328Reputation: 328Reputation: 328Reputation: 328
Many of these USB keys that I've seen aren't partitioned - they are like floppy disks. You can format the entire units as unpartitioned mountable space with:

mkdosfs -F 32 /dev/sda

If you want to partition the space, you can try wiping the device partition table with:

dd if=/dev/zero of=/dev/sda bs=512 count=10

You can also try another partitioning tool, like fdisk.
 
Old 10-08-2005, 02:23 PM   #3
guldo
Member
 
Registered: Aug 2003
Location: Morio Cho
Distribution: debian sid
Posts: 124

Original Poster
Rep: Reputation: 15
Thanks.
I've tried both, but each time:
# mount /mnt/usbkey/
mount: /dev/sda1 is not a valid block device

What should I check next?
 
Old 10-08-2005, 02:34 PM   #4
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 328Reputation: 328Reputation: 328Reputation: 328
If you format the entire drive unpartitioned, then you want to mount /dev/sda, not /dev/sda1 (there is no partition "1").
 
Old 10-08-2005, 03:36 PM   #5
guldo
Member
 
Registered: Aug 2003
Location: Morio Cho
Distribution: debian sid
Posts: 124

Original Poster
Rep: Reputation: 15
Thanks for the reply.

# mount -t vfat /dev/sda /mnt/usbkey/
mount: /dev/sda is not a block device (maybe try `-o loop'?)
# mount -t vfat -o loop /dev/sda /mnt/usbkey/
mount: wrong fs type, bad option, bad superblock on /dev/loop0,
missing codepage or other error
In some cases useful info is found in syslog - try
dmesg | tail or so

# dmesg
...
FAT: bogus number of reserved sectors
VFS: Can't find a valid FAT filesystem on dev loop0.



Last edited by guldo; 10-08-2005 at 03:38 PM.
 
Old 10-08-2005, 04:00 PM   #6
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 328Reputation: 328Reputation: 328Reputation: 328
It's not a loopback device (a filesystem in a file), so you do not want to use the loop option.

What is the sequence of commands you issued to the device? If you wiped out the partition table with dd, then this is what I would expect.

Format, then mount:

mkdosfs -F 32 /dev/sda
mount -t vfat /dev/sda /mnt/usbkey/
 
Old 10-08-2005, 05:38 PM   #7
guldo
Member
 
Registered: Aug 2003
Location: Morio Cho
Distribution: debian sid
Posts: 124

Original Poster
Rep: Reputation: 15
(23:36:51)debian:~$ dd if=/dev/zero of=/dev/sda bs=512 count=10
10+0 records in
10+0 records out
5120 bytes transferred in 0.000736 seconds (6956872 bytes/sec)
(23:36:58)debian:~$ mkdosfs -F 32 /dev/sda
mkdosfs 2.11 (12 Mar 2005)
mkdosfs: Too few blocks for viable file system
(23:37:11)debian:~$ mount -t vfat /dev/sda /mnt/usbkey/
mount: /dev/sda is not a block device (maybe try `-o loop'?)

I'm puzzled...
 
Old 10-08-2005, 05:50 PM   #8
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 328Reputation: 328Reputation: 328Reputation: 328
Quote:
Originally posted by guldo

(23:36:58)debian:~$ mkdosfs -F 32 /dev/sda
mkdosfs 2.11 (12 Mar 2005)
mkdosfs: Too few blocks for viable file system
(23:37:11)debian:~$ mount -t vfat /dev/sda /mnt/usbkey/
mount: /dev/sda is not a block device (maybe try `-o loop'?)

I'm puzzled...
The format failed, so there is no use trying to mount. The device may be too small to support vfat, so you can try fat by just removing the "-F 32" option:

mkdosfs /dev/sda
 
Old 10-08-2005, 07:10 PM   #9
guldo
Member
 
Registered: Aug 2003
Location: Morio Cho
Distribution: debian sid
Posts: 124

Original Poster
Rep: Reputation: 15
Thanks for the hint
Unfortunately:
(01:08:29)debian:guldo# mkdosfs /dev/sda
mkdosfs 2.11 (12 Mar 2005)
mkdosfs: Attempting to create a too large file system
(01:08:35)debian:guldo# mkdosfs -F 12 /dev/sda
mkdosfs 2.11 (12 Mar 2005)
mkdosfs: Attempting to create a too large file system
 
Old 10-08-2005, 10:00 PM   #10
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 328Reputation: 328Reputation: 328Reputation: 328
Then your device is broken - it's not indicating a valid size. You can try overriding the default detection by specifying the block count:

mkdosfs -F 32 /dev/sda <count>

where count is:

MB * 2048

For example, a 256MB unit would have a block count of:

256 * 2048 = 524288
 
Old 10-09-2005, 06:32 AM   #11
guldo
Member
 
Registered: Aug 2003
Location: Morio Cho
Distribution: debian sid
Posts: 124

Original Poster
Rep: Reputation: 15
Thank you.
What does the following mean?
(12:30:47)debian:~# mkdosfs -F 32 /dev/sda 524288
mkdosfs 2.11 (12 Mar 2005)
Warning: block count mismatch: found 5 but assuming 524288.
 
Old 10-09-2005, 12:16 PM   #12
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 328Reputation: 328Reputation: 328Reputation: 328
It means that your device reported that it has a capacity of 5 blocks (which is 2.5K) while you specified that it actually contains 524288 blocks (256MB). The device was formatted as if it had the larger capacity.

Unless you are running a broken kernel, the device is reporting a bogus capacity.
 
  


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
Formatting USB ZIP Drive solarisrob Solaris / OpenSolaris 1 08-01-2005 03:44 PM
formatting a usb flash drive to fat32 Haiyadragon Linux - General 4 07-10-2005 08:45 PM
formatting a usb flash drive zatka Linux - Hardware 2 12-12-2004 09:04 AM
Formatting Floppy Usb Drive Redhat9 lorenzo111 Red Hat 6 05-03-2004 05:45 PM
Formatting USB Floopy Drive RedHat9 lorenzo111 Linux - Newbie 2 01-03-2004 10:38 AM


All times are GMT -5. The time now is 10:30 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration