Merge lp:~liuyq0307/lava-master-image-scripts/use-kpartx into lp:lava-master-image-scripts

Proposed by Yongqin Liu
Status: Merged
Merged at revision: 61
Proposed branch: lp:~liuyq0307/lava-master-image-scripts/use-kpartx
Merge into: lp:lava-master-image-scripts
Diff against target: 56 lines (+15/-4)
1 file modified
lava-create-master (+15/-4)
To merge this branch: bzr merge lp:~liuyq0307/lava-master-image-scripts/use-kpartx
Reviewer Review Type Date Requested Status
Spring Zhang (community) Approve
Review via email: mp+111133@code.launchpad.net

Description of the change

change to use kpartx instead of partx to map the partitions of image file to kernel

To post a comment you must log in.
Revision history for this message
Spring Zhang (qzhang) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lava-create-master'
2--- lava-create-master 2012-05-16 13:05:26 +0000
3+++ lava-create-master 2012-06-20 02:02:19 +0000
4@@ -48,6 +48,9 @@
5 precise)
6 export LAVA_SUPPORTED=1
7 ;;
8+ natty)
9+ export LAVA_SUPPORTED=1
10+ ;;
11 esac
12 ;;
13 esac
14@@ -253,7 +256,7 @@
15 if [ -n "$LOOP_DEV" ]; then
16 # Remove loopback partitions
17 verbose " * Removing loopback device partitions..."
18- partx --delete $LOOP_DEV
19+ kpartx -d $LOOP_DEV
20 # Detach loopback device
21 verbose " * Detaching loopback device..."
22 losetup --detach $LOOP_DEV
23@@ -276,6 +279,13 @@
24
25
26 make_master() {
27+ if [ -z "$(which kpartx)" ]; then
28+ sudo apt-get -y install kpartx
29+ if [ $? -ne 0 ]; then
30+ echo "Failed to install kpartx" >&2
31+ exit 1
32+ fi
33+ fi
34 # Cleanup on exit
35 trap cleanup EXIT
36
37@@ -371,15 +381,16 @@
38
39 # Add partition devices
40 verbose " * Adding partitions to the loopback device..."
41- partx --add $LOOP_DEV
42-
43+ kpartx -av $LOOP_DEV
44+
45 # Get a mount point for master image
46 verbose " * Creating temporary mount point for rootfs..."
47 MASTER_MNT=$(mktemp --directory --suffix .lava.$dev.master)
48
49 # Mount the root filesystem
50 verbose " * Mounting rootfs..."
51- mount ${LOOP_DEV}p${ROOTFS_PARTITION} $MASTER_MNT
52+ LOOP_NAME=`basename ${LOOP_DEV}`
53+ mount /dev/mapper/${LOOP_NAME}p${ROOTFS_PARTITION} $MASTER_MNT
54
55 # Update hostname to 'master'
56 verbose " * Changing hostname to 'master'..."

Subscribers

People subscribed via source and target branches