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 |
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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
|
01-18-2006, 03:45 AM
|
#1
|
|
Member
Registered: Jun 2004
Posts: 124
Rep:
|
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!
|
|
|
|
01-18-2006, 04:15 AM
|
#2
|
|
Member
Registered: Nov 2005
Posts: 120
Rep:
|
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...
|
|
|
|
01-18-2006, 04:49 AM
|
#3
|
|
Member
Registered: Jul 2004
Location: Skuttunge SWEDEN
Distribution: Debian preferably
Posts: 987
Rep:
|
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.)
|
|
|
|
01-18-2006, 11:21 AM
|
#4
|
|
Member
Registered: Jun 2004
Posts: 124
Original Poster
Rep:
|
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.
|
|
|
|
01-18-2006, 11:25 AM
|
#5
|
|
Member
Registered: Jun 2004
Posts: 124
Original Poster
Rep:
|
One more thought. What about vfat? Can Windows understand that? Then maybe a simple "mkfs.vfat /dev/sda3" will solve my problems.
|
|
|
|
01-18-2006, 06:11 PM
|
#6
|
|
Moderator
Registered: Aug 2002
Posts: 10,707
|
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)
|
|
|
|
01-19-2006, 08:34 AM
|
#7
|
|
Member
Registered: Jun 2004
Posts: 124
Original Poster
Rep:
|
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
|
|
|
|
01-19-2006, 09:03 AM
|
#8
|
|
Moderator
Registered: Aug 2002
Posts: 10,707
|
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.
|
|
|
|
01-20-2006, 05:09 AM
|
#9
|
|
Member
Registered: Jun 2004
Posts: 124
Original Poster
Rep:
|
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.
|
|
|
|
01-20-2006, 07:46 AM
|
#10
|
|
LQ Newbie
Registered: Jul 2003
Location: London
Distribution: Fedora Core 4
Posts: 16
Rep:
|
Have you tried qtparted? I *think* this can format partitions as fat32..
|
|
|
|
01-20-2006, 11:02 AM
|
#11
|
|
Moderator
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,505
Rep: 
|
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.
|
|
|
|
01-20-2006, 11:26 AM
|
#12
|
|
Member
Registered: Jun 2004
Posts: 124
Original Poster
Rep:
|
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.
|
|
|
|
01-20-2006, 11:28 AM
|
#13
|
|
Moderator
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,505
Rep: 
|
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.
|
|
|
|
01-20-2006, 12:42 PM
|
#14
|
|
Moderator
Registered: Aug 2002
Posts: 10,707
|
Does XP recognize sda3 as a DOS partition with an ID type of 0xb? If so then use XP to format it as FAT32.
|
|
|
|
01-20-2006, 07:50 PM
|
#15
|
|
Moderator
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,505
Rep: 
|
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.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 05:08 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|