Edit: Es gibt ein Problem mit diesem Skript. Als Workaround habe ich verwendethttp://code.google.com/p/beagleboard/wiki/LinuxBootDiskFormat

Edit: Es gibt ein Problem mit diesem Skript. Als Workaround habe ich verwendethttp://code.google.com/p/beagleboard/wiki/LinuxBootDiskFormat

Ich verwende ein Skript vonhttp://www.angstrom-distribution.org/demo/beagleboard/das verwendet mkfs.vfat und mkfs.e2fs, um 2 Partitionen auf einer SD-Karte zu erstellen, aber ich bekomme

mkfs.vfat 3.0.12 (29 Oct 2011)
mkfs.vfat: unable to open /dev/sdg1: Device or resource busy

Edit: Es gibt ein Problem mit diesem Skript. Als Workaround habe ich verwendethttp://code.google.com/p/beagleboard/wiki/LinuxBootDiskFormat

Das Skript ist das folgende

#! /bin/sh
# mkcard.sh v0.5
# (c) Copyright 2009 Graeme Gregory <[email protected]>
# Licensed under terms of GPLv2
#
# Parts of the procudure base on the work of Denys Dmytriyenko
# http://wiki.omap.com/index.php/MMC_Boot_Format

export LC_ALL=C

if [ $# -ne 1 ]; then
    echo "Usage: $0 <drive>"
    exit 1;
fi

DRIVE=$1

dd if=/dev/zero of=$DRIVE bs=1024 count=1024

SIZE=`fdisk -l $DRIVE | grep Disk | grep bytes | 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

sleep 1


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

# handle various device names.
# note something like fdisk -l /dev/loop0 | egrep -E '^/dev' |  cut -d' ' -f1 
# won't work due to https://bugzilla.redhat.com/show_bug.cgi?id=649572

PARTITION1=${DRIVE}1
if [ ! -b ${PARTITION1} ]; then
    PARTITION1=${DRIVE}p1
fi

DRIVE_NAME=`basename $DRIVE`
DEV_DIR=`dirname $DRIVE`

if [ ! -b ${PARTITION1} ]; then
    PARTITION1=$DEV_DIR/mapper/${DRIVE_NAME}p1
fi

PARTITION2=${DRIVE}2
if [ ! -b ${PARTITION2} ]; then
    PARTITION2=${DRIVE}p2
fi
if [ ! -b ${PARTITION2} ]; then
    PARTITION2=$DEV_DIR/mapper/${DRIVE_NAME}p2
fi


# now make partitions.
if [ -b ${PARTITION1} ]; then
    umount ${PARTITION1}
    mkfs.vfat -F 32 -n "boot" ${PARTITION1}
else
    echo "Cant find boot partition in /dev"
fi

if [ -b ${PARITION2} ]; then
umount ${PARTITION2}
mke2fs -j -L "Angstrom" ${PARTITION2} 
else
echo "Cant find rootfs partition in /dev"
fi

Die vollständige Ausgabe lautet:

1024+0 records in
1024+0 records out
1048576 bytes (1.0 MB) copied, 0.356157 s, 2.9 MB/s
Disk /dev/sdg 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/sdg: 966 cylinders, 255 heads, 63 sectors/track

sfdisk: ERROR: sector 0 does not have an msdos signature
/dev/sdg: 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/sdg1   *      0+      8       9-     72261    c  W95 FAT32 (LBA)
/dev/sdg2          9     965     957    7687102+  83  Linux
/dev/sdg3          0       -       0          0    0  Empty
/dev/sdg4          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/sdg1: not mounted
mkfs.vfat 3.0.12 (29 Oct 2011)
mkfs.vfat: unable to open /dev/sdg1: Device or resource busy
umount: /dev/sdg2: not mounted
mke2fs 1.42 (29-Nov-2011)
/dev/sdg2 is apparently in use by the system; will not make a   filesystem here!

ich habe es versucht

sudo fuser -v /dev/sdg
sudo fuser -v /dev/sdg1
sudo fuser -v /dev/sdg2

aber ohne Ergebnis. Danke

Antwort1

Überprüfen Sie, dass Ihr LVM die Geräte nicht stiehlt:

sudo dmsetup ls

Wenn Sie Ihre Geräte dort sehen, entfernen Sie sie einfach:

sudo dmsetup remove sdgX

Antwort2

Die Antwort von Pekka Nikander hat bei mir geholfen.

Das einzige Problem ist, dass Sie nicht einfach „dmsetup remove sdgX“ ausführen können. Wenn das mkcard-Skript neu partitioniert, schnappt sich der LVM siewieder. Also habe ich das Skript einmal ausgeführt und es dann noch einmal erneut ausgeführt, nachdem ich die Geräte entwendet und die Partitionierungsabschnitte im Skript auskommentiert hatte.

BEARBEITEN: Ich glaube, der Teil, den er in mkcard.txt auskommentiert hat, sind die folgenden Zeilen:

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

verwandte Informationen