From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pb0-f52.google.com (mail-pb0-f52.google.com [209.85.160.52]) by mail.openembedded.org (Postfix) with ESMTP id 944F16086B for ; Thu, 23 May 2013 04:18:47 +0000 (UTC) Received: by mail-pb0-f52.google.com with SMTP id um15so2436077pbc.39 for ; Wed, 22 May 2013 21:18:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer; bh=rdASTtau0GlZWQzNWzbYyeBS0cHOGOAJ/zetgL/qKsM=; b=GmftjKNciGgK16ZW4KemTA2wEYvzTM920raYUJVMhC/YP8kYwW+8P/1pyiUnAZCwrT EHqu7DQmnjlS1V0x65+M1bAtEo6l3NM/43ROeuX0YAIbo2l0GRxpSjCZcy1V/C4u6kzT ybJwyqWQbYR3n0M6OcJ0Jq2jxHSCgvT6+ntEN8ZBZ9FCBzYoX0F4fNPDXOmGzP9Qtyj3 7ohzMPOAohdLSC1UJ/0ChrQkQchfWmPM4IxOp0cqzK7e6sN8Drd0V2z7dTq3OcgXJ0C4 MkHAey5mXmtN+hfp0DUDocHthBUqno/fcI4x3w7aXJ8BZJzH+oLyUwUYR+OZv99xPO5b p12w== X-Received: by 10.66.163.38 with SMTP id yf6mr11312635pab.45.1369282728611; Wed, 22 May 2013 21:18:48 -0700 (PDT) Received: from 60-242-179-244.static.tpgi.com.au (60-242-179-244.static.tpgi.com.au. [60.242.179.244]) by mx.google.com with ESMTPSA id ra4sm10985264pab.9.2013.05.22.21.18.46 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 22 May 2013 21:18:47 -0700 (PDT) From: Jonathan Liu To: openembedded-core@lists.openembedded.org Date: Thu, 23 May 2013 14:31:54 +1000 Message-Id: <1369283514-8837-1-git-send-email-net147@gmail.com> X-Mailer: git-send-email 1.8.2.3 Subject: [PATCH] boot-directdisk: mount root by MBR disk signature for Linux 3.8+ X-BeenThere: openembedded-core@lists.openembedded.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Patches and discussions about the oe-core layer List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 May 2013 04:18:47 -0000 Signed-off-by: Jonathan Liu --- meta/classes/boot-directdisk.bbclass | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/meta/classes/boot-directdisk.bbclass b/meta/classes/boot-directdisk.bbclass index 3169043..736bee0 100644 --- a/meta/classes/boot-directdisk.bbclass +++ b/meta/classes/boot-directdisk.bbclass @@ -23,7 +23,8 @@ do_bootdirectdisk[depends] += "dosfstools-native:do_populate_sysroot \ syslinux:do_populate_sysroot \ syslinux-native:do_populate_sysroot \ parted-native:do_populate_sysroot \ - mtools-native:do_populate_sysroot " + mtools-native:do_populate_sysroot \ + util-linux-native:do_populate_sysroot " PACKAGES = " " EXCLUDE_FROM_WORLD = "1" @@ -58,6 +59,22 @@ build_boot_dd() { # done in blocks, thus the mod by 16 instead of 32. BLOCKS=$(expr $BLOCKS + $(expr 16 - $(expr $BLOCKS % 16))) + KERNEL_VERSION=$(grep '^VERSION\s*=' ${STAGING_KERNEL_DIR}/Makefile | grep -o '[0-9]*$') + KERNEL_PATCHLEVEL=$(grep '^PATCHLEVEL\s*=' ${STAGING_KERNEL_DIR}/Makefile | grep -o '[0-9]*$') + + rm -rf $IMAGE + dd if=/dev/zero of=$IMAGE bs=512 seek=1 count=0 + parted $IMAGE mklabel msdos + + # If using Linux 3.8 or later, mount root by MBR disk signature + if [[ $KERNEL_VERSION -eq 3 && $KERNEL_PATCHLEVEL -ge 8 ]] || [ $KERNEL_VERSION -gt 3 ]; then + # The disk signature generated by GNU Parted isn't really random, so regenerate it + echo -ne "$(uuidgen | sed 's/-//g;s/\(..\)/\\x&/g')" | dd of=$IMAGE bs=1 seek=440 count=4 conv=notrunc + + DISK_SIGNATURE=$(hexdump -s 440 -n 4 -e '4 1 "%02x\n" "\n"' $IMAGE | tac | paste -sd '') + sed -i "s|\broot=[^ ]*|root=PARTUUID=$DISK_SIGNATURE-02|" $HDDDIR/syslinux.cfg + fi + mkdosfs -n ${BOOTDD_VOLUME_ID} -S 512 -C $HDDIMG $BLOCKS mcopy -i $HDDIMG -s $HDDDIR/* ::/ @@ -71,10 +88,8 @@ build_boot_dd() { END3=`expr \( $ROOTFSBLOCKS \* 1024 \) + $END1` echo $ROOTFSBLOCKS $TOTALSIZE $END1 $END2 $END3 - rm -rf $IMAGE dd if=/dev/zero of=$IMAGE bs=1024 seek=$TOTALSIZE count=1 - parted $IMAGE mklabel msdos parted $IMAGE mkpart primary fat16 0 ${END1}B parted $IMAGE unit B mkpart primary ext2 ${END2}B ${END3}B parted $IMAGE set 1 boot on -- 1.8.2.3