Opened 12 years ago

Closed 11 years ago

#651 closed defect (fixed)

Mindi USB Creation (Filesystem) Failing

Reported by: Matthew Ross Owned by: Bruno Cornec
Priority: normal Milestone: 3.0.3
Component: mindi Version: 3.0.2
Severity: normal Keywords:
Cc: mondotrac@…


I am running into issues using mindi to create bootable USB drives on RHEL/CentOS 6.x.

After writing the partition table to the USB drive (successfully), the call mkdosfs fails to write the filesystem. Output is as follows:

INFO: The USB device /dev/sdb now looks like this:

Disk /dev/sdb: 131 MB, 131072000 bytes
16 heads, 32 sectors/track, 500 cylinders
Units = cylinders of 512 * 512 = 262144 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *           1         500      127984    b  W95 FAT32
INFO: Unmounting /dev/sdb1 just in case again
umount: /dev/sdb1: not mounted
INFO: Creating a vfat filesystem on /dev/sdb1
mkdosfs 3.0.9 (31 Jan 2010)
ERROR: Unable to create a vfat filesystem on /dev/sdb1
       Make sure your USB device is pluged (<--sp) in and partitioned (/dev/sdb1 must exist on it)

Of course nothing on the device is mounted and I have verified this occurs manually entering the commands to create the drive:

  1. fdisk the drive deleting partitions and creating the one (type b)
  2. kpartx -a /dev/sdb
  3. mkdosfs -F 32 /dev/sdb1

What appears to happening is upon calling kpartx, device mapper seems to be getting a hold of the device creating a node for it (/dev/mapper/sdb1 and /dev/dm-N) causing the mkdosfs command to fail.

kpartx output:

[root@##### rules.d]# kpartx -va /dev/sdb
add map sdb1 (253:0): 0 255950 linear /dev/sdb 50

dmsetup ls output:

sdb1    (253:0)

dmsetup info output:

Name:              sdb1
State:             ACTIVE
Read Ahead:        256
Tables present:    LIVE
Open count:        0
Event number:      0
Major, minor:      253, 0
Number of targets: 1
UUID: part1-sdb

mkdosfs output:

[root@##### rules.d]# mkdosfs -F 32 /dev/sdb1
mkdosfs 3.0.9 (31 Jan 2010)
mkdosfs: unable to open /dev/sdb1

For some reason device mapper is preventing mkdosfs from creating the filesystem. I am not really sure what is happening here or why device mapper would interfere with creating a filesystem. I suspect something is going on with udev creating this node but I will need to investigate it further.

As a work around I added the following to mindi for the time being, though at this point I am not sure if this is a distro quirk, external bug, or internal bug:

OfferToMakeBootableUSB() {
    kpartx -a $USBDEVICE
    # Some distro do auto mount at that point (Ubuntu)
    LogFile "INFO: Unmounting $USBPART just in case again"
    umount $USBPART 2>> $LOGFILE 1>> $LOGFILE
    echo -en "."
    if [ "`which dmsetup`" != "" ]; then
        block_id="`echo $USBPART | sed 's|/dev/||g'`"
        if [[ "`dmsetup ls | awk '{print $1}' | grep $block_id`" != "" ]]; then
            LogFile "INFO: Removing $block_id from device mapper."
            sleep 1
            dmsetup remove $block_id
    LogFile "INFO: Creating a vfat filesystem on $USBPART"
    mkdosfs -F 32 $USBPART 2>&1 >> $LOGFILE

Kind of a hack but it got it working for me. I did a quick search on trac for anything similar and came up empty - punch me if I missed something. I will try and get to the bottom of what is going on in the background but I wanted to spit this out there in case anyone has had similar issues.

Change History (3)

comment:1 by Matthew Ross, 12 years ago

Ignore the comment on udev - I believe kpartx is doing what is expected adding the mapper nodes. I am still unsure why this all is interfering the filesystem creation. Verified on another system with two USB drives.

In all cases the work around is working.

comment:2 by Rai, 11 years ago

Cc: mondotrac@… added

Encountered the same issue on RHEL 5.7 x86_64. mindi stops on this error:


Transforming /dev/sda in a Bootable device ..INFO: Installing an MBR (/usr/share/syslinux/mbr.bin) on /dev/sda 0+1 records in 0+1 records out 440 bytes (440 B) copied, 0.011183 seconds, 39.3 kB/s

Disk /dev/sda: 320.0 GB, 320072933376 bytes 255 heads, 63 sectors/track, 38913 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System /dev/sda1 * 1 38913 312568641 b W95 FAT32 ...ERROR: Unable to mount /dev/sda1 on /tmp/mindi.MORMj11329/usb

Make sure your USB device is pluged in, partitioned and formated (/dev/sda1 must exist on it)

Disk /dev/sda: 320.0 GB, 320072933376 bytes 255 heads, 63 sectors/track, 38913 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/dev/sda1 * 1 38913 312568641 b W95 FAT32 ---

After then, the USB device can no longer be mounted, returning the error:

[root@localhost ~]# mount -t vfat /dev/sda1 /mnt mount: /dev/sda1 already mounted or /mnt busy

To be able to remount the drive, I have to restart the server. As for the packages installed, I have the following:

mindi-busybox-1.18.5-1.rhel5 mondo-3.0.2-1.rhel5 mindi-2.1.3-1.rhel5

The work around provided by msross seemed to have, well, worked around the issue.

Last edited 11 years ago by Rai (previous) (diff)

comment:3 by Bruno Cornec, 11 years ago

Resolution: fixed
Status: newclosed

Patch adopted in rev [3086]. test packages on their way.

Note: See TracTickets for help on using tickets.