From: Jonathan Liu <net147@gmail.com>
To: openembedded-core@lists.openembedded.org
Subject: [PATCH] boot-directdisk: mount root by MBR disk signature for Linux 3.8+
Date: Thu, 23 May 2013 14:31:54 +1000 [thread overview]
Message-ID: <1369283514-8837-1-git-send-email-net147@gmail.com> (raw)
Signed-off-by: Jonathan Liu <net147@gmail.com>
---
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
next reply other threads:[~2013-05-23 4:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-23 4:31 Jonathan Liu [this message]
2013-06-07 23:28 ` [PATCH] boot-directdisk: mount root by MBR disk signature for Linux 3.8+ Darren Hart
2013-06-08 13:03 ` Jonathan Liu
2013-06-10 16:26 ` Darren Hart
2013-07-09 13:58 ` Jonathan Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1369283514-8837-1-git-send-email-net147@gmail.com \
--to=net147@gmail.com \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox