Patchwork use of kpartx in contrib/angstrom/ is suboptimal

mail settings
Submitter Attila Kinali
Date Oct. 7, 2011, 1:53 p.m.
Message ID <>
Download mbox | patch
Permalink /patch/12871/
State New, archived
Headers show


Attila Kinali - Oct. 7, 2011, 1:53 p.m.

the script contrib/angstrom/ uses kpartx to create the
device files for the partitions just created, if kpartx is available.
Unfortunately, kpartx does not work here as intended, it binds the
device files in a way that prevents the script from running properly
(mkfs fails due to the "partition in use" check, as kpartx makes
the kernel to keep them in use). As most systems do not have
kpartx installed, this bug isn't triggered for most people.
(kpartx is only needed if you want to create "partiton device files"
for block devices that are not usually partitioned, like lvm volumes or
disk images)

The right thing to do would be to use sfdisk to reload the partition
table and let udev handle the rest. (Actually this isn't really necessary,
as sfdisk reloads the partition table anyways after writing the changes)

			Attila Kinali


---        2011-10-07 15:52:57.000000000 +0200
+++     2011-10-07 15:29:49.000000000 +0200
@@ -33,9 +33,10 @@ 
 sleep 1
-if [ -x `which kpartx` ]; then
-       kpartx -a ${DRIVE}
+#if [ -x `which kpartx` ]; then
+#      kpartx -a ${DRIVE}
+sfdisk -R $DRIVE
 # handle various device names.
 # note something like fdisk -l /dev/loop0 | egrep -E '^/dev' | cut -d' ' -f1