LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
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 01-18-2006, 03:45 AM   #1
conn-fused
Member
 
Registered: Jun 2004
Posts: 124

Rep: Reputation: 15
Formatting a USB partition for use with Windows


I have an LG 512MB USB key, divided into three partitions. The first two are ext2 and have a bootable installation of Debian. The third is an msdos partition. I was hoping that I could use this partition to carry files for those times when I'm forced to work with Windows machines at work.

Unfortunately, Windows claims the whole disk is unformatted. It offers me a chance to format it but I decline. We all know how clumsy Windows is ... not understanding ext2, it'd probably erase the first two partitions too.

So my question is this: How can I use Linux or Windows to make the third partition (and only the third partition) on my USB key readable on a Windows machine?

Thanks!
 
Old 01-18-2006, 04:15 AM   #2
yoron
Member
 
Registered: Nov 2005
Posts: 120

Rep: Reputation: 15
do a partition from XP (unformat your usb first)
Use Fat32.
Then do the rest unformated partition/s from linux.
and mount your Fat32 partition.
I think that would work...
 
Old 01-18-2006, 04:49 AM   #3
pingu
Senior Member
 
Registered: Jul 2004
Location: Skuttunge SWEDEN
Distribution: Debian preferably
Posts: 1,295

Rep: Reputation: 123Reputation: 123
I agree with yoron.
Just a few notes YI:
There are two things that might cause problems:
1) From fdisk's manpage:
Code:
if you use cfdisk or fdisk to change the size of a DOS partition table entry, 
then you must also use dd to zero the first 512 bytes of that partition before 
using DOS FORMAT to format the partition
I have found this to be necessary with all Windows-partitions, not only DOS6.
2) Windows wants C:\ to be the very first partition . sometimes it works having C:\ as second-or-later, but my advice is to avoid it.
Linux is completely unsensitive as to where partitions are placed (only /boot might have to be primary, and/or before cyl 1024.)
 
Old 01-18-2006, 11:21 AM   #4
conn-fused
Member
 
Registered: Jun 2004
Posts: 124

Original Poster
Rep: Reputation: 15
Thanks guys, these are helpful posts, but is there any way I can format the third partition as FAT32 without loosing the data on the first two partitions?

If there isn't, could I get some advice on using dd with the usb to make images of these two partitions so I can restore them?

Please keep in mind, if you think I should use the dd route, that the first partition I want to preserve is a /boot partition, and so should probably go at the start of the usb key. Can I actually format the key to FAT32 and then change the start point of the partition? I was under the (possibly false) impression that only the end points of partitions could be altered, but then I am pretty new to working with partitions like this.
 
Old 01-18-2006, 11:25 AM   #5
conn-fused
Member
 
Registered: Jun 2004
Posts: 124

Original Poster
Rep: Reputation: 15
One more thought. What about vfat? Can Windows understand that? Then maybe a simple "mkfs.vfat /dev/sda3" will solve my problems.
 
Old 01-18-2006, 06:11 PM   #6
michaelk
Moderator
 
Registered: Aug 2002
Posts: 11,969

Rep: Reputation: 752Reputation: 752Reputation: 752Reputation: 752Reputation: 752Reputation: 752Reputation: 752
How were the partitions created and formated?
What did you use to format the msdos partition?
What is the partition ID type for your msdos partition?
Post the output of the command
fdisk -l /dev/sda (that is a small L and you must be root, change sda for the actual device ID if different)
 
Old 01-19-2006, 08:34 AM   #7
conn-fused
Member
 
Registered: Jun 2004
Posts: 124

Original Poster
Rep: Reputation: 15
OK, here's what I did:

parted /dev/sda "mklabel msdos mkpart primary 0 14 mkpart primary 15 383 mkpart primary 384 -0"
shred -n 1 -v /dev/sdd2
cryptsetup -y create rootfs /dev/sdd2
mkfs.ext2 /dev/mapper/rootfs
mkfs.ext2 /dev/sda2
sync ; sync
mkfs.msdos /dev/sda3

That's only the slightest of variations on the instructions in the following article here (in case anyone else is interested):
http://www.debian-administration.org/articles/179

I think that answers your first question.

As to your second, I did nothing after "mkfs.msdos /dev/sda3". I was under the impression that making the filesystem formatted the partition. Apparently it does not. But in that case, why can I read my ext2 partitions after "mkfs.ext2 /dev/whatever"?

Third: looks like 83 to me ... which is not what I'd have expected. See for yourself in the fdisk output you requested (below):

Disk /dev/sda: 519 MB, 519700480 bytes
255 heads, 63 sectors/track, 63 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 1 2 16033+ 83 Linux
/dev/sda2 3 49 377527+ 83 Linux
/dev/sda3 50 63 112455 83 Linux
 
Old 01-19-2006, 09:03 AM   #8
michaelk
Moderator
 
Registered: Aug 2002
Posts: 11,969

Rep: Reputation: 752Reputation: 752Reputation: 752Reputation: 752Reputation: 752Reputation: 752Reputation: 752
The mkfs utility does format the filesystem.
Windows does not recognize sda3 because the partition ID type is non DOS i.e. 83 instead of 06 or 0xb. Formating does not modify the ID type.

Use cfdisk or fdisk etc to change the ID type. This will not effect existing data.
 
Old 01-20-2006, 05:09 AM   #9
conn-fused
Member
 
Registered: Jun 2004
Posts: 124

Original Poster
Rep: Reputation: 15
Thanks michaelk ... I should have remembered to change the ID.

BTW, I've decided to go with vfat instead of msdos (for long filename support). I presume only 0xB (Win95 Fat32) will do for that, but if I'm wrong please post a correction in case anyone else decides that want to follow the procedure we've laid out here.

Last edited by conn-fused; 01-20-2006 at 05:22 AM.
 
Old 01-20-2006, 07:46 AM   #10
blimbo
LQ Newbie
 
Registered: Jul 2003
Location: London
Distribution: Fedora Core 4
Posts: 16

Rep: Reputation: 0
Have you tried qtparted? I *think* this can format partitions as fat32..
 
Old 01-20-2006, 11:02 AM   #11
Matir
Moderator
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,507

Rep: Reputation: 118Reputation: 118
0x0B should work for vfat (aka fat16). If you really want fat32, you'd need to specifically add '-F 32' to the mkfs.vfat options.
 
Old 01-20-2006, 11:26 AM   #12
conn-fused
Member
 
Registered: Jun 2004
Posts: 124

Original Poster
Rep: Reputation: 15
Matir: OK, I've tried "mkfs.vfat" and "mkfs.vfat -F 32" with the partition ID set to "b" (0x0b) and tested both combinations on a laptop running XP. In both cases, it insists that the USB key is not formated. I also tried "mkfs.vfat" with partition ID "6" (0x06), to no avail.

Is it possible that XP can't deal with a USB key that has a non-FAT32 partition before a FAT32 one at all? Does anyone else have an empty USB key, an XP and a Linux they can test this with? (ie maybe it's just my key?)

Blimbo: No, I haven't run across qtparted before; thanks for the tip. I'll track down a copy and put my results into this post.
 
Old 01-20-2006, 11:28 AM   #13
Matir
Moderator
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,507

Rep: Reputation: 118Reputation: 118
Well, if you haven't found anything, I can test it when I get home this evening. I've done mixed fat/non-fat USB drives before, but the fat partition has always been first.
 
Old 01-20-2006, 12:42 PM   #14
michaelk
Moderator
 
Registered: Aug 2002
Posts: 11,969

Rep: Reputation: 752Reputation: 752Reputation: 752Reputation: 752Reputation: 752Reputation: 752Reputation: 752
Does XP recognize sda3 as a DOS partition with an ID type of 0xb? If so then use XP to format it as FAT32.
 
Old 01-20-2006, 07:50 PM   #15
Matir
Moderator
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,507

Rep: Reputation: 118Reputation: 118
Seeing that there has been nothing conclusive so far, I am going to test some different arrangements using a cheap 256MB jumpdrive I have here.

In an effort to make this well-documented, I invite commentary as I perform the tests.

I will be partitioning and formatting the jumpdrive with standard linux tools, whose versions I will list below. I will test the drive using Windows XP Professional SP2. I will test the following arrangements (p1=partition 1, etc.):
  • p1: ext2, type 0x83 p2: fat16, type 0x83 (OP Configuration)
  • p1: ext2, type 0x83 p2: fat16, type 0x0B (Revised Config)
  • p1: fat16, type 0x0B p2: ext2, type 0x83 (Likely to Work)
  • p1: fat16, type 0x83 p2: ext2, type 0x83 (Test if partition type matters)

If anyone else has any other thoughts on what I can test, let me know. I think this will prove interesting.

Software versions:
Code:
$ mkfs.vfat
mkfs.vfat 2.11 (12 Mar 2005)
No device specified!
Usage: mkdosfs [-A] [-c] [-C] [-v] [-I] [-l bad-block-file] [-b backup-boot-sector]
       [-m boot-msg-file] [-n volume-name] [-i volume-id]
       [-s sectors-per-cluster] [-S logical-sector-size] [-f number-of-FATs]
       [-h hidden-sectors] [-F fat-size] [-r root-dir-entries] [-R reserved-sectors]
       /dev/name [blocks]
$ mkfs.ext2 -V
mke2fs 1.38 (30-Jun-2005)
        Using EXT2FS Library version 1.38
$ cfdisk -v
cfdisk 2.12r
Copyright (C) 1994-2002 Kevin E. Martin & aeb

Last edited by Matir; 01-20-2006 at 07:54 PM.
 
  


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 partition with XFS. duffmckagan Linux - Software 1 10-30-2005 12:58 PM
Formatting failed, now my fat32 windows partition is non-existent. zimzam Mandriva 12 12-28-2004 06:51 PM
help with partition formatting and reisferFS debloxie Linux - Newbie 11 05-11-2004 10:24 AM
Formatting a FAT32 partition... SamH Linux - General 3 12-23-2003 10:51 AM
can i resize partition without formatting? doublefailure Linux - General 4 03-23-2002 06:15 PM


All times are GMT -5. The time now is 12:22 PM.

Main Menu
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