newfs_msdos onto an image file

Brian Candler B.Candler at pobox.com
Sun Jan 15 04:49:54 PST 2006


On Sun, Jan 15, 2006 at 12:34:46PM +0000, Brian Candler wrote:
> I am trying to prepare an MS-DOS disk image file (for later dd to a USB
> device) but am having difficulties getting newfs_msdos to work in this way.
> This is under 5.4-RELEASE.

P.S. it seems that the total disk size given by -s is in sectors not bytes
(this isn't very clear in the manpage). This doesn't help the simple case:

# newfs_msdos -h 64 -u 32 -s 256000 /dev/md0
newfs_msdos: Cannot get number of sectors, Operation not supported
# newfs_msdos -h 64 -u 32 -s 256000 -S 512 /dev/md0
newfs_msdos: Cannot get number of sectors, Operation not supported

But finally I found an incantation that works:

# newfs_msdos -h 64 -u 32 -s 256000 -f 1440 -a 125 -F 16 -b 4096 -c 8 /dev/md0
/dev/md0: 255728 sectors in 31966 FAT16 clusters (4096 bytes/cluster)
bps=512 spc=8 res=1 nft=2 rde=224 mid=0xf0 spf=125 spt=32 hds=64 hid=0 bsec=256000
# mount -t msdos /dev/md0 /mnt
# df -k | grep md0
/dev/md0       127872       8   127864     0%    /mnt

That was a lot harder work than I was expecting, especially having to use
trial-and-error on the sectors per FAT value.

Is there any chance that newfs_msdos could gain some intelligence and be
able to choose suitable default values?

Furthermore, why do I still have to pretend that the device is a 1440K
floppy disk? If I remove -f 1440 I get:

# newfs_msdos -h 64 -u 32 -s 256000 -a 125 -F 16 -b 4096 -c 8 /dev/md0
newfs_msdos: Cannot get number of sectors, Operation not supported

Regards,

Brian.


More information about the freebsd-stable mailing list