Formatting an SD Card for the Beagleboard(Xm,Bone) in Ubuntu 12.04

I about tore my hair out on this one.

The guys who make the Angstrom distribution of Linux have a script called mkcard.txt ( which has traditionally worked for me to format an SD card properly for the Beagleboard family of single-board computers.

But for some reason whenever I would run it in the last month or so on either Ubuntu 10.04 or Ubuntu 12.04, I would receive the following error and the card would not be properly formatted:

/dev/sdb2 is apparently in use by the system; will not make a filesystem

I found a path to the solution thanks to this question:

There seem to be two problems. The first is that dmsetup is stealing the SD card devices.

The second problem is that the script calls kpartx to add a partition mapping of the SD card you’re using to the /dev/mapper folder. In English, this means that it will take the drive string (“/dev/sdb” in my case), mount the partitions on the drive, and create device files for them in /dev/mapper. I’m not sure why this causes the script to fail, but I’m guessing the system isn’t relinquishing control of the partition device files to the script so it can run mkfs.vfat and mke2fs on them.

So anyway, to make the mkcard.txt script work, first run it once (and experience the error I referenced above).

Then, remove the stolen devices from dmsetup by running:

sudo dmsetup remove sdb1
sudo dmsetup remove sdb2

Finally, comment out the following lines in mkcard.txt:

if [ -x `which kpartx` ]; then
    kpartx -a ${DRIVE}

And run mkcard.txt one more time, and you should be good to go!

I hope you enjoyed this post. If you are looking to hire a versatile software engineer who loves improving developer productivity and infrastructure and you happen to be either 1) located in Sacramento or 2) open to a remote worker, then please get in touch.

© 2018 Kevin Conley

Powered by Hydejack v7.5.1