J'utilise un script de http://www.angstrom-distribution.org/demo/beagleboard/ qui utilise mkfs.vfat et mkfs.e2fs pour créer 2 partitions sur une carte SD mais je reçois
mkfs.vfat 3.0.12 (29 Oct 2011)
mkfs.vfat: unable to open /dev/sdg1: Device or resource busy
Le script est le suivant
#! /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
la pleine sortie est:
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!
J'ai essayé
Sudo fuser -v /dev/sdg
Sudo fuser -v /dev/sdg1
Sudo fuser -v /dev/sdg2
mais sans résultat. Merci
Vérifiez que votre LVM ne vole pas les périphériques:
Sudo dmsetup ls
Si vous voyez vos appareils là-bas, supprimez-les simplement:
Sudo dmsetup remove sdgX
La réponse de Pekka Nikander a fait l'affaire pour moi.
Le seul problème est que vous ne pouvez pas simplement "dmsetup remove sdgX". Lorsque le script mkcard se repartitionne, le LVM les saisit encore. J'ai donc exécuté le script une fois, puis le relancer après avoir découvert les périphériques et commenté les sections de partitionnement du script.
EDIT: Je crois que la partie qu’il a commentée dans mkcard.txt est la suivante:
if [ -x `which kpartx` ]; then
kpartx -a ${DRIVE}
fi