Not able to see partition after formating sd card using mkcard.sh script

Guys,

I have tried mkcard.sh script to make sd card bootable but after
running script, my linux machine (RHEL) is not able to detect sd card.
Please help. Following is the log,

[root@nkhandar Downloads]# ./mkcard.sh /dev/sdb
1024+0 records in
1024+0 records out
1048576 bytes (1.0 MB) copied, 0.385247 s, 2.7 MB/s
Disk /dev/sdb doesn't contain a valid partition table
DISK SIZE - 7948206080 bytes
CYLINDERS - 966
Checking that no-one is using this disk right now ...
OK

Disk /dev/sdb: 966 cylinders, 255 heads, 63 sectors/track

sfdisk: ERROR: sector 0 does not have an msdos signature
/dev/sdb: unrecognized partition table type
Old situation:
No partitions found
New situation:
Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting
from 0

   Device Boot Start End #cyls #blocks Id System
/dev/sdb1 * 0+ 8 9- 72261 c W95 FAT32 (LBA)
/dev/sdb2 9 965 957 7687102+ 83 Linux
/dev/sdb3 0 - 0 0 0 Empty
/dev/sdb4 0 - 0 0 0 Empty
Successfully wrote the new partition table

Re-reading the partition table ...

If you created or changed a DOS partition, /dev/foo7, say, then use
dd(1)
to zero the first 512 bytes: dd if=/dev/zero of=/dev/foo7 bs=512
count=1
(See fdisk(8).)
umount: /dev/sdb1: not mounted
mkfs.vfat 3.0.9 (31 Jan 2010)
mkfs.vfat: unable to open /dev/sdb1
umount: /dev/sdb2: not mounted
mke2fs 1.41.12 (17-May-2010)
/dev/sdb2 is apparently in use by the system; will not make a
filesystem here!

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

Please unmount the volume before running your shell script.
Try and let me know.

Thanks,
Barun

Hi Barun,

Barun,Thanks for the reply.

I tried to unmount the volumen before running script but its not
working,

Following procedure I tried,
1. Insert SD card.
2. Get device mount name using dmesg | tail. i.e. /dev/sdb
3. run the script. i.e. ./mkcard.sh /dev/sdb (Before that I had make
sure that /dev/sdb1 or /dev/sdb2 is not mounted anywhere)

Any idea??

Thanks,
Neel

Hi,

Can you post the script? Or mention the link of the script if possible.

Thanks,
Jyothi

Jyothi,

Thanks for the reply.

Following is the link of the script.
http://www.angstrom-distribution.org/demo/beaglebone/mkcard.txt

Let me know in case of more information needed.

Thanks,
Neel.

Hi Neel,

There is some problem with your script use the below script

#!/bin/bash
if [ ! “$1” = “/dev/sda” ] ; then
unset LANG
DRIVE=$1
if [ -b “$DRIVE” ] ; then
dd if=/dev/zero of=$DRIVE bs=1024 count=1024
SIZE=fdisk -l $DRIVE | grep Disk | awk '{print $5}'
echo DISK SIZE - $SIZE bytes
CYLINDERS=echo $SIZE/255/63/512 | bc
echo CYLINDERS - $CYLINDERS
{
echo ,9,0x0C,*
echo ,-
} | sfdisk -D -H 255 -S 63 -C $CYLINDERS $DRIVE
mkfs.vfat -F 32 -n “boot” ${DRIVE}1
mke2fs -j -L “rootfs” ${DRIVE}2
fi
fi

And let me know if you need furthur information

Thanks,
Jyothi

Hi Neel,
Can you format your SD card.
make 2 partition :

partition 1 : fat 32 , 70 MB
partition 2: ext3, rest

No need to run the script now. Just copy your uImage stuffs into partition1 and filesystem stuffs to partition2 and try.
There are many ways to do the formatiing of SD card ( in ubuntu use system->administration->disk utility).

Regards,
Barun

Hi there,

I have had the same problem with my SD Card some time ago: that "/dev/sdb2 is apparently in use by the system; will not make a
filesystem here! " message was killing me!
I did my researches on Google and this is the page that gave me the solution:
http://www.overclockers.com/forums/showthread.php?t=667317

It seems that the device was in a RAID array and keeping the drive open. Hope it will help you.

Good luck!

Hi there,

I have had the same problem with my SD Card some time ago: that "/dev/sdb2 is apparently in use by the system; will not make a
filesystem here! " message was killing me!
I did my researches on Google and this is the page that gave me the solution:
http://www.overclockers.com/forums/showthread.php?t=667317

It seems that the device was in a RAID array and keeping the drive open. Hope it will help you.

Good luck!

Hi there,

I have had the same problem with my SD Card some time ago: that "/dev/sdb2
is apparently in use by the system; will not make a
filesystem here! " message was killing me!
I did my researches on Google and this is the page that gave me the
solution:
http://www.overclockers.com/forums/showthread.php?t=667317<https://webmail.intra.cea.fr/owa/redir.aspx?C=108fb28bfe324ac18a9879a036c28a13&URL=http%3A%2F%2Fwww.overclockers.com%2Fforums%2Fshowthread.php%3Ft%3D667317>

It seems that the device was in a RAID array and keeping the drive open.
Hope it will help you.

Good luck!

Hi there,

I have had the same problem with my SD Card some time ago: that "/dev/sdb2
is apparently in use by the system; will not make a
filesystem here! " message was killing me!
I did my researches on Google and this is the page that gave me the
solution:
http://www.overclockers.com/forums/showthread.php?t=667317<https://webmail.intra.cea.fr/owa/redir.aspx?C=108fb28bfe324ac18a9879a036c28a13&URL=http%3A%2F%2Fwww.overclockers.com%2Fforums%2Fshowthread.php%3Ft%3D667317>

It seems that the device was in a RAID array and keeping the drive open.
Hope it will help you.

Good luck!

Hi there,

I have had the same problem with my SD Card some time ago: that "/dev/
sdb2 is apparently in use by the system; will not make a
filesystem here! " message was killing me!
I did my researches on Google and this is the page that gave me the
solution:
http://www.overclockers.com/forums/showthread.php?t=667317

It seems that the device was in a RAID array and keeping the drive
open. Hope it will help you.

Good luck!

Hello again.
I'd like to apologise for the 5 messages: this was my first time using
google groups, and as my messages didn't show on the topic page, i
thought that the system failed.... so i tried again and again (I even
did create a google account).
So sorry again for the spam, and hope that the solution i gave will
work.

cheers

Natxo

Hi Guys,

Thanks a lot Barun,Jyothi,Naxtao for your replies. I really appreciate your help.

Update: Finally I was able to format the sd card using expert mode (Manually using fdisk). I am still not able to figure out the root cause of the issue :slight_smile:

Again thanks a lot.

Sorry for late reply.

Thanks,
Neel

Hi Neel,

Can you describe the steps you took to fix this?

I’m getting the following:

root@ubuntu-server-x64-beagleboard:/home/cwilson# ./mkcard.sh /dev/sdb
1024+0 records in
1024+0 records out
1048576 bytes (1.0 MB) copied, 1.55514 s, 674 kB/s
Disk /dev/sdb doesn’t contain a valid partition table
DISK SIZE - 7948206080 bytes
CYLINDERS - 966
Checking that no-one is using this disk right now …
OK

Disk /dev/sdb: 966 cylinders, 255 heads, 63 sectors/track

sfdisk: ERROR: sector 0 does not have an msdos signature
/dev/sdb: unrecognized partition table type
Old situation:
No partitions found
New situation:
Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0

Device Boot Start End #cyls #blocks Id System
/dev/sdb1 * 0+ 8 9- 72261 c W95 FAT32 (LBA)
/dev/sdb2 9 965 957 7687102+ 83 Linux
/dev/sdb3 0 - 0 0 0 Empty
/dev/sdb4 0 - 0 0 0 Empty
Successfully wrote the new partition table

Re-reading the partition table …

If you created or changed a DOS partition, /dev/foo7, say, then use dd(1)
to zero the first 512 bytes: dd if=/dev/zero of=/dev/foo7 bs=512 count=1
(See fdisk(8).)
umount: /dev/sdb1: not mounted
mkfs.vfat 3.0.12 (29 Oct 2011)
mkfs.vfat: unable to open /dev/sdb1: Device or resource busy
umount: /dev/sdb2: not mounted
mke2fs 1.42 (29-Nov-2011)
/dev/sdb2 is apparently in use by the system; will not make a filesystem here!

Thanks,
Chris

I found it: http://elinux.org/BeagleBoardBeginners#Formatting_the_SD_card_via_fdisk_.22Expert_mode.22

Performing the steps in “Expert Mode” from the link above work perfectly, but mkcard.txt gives the errors in my previous post on Ubuntu 10.04 and 12.04. No clue why it thinks /dev/sdb1 and /dev/sdb2 are busy/in use…

Anybody have any insight into what’s goin on?

Chris

Even stranger this works on my desktop using Ubuntu 12.04 but fails as you describe on my Macbook Air running Ubuntu 12.04

Just in case someone else runs into this issue, this fix worked for me:

http://kevintechnology.com/post/29649230627/formatting-an-sd-card-for-the-beagleboard-xm-bone-in