Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

mkdosfs -C ...

49 views
Skip to first unread message

peas...@shaw.ca

unread,
Jun 3, 2013, 6:10:02 PM6/3/13
to
Hi,

mkdosfs fails in this case.

=============
root@dalton:/media/9D7C-BB83# fdisk -l /dev/sdb

Disk /dev/sdb: 257 MB, 257425408 bytes
6 heads, 26 sectors/track, 3222 cylinders
Units = cylinders of 156 * 512 = 79872 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x8878a0ad

Device Boot Start End Blocks Id System
/dev/sdb1 14 3223 250368 6 FAT16
root@dalton:/media/9D7C-BB83# mount | grep sdb
/dev/sdb1 on /media/9D7C-BB83 type vfat (rw,nosuid,nodev,uhelper=udisks,uid=1000,gid=1000,shortname=mixed,dmask=0077,utf8=1,showexec,flush)
root@dalton:/media/9D7C-BB83# mkdosfs -v -C /media/9D7C-BB83/FatFile 25
mkdosfs 3.0.9 (31 Jan 2010)
mkdosfs: unable to create /media/9D7C-BB83/FatFile
=============

In attempt understand the ouput from fdisk,
257425408/250368 = 1028 suggests that the block size is 1024 or 1028.
fdisk has no mention of such number but tells "Sector size ... 512 bytes".

What is the block size here?
Why did mkdosfs fail?

Thanks for any enlightenment or ideas, ... Peter E.


--
123456789 123456789 123456789 123456789 123456789 123456789 123456789 12
Tel +13606390202 Bcc: peasthope at shaw.ca http://carnot.yi.org/
"http://members.shaw.ca/peasthope/index.html#Itinerary "


--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org
Archive: http://lists.debian.org/171058051....@cantor.invalid

Andrei POPESCU

unread,
Jun 4, 2013, 2:20:01 AM6/4/13
to
On Lu, 03 iun 13, 15:06:05, peas...@shaw.ca wrote:
> Hi,
>
> mkdosfs fails in this case.
>
> =============
> root@dalton:/media/9D7C-BB83# fdisk -l /dev/sdb
>
> Disk /dev/sdb: 257 MB, 257425408 bytes
> 6 heads, 26 sectors/track, 3222 cylinders
> Units = cylinders of 156 * 512 = 79872 bytes
> Sector size (logical/physical): 512 bytes / 512 bytes
> I/O size (minimum/optimal): 512 bytes / 512 bytes
> Disk identifier: 0x8878a0ad
>
> Device Boot Start End Blocks Id System
> /dev/sdb1 14 3223 250368 6 FAT16
> root@dalton:/media/9D7C-BB83# mount | grep sdb
> /dev/sdb1 on /media/9D7C-BB83 type vfat (rw,nosuid,nodev,uhelper=udisks,uid=1000,gid=1000,shortname=mixed,dmask=0077,utf8=1,showexec,flush)
> root@dalton:/media/9D7C-BB83# mkdosfs -v -C /media/9D7C-BB83/FatFile 25
> mkdosfs 3.0.9 (31 Jan 2010)
> mkdosfs: unable to create /media/9D7C-BB83/FatFile

I get a different error with the version in unstable:

# mkdosfs -v -C FatFile 25
mkdosfs 3.0.16 (01 Mar 2013)
mkdosfs: Too few blocks for viable file system

Kind regards,
Andrei
--
http://wiki.debian.org/FAQsFromDebianUser
Offtopic discussions among Debian users and developers:
http://lists.alioth.debian.org/mailman/listinfo/d-community-offtopic
signature.asc

Klaus

unread,
Jun 4, 2013, 3:50:02 AM6/4/13
to
Peter

Not sure about the main question of why mkdosfs failed, I tried to
replicate the situation on a spare USB stick and it just works. That
said, I didn't understand why you used the -"C" option in this case
instead of just giving the device name ?

The units reported by fdisk keep confusing me too. I made myself a
little spread sheet to aid my memory :^)

Each cylinder is nominally divided into tracks that are read by 1 head
each. Each track is divided into sectors, and these sectors contain a
number of bytes. Going upwards in size now: In your case the sector size
is 512 bytes, you've got 26 sectors per head and 6 heads per cylinder.
26*6=156 sectors per cylinder, 26*6*512=79872 bytes per cylinder.
Now, to make it even more confusing, cylinders sometimes seem to be
counted from zero. In your case, the total 257425408 bytes divided by
79872 bytes per cylinder yields 3223 cylinders per disk, not 3222 as
fdisk -l displays.
Note that partition sdb1 doesn't start at the very beginning of the
disk, and the 250368 blocks of 1024 bytes each make up only 256376832
bytes.


--
Klaus


--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org
Archive: http://lists.debian.org/51AD9BC6...@gmail.com

Klaus

unread,
Jun 4, 2013, 4:00:02 AM6/4/13
to
Increase block count a little, and hey presto:

$ sudo mkdosfs -v -C FatFile2 1024
mkdosfs 3.0.16 (01 Mar 2013)
FatFile2 has 64 heads and 32 sectors per track,
logical sector size is 512,
using 0xf8 media descriptor, with 2048 sectors;
file system has 2 12-bit FATs and 4 sectors per cluster.
FAT size is 2 sectors, and provides 502 clusters.
There is 1 reserved sector.
Root directory contains 512 slots and uses 32 sectors.
Volume ID is fa11e184, no volume label.


--
Klaus


--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org
Archive: http://lists.debian.org/51AD9D46...@gmail.com

peas...@shaw.ca

unread,
Jun 4, 2013, 9:50:01 PM6/4/13
to
Since the original trial, the system was upgraded from
Squeeze to Wheezy.

From: Klaus <klaus.do...@gmail.com>
Date: Tue, 04 Jun 2013 08:54:46 +0100
> Increase block count a little, and hey presto:
> $ sudo mkdosfs -v -C FatFile2 1024
> mkdosfs 3.0.16 (01 Mar 2013)
> FatFile2 has 64 heads and 32 sectors per track,
> logical sector size is 512, ...

In Wheezy I fare no better than in Squeeze.
root@dalton:~# mount | grep sdb
/dev/sdb1 on /media/usb0 type vfat (rw,nodev,noexec,noatime,nodiratime,sync,fmas
k=0022,dmask=0022,codepage=cp437,iocharset=utf8,shortname=mixed,errors=remount-r
o)
root@dalton:~# ls -ld /media/usb0
drwxr-xr-x 3 root root 16384 Jun 4 18:12 /media/usb0
root@dalton:~# mkdosfs -v -C /media/usb0/FatFile 1024
mkdosfs 3.0.13 (30 Jun 2012)
mkdosfs: unable to create /media/usb0/FatFile

From: Klaus <klaus.do...@gmail.com>
Date: Tue, 04 Jun 2013 08:48:22 +0100
> ... didn't understand why you used the -"C" option in this case
> instead of just giving the device name ?

The intention is to make an empty file occupying the whole
partition. Then another filesystem can be mounted on that
empty file; or "another filesystem can occupy that file" might
be better terminology. The -C option is explained briefly
by man mkdosfs. Loop device is explained in Wikipedia.

http://en.wikipedia.org/wiki/Loop_device

Regards, ... Peter E.

--
123456789 123456789 123456789 123456789 123456789 123456789 123456789 12
Tel +13606390202 Bcc: peasthope at shaw.ca http://carnot.yi.org/
"http://members.shaw.ca/peasthope/index.html#Itinerary "


--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org
Archive: http://lists.debian.org/171058052....@cantor.invalid

Klaus

unread,
Jun 5, 2013, 4:50:02 AM6/5/13
to
Peter,

Here are test on a newly (re-)created partition on a USB stick, and I'm
running SID. After creating the

$ sudo mkdosfs -v -n TEST_FAT16 -C /media/user/TEST 1024
mkdosfs 3.0.16 (01 Mar 2013)
mkdosfs: unable to create /media/user/TEST

$ sudo mkdosfs -v -n TEST_FAT16 -C /media/user/TEST/test-mkdosfs-file2 1024
mkdosfs 3.0.16 (01 Mar 2013)
/media/user/TEST/test-mkdosfs-file2 has 64 heads and 32 sectors per track,
logical sector size is 512,
using 0xf8 media descriptor, with 2048 sectors;
file system has 2 12-bit FATs and 4 sectors per cluster.
FAT size is 2 sectors, and provides 502 clusters.
There is 1 reserved sector.
Root directory contains 512 slots and uses 32 sectors.
Volume ID is 32523ae6, volume label TEST_FAT16 .

$ sudo mkdosfs -v -n TEST_FAT16 -C /media/user/TEST/test-mkdosfs-file2 1024
mkdosfs 3.0.16 (01 Mar 2013)
mkdosfs: unable to create /media/user/TEST/test-mkdosfs-file2

As you can see, I get the same error as you report under two conditions,
(1) when I specify a directory instead of a file to the "-C" option, and
(2) when the file already exists. Any help?

Have you tried the mkdosfs on a file located somewhere else, e.g. in a
tmp folder on your hdd?
Since you have mounted the USB device, there'll be a filesystem on there
already. Have you tried writing to it, like "touch /media/usb0/testfile"?
Just for trouble shooting, have you tried to create a DOS filesystem
directly on the partition, i.e. without the "-C" option ?

--
Klaus


--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org
Archive: http://lists.debian.org/51AEFA64...@gmail.com

peas...@shaw.ca

unread,
Jun 5, 2013, 11:20:03 AM6/5/13
to
From: Klaus <klaus.do...@gmail.com>
Date: Wed, 05 Jun 2013 09:44:20 +0100
> Have you tried the mkdosfs on a file located somewhere else, ...

It works in directory FatTest in my home directory.
root@dalton:/home/peter# mkdosfs -C -v /home/peter/FatTest/FatFile 1024
mkdosfs 3.0.13 (30 Jun 2012)
/home/peter/FatTest/FatFile has 64 heads and 32 sectors per track,
logical sector size is 512,
using 0xf8 media descriptor, with 2048 sectors;
file system has 2 12-bit FATs and 4 sectors per cluster.
FAT size is 2 sectors, and provides 502 clusters.
There is 1 reserved sector.
Root directory contains 512 slots and uses 32 sectors.
Volume ID is e7f1f6a5, no volume label.

> have you tried to create a DOS filesystem
> directly on the partition, i.e. without the "-C" option ?

That also works.
root@dalton:/# mkdosfs -v /dev/sdb1
mkdosfs 3.0.13 (30 Jun 2012)
/dev/sdb1 has 8 heads and 62 sectors per track,
logical sector size is 512,
using 0xf8 media descriptor, with 500736 sectors;
file system has 2 16-bit FATs and 8 sectors per cluster.
FAT size is 248 sectors, and provides 62525 clusters.
There are 8 reserved sectors.
Root directory contains 512 slots and uses 32 sectors.
Volume ID is fb793051, no volume label.

> Since you have mounted the USB device, there'll be a filesystem on there
> already. Have you tried writing to it, like "touch /media/usb0/testfile"?

Also works.
root@dalton:/# mount /dev/sdb1 /media/usb0
root@dalton:/# mount | grep sdb
/dev/sdb1 on /media/usb0 type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=c
p437,iocharset=utf8,shortname=mixed,errors=remount-ro)
root@dalton:/# touch /media/usb0/FatFile
root@dalton:/# ls -l /media/usb0
total 0
-rwxr-xr-x 1 root root 0 Jun 5 07:50 FatFile

A bug in mkdosfs shouldn't be ruled out absolutely.

Thanks for the feedback, ... Peter E.

--
123456789 123456789 123456789 123456789 123456789 123456789 123456789 12
Tel +13606390202 Bcc: peasthope at shaw.ca http://carnot.yi.org/
"http://members.shaw.ca/peasthope/index.html#Itinerary "


--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org
Archive: http://lists.debian.org/171058053....@cantor.invalid

peas...@shaw.ca

unread,
Jun 19, 2013, 12:50:01 PM6/19/13
to
* From: Klaus <klaus.do...@gmail.com>
* Date: Tue, 04 Jun 2013 08:48:22 +0100
> I didn't understand why you used the -"C" option in
> this case instead of just giving the device name ?

My objective is to have a FAT filesystem residing in an ext3
file in wheezy.

Consequent to the difficulty with "mkdosfs -C ..." I've tried
working through a case similar to "Floppy Disk Images With FAT16".
http://wiki.osdev.org/Loopback_Device#Floppy_Disk_Images_With_FAT16

# 1. Make the empty image file.
peter@dalton:~$ dd if=/dev/zero of=FATholder bs=512 count=288000
288000+0 records in
288000+0 records out
147456000 bytes (147 MB) copied, 4.55382 s, 32.4 MB/s

# 2. Set it up for mounting.
root@dalton:/home/peter# losetup /dev/loop0 FATholder

# 3. Create the FAT filesystem.
root@dalton:/home/peter# mkfs.vfat
mkfs.vfat 3.0.13 (30 Jun 2012)
Loop device does not match a floppy size, using default hd params

# 4. Show that the user is allowed to mount the image;
root@dalton:/home/peter# grep loop /etc/fstab
/dev/loop0 /home/peter/FATmount vfat defaults,noauto,user 0 0

# ... and mount it.
peter@dalton:~$ mount /dev/loop0
peter@dalton:~$ mount | grep loop
/dev/loop0 on /home/peter/FATmount type vfat (rw,nosuid,nodev,noexec,relatime,ui
d=1000,gid=1000,fmask=0022,dmask=0022,codepage=cp437,iocharset=utf8,shortname=mi
xed,errors=remount-ro,user=peter)

# 5. Confirm that the virtual FatFS can be written to.
peter@dalton:~/Work$ cp rawrite.exe ~/FATmount
peter@dalton:~/Work$ ls -l ~/FATmount/raw*
-rwxr-xr-x 1 peter peter 12702 Jun 19 09:37 /home/peter/FATmount/rawrite.exe

Conclusion: success in five steps is better than failure in one step.

Thanks for the feedback, ... Peter E.

--
123456789 123456789 123456789 123456789 123456789 123456789 123456789 12
Tel +13606390202 Bcc: peasthope at shaw.ca http://carnot.yi.org/
"http://members.shaw.ca/peasthope/index.html#Itinerary "


--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org
Archive: http://lists.debian.org/171058067....@cantor.invalid

Klaus

unread,
Jun 19, 2013, 4:10:02 PM6/19/13
to
$ sudo mkdosfs -C test-mkdosfs-file 1440
mkdosfs 3.0.16 (01 Mar 2013)

$ ll test*
-rw-r--r-- 1 root root 1474560 Jun 19 20:52 test-mkdosfs-file

$ mkdir mnt

$ sudo mount -o loop -t vfat test-mkdosfs-file mnt/

$ ll mnt
total 0

$ sudo cp mini_ITX_spec_V1_1.pdf mnt/

$ ll mnt
total 379
-rwxr-xr-x 1 root root 387424 Jun 19 20:54 mini_ITX_spec_V1_1.pdf

$ mount
(...)
/home/klaus/tmp/test-mkdosfs-file on /home/klaus/tmp/mnt type vfat
(rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=utf8,shortname=mixed,errors=remount-ro)

$ df
Filesystem 1K-blocks Used Available Use% Mounted on
(...)
/dev/loop0 1424 379 1045 27% /home/klaus/tmp/mnt


Did you ever find out why this didn't (doesn't?) work for you?
--
Klaus


--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org
Archive: http://lists.debian.org/51C20FF3...@gmail.com

peas...@shaw.ca

unread,
Jun 20, 2013, 11:00:02 PM6/20/13
to
From: Klaus <klaus.do...@gmail.com>
Date: Wed, 19 Jun 2013 21:09:23 +0100
> $ sudo mkdosfs -C test-mkdosfs-file 1440
> mkdosfs 3.0.16 (01 Mar 2013)
> ...

Your steps can be duplicated on the hdd here with no problem.

> Did you ever find out why this didn't (doesn't?) work for you?

No. I was targeting a CF card in a USB adapter, which
should work as well as a hdd. Will try again on the
weekend or Tuesday.

Thanks, ... Peter E.

--
123456789 123456789 123456789 123456789 123456789 123456789 123456789 12
Tel +13606390202 Bcc: peasthope at shaw.ca http://carnot.yi.org/
"http://members.shaw.ca/peasthope/index.html#Itinerary "


--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org
Archive: http://lists.debian.org/171058068....@cantor.invalid
0 new messages