Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 01 May 2010 12:40:23 +0800
From:      Fbsd1 <fbsd1@a1poweruser.com>
To:        FreeBSD Questions <freebsd-questions@freebsd.org>
Subject:   Re: How To create msdosfs on HD?
Message-ID:  <4BDBB0B7.4080609@a1poweruser.com>
In-Reply-To: <4BDA4EF5.7050703@a1poweruser.com>
References:  <4BD97BAF.8080002@a1poweruser.com>	<op.vbxbzwnzwdsea2@ccbh-194.acct.upmchs.net>	<p2k6201873e1004290541s3148df16h79a63858686837f5@mail.gmail.com> <4BDA4EF5.7050703@a1poweruser.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Fbsd1 wrote:
>>> On Thu, 29 Apr 2010 09:29:35 -0300, Fbsd1 <fbsd1@a1poweruser.com> wrote:
>>>
>>>> I know mount_msdosfs command is used to mount a HD formated with 
>>>> fat, but
>>>> I could not find a FBSD command to create a msdos file system on a hard
>>>> drive. Native dos fdisk/format is no good because it's not USB 
>>>> aware. Is
>>>> there any FBSD command or port I can use to reformat the UFS hard 
>>>> drive with
>>>> msdosfs?
>>>
>> dd if=/dev/zero of=/dev/da0 bs=512k count=10
>> fdisk -i /dev/da0
>> newfs_msdos -F32 /dev/da0s1
>>
> 
> Thank you very much.
> Thats the answer I was hoping for.
>
>
 >
 >
For the archives here is a detailed explanation.

Create MS/Windows file system on a Hard Drive so it will be recognized 
on an MS/Windows system.

The goal here is to initialize a hard drive that was previous 
initialized with a non-Microsoft Windows file system, with a single 
active partition populated with Microsoft Windows 32 bit FAT (LBA) file 
system. So this hard drive will be recognized as containing a valid 
MS/Windows file system when used on a Microsoft Windows system.

I have an old IDE 3.5” hard drive with FBSD Release 7.0 on it. I want to 
use it as external USB attached disk on XP. I bought a 'CD-r king' hard 
drive to USB adapter cable. It will work with 2.5” & 3.5” IDE drives and 
SATA drives. When I plug the USB end of the cable into a FBSD system I 
can mount the 3.5” IDE 7.0 HD's da0s1a, da0s1d, da0s1e and da0s1f  file 
systems with no problem. But when I plug the same drive into a XP system 
the USB drive shows in “control panel/system/hardware/devices/hard 
drives” as there, but “windows explorer” does not assign a drive letter 
for it so I can not reformat it.

All PC’s running a MS/Windows system inspect sector 0 of the hard drive 
for the partition/slice table to determine the sysid of each 
partition/slice. If the sysid value is 12 then it’s a valid Microsoft 
Windows file system and gets assigned a drive letter in “windows 
explorer”. Any other sysid value means non-Microsoft Windows file system 
and the device is seen in  “control panel/system/hardware/devices/hard 
drives” as there but “windows explorer” does not assign a drive letter 
to it.

There are 2 ways to initialize ((2.5” or 3.5”) (IDE or SATA)) hard 
drives with a valid MS/Windows file system. Using the Microsoft “fdisk” 
program or the FreeBSD “fdisk” program. The Microsoft “fdisk” program 
defaults to sysid =12. The FreeBSD “fdisk” program defaults to sysid = 
165, but has alternate way to assign any sysid value you want.

Microsoft method. Replace the 2.5” hard drive in your laptop with the 
2.5” hard drive containing the FreeBSD system. If 3.5” hard drive then 
open your desktop PC, remove the data cable ribbon and power connection 
from the existing hard drive and attach them to the 3.5” hard drive 
containing the FreeBSD system. Put the Microsoft XP, Vista, or Windows7 
install CD in the cdrom drive and boot. Select fdisk option from the 
install menu to populate the hard drive with official ntfs file system. 
No need to continue with the install after fdisk complete.

FreeBSD method. You need a PC with a running FreeBSD system and USB 
hardware to attach the 2.5” or 3.5” IDE or SATA hard drives with. A USB 
external hard drive housing will work fine for 3.5” IDE and SATA drives. 
For 2.5” IDE or SATA drives you will need a USB adapter cable. The 'CD-r 
king' hard drive to USB cable I purchased works with 2.5” & 3.5” IDE 
drives and SATA drives, cost $10 USA. If you have a 3.5” IDE or SATA 
hard drive and FreeBSD is running on a desktop PC, you could open it up 
and add it as a second hard drive on the data ribbon.

Attach the hard drive to the USB equipment and plug into USB port on the 
PC running FreeBSD. Best if you are logged in as “root”. You will see 
the USB console messages as the USB hard drive is connected. In most 
cases the USB drive will be assigned da0 as the device name. The 
following instructions are for initializing the hard drive as a single 
MS/Windows partition occupying the whole hard drive.


  Wipe clean the sector 0 slice table
# dd if=/dev/zero of=/dev/da0 count=2


The following is what you would do if the initialized msdosfs hard drive 
will only be used on a FreeBSD system. The slice table is populated with 
the sysid of 165, which means FreeBSD is using this slice, but the slice 
contains a MSDOS FAT32 file system. The newfs_msdos command is really 
acting like the msdos format command. The larger your hard drive the 
longer this command will take to complete.

#fdisk -BI /dev/da0
#newfs_msdos -F32 /dev/da0s1
This creates the sector 0 slice table and loads the default bios boot 
code and activates a single slice covering the entire disk.


If at this point you un-plugged the USB cable from the FreeBSD system 
and plugged it into a Microsoft Windows PC. The USB drive would be 
un-accessible by “windows explorer” because no drive letter gets 
assigned. That’s because Window’s see this hard drive as a non-windows 
drive. Which is really true because the slice sysid contains the 165 value.


To make the hard drive accessible to a Microsoft Windows PC, the sysid 
has to be set to a value of 12. This time use the fdisk flag lower case 
“i” which clears all existing slice entries and puts you in interactive 
slice table update mode.

# fdisk -Bi /dev/da0

Select default “n” for everything except for the following prompts.
(Changing partition1 which you answer “y”. When prompt ( Supply a 
decimal value for "sysid (165=FreeBSD)" [165] ) enter the value of 12. 
Then at prompt (Are we happy with this entry? [n] ) enter value of y for 
yes. And at the end you get prompt (Should we write new partition table? 
[n] ) enter value y for yes.

#fdisk /dev/da0
Will now show that partition 1 is marked active and has sysid or 12 for 
(DOS or Windows 95 with 32 bit FAT (LBA))

# newfs_msdos -F32 /dev/da0s1

Will format the slice 1 partition for MSDOS file system. Elapse running 
time is dependent on hard disk size.

If at this point you un-plugged the USB cable from the FreeBSD system 
and plugged it into a Microsoft Windows PC. The USB drive would be 
accessible by “windows explorer” because a drive letter gets 
auto-assigned. That’s because Window’s now sees this hard drive as a 
windows drive. Which is really true because the slice sysid contains the 
12 value.







Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4BDBB0B7.4080609>