summaryrefslogtreecommitdiffstats
path: root/scripts/contrib
diff options
context:
space:
mode:
authorJason Wessel <jason.wessel@windriver.com>2013-09-27 01:01:20 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-09-30 22:11:58 +0100
commitcf2ebed2ff3e498b399a40d4dfba91d62d0a758b (patch)
treebed5bba6b9ef7fd5f08afcb3fe7a0cd77f8c1e0b /scripts/contrib
parent072c4e123f878d57fb7f767d3888b38461f91a27 (diff)
downloadpoky-cf2ebed2ff3e498b399a40d4dfba91d62d0a758b.tar.gz
mkefidisk.sh: Allow using a loopback mounted file
It should be possible to generate a disk to a file using a loopback device with mkefidisk.sh, which is useful for booting simulators. To make this possible the partitions for the loop back need to work similarly to the mmc devices. The mkfs.vfat also requires and additional argument to force it to write to something other then a real disk. Example: qemu-img create -f raw bigdisk 4G dev=`sudo losetup -f` sudo losetup $dev bigdisk mkefidisk.sh $dev tmp-eglibc/deploy/images/qemux86/core-image-minimal-qemux86.hddimg /dev/sda sudo losetup -d $dev Note: Also a bug was fixed in the mkefidisk.sh where if the disk you are writing to initially has an invalid label the size of the first partition will be computed incorrectly. For the simulator disk creation this is generally always the case, but this can happen with real hardware as well. (From OE-Core rev: 254899824900f2e8c6a34d2ad1b8cbea91acb4ae) Signed-off-by: Jason Wessel <jason.wessel@windriver.com> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/contrib')
-rwxr-xr-xscripts/contrib/mkefidisk.sh14
1 files changed, 12 insertions, 2 deletions
diff --git a/scripts/contrib/mkefidisk.sh b/scripts/contrib/mkefidisk.sh
index af06b4bd5b..c86849d395 100755
--- a/scripts/contrib/mkefidisk.sh
+++ b/scripts/contrib/mkefidisk.sh
@@ -134,6 +134,11 @@ fi
134# Partition $DEVICE 134# Partition $DEVICE
135# 135#
136DEVICE_SIZE=$(parted $DEVICE unit mb print | grep ^Disk | cut -d" " -f 3 | sed -e "s/MB//") 136DEVICE_SIZE=$(parted $DEVICE unit mb print | grep ^Disk | cut -d" " -f 3 | sed -e "s/MB//")
137# If the device size is not reported there may not be a valid label
138if [ "$DEVICE_SIZE" = "" ] ; then
139 parted $DEVICE mklabel msdos
140 DEVICE_SIZE=$(parted $DEVICE unit mb print | grep ^Disk | cut -d" " -f 3 | sed -e "s/MB//")
141fi
137SWAP_SIZE=$((DEVICE_SIZE*SWAP_RATIO/100)) 142SWAP_SIZE=$((DEVICE_SIZE*SWAP_RATIO/100))
138ROOTFS_SIZE=$((DEVICE_SIZE-BOOT_SIZE-SWAP_SIZE)) 143ROOTFS_SIZE=$((DEVICE_SIZE-BOOT_SIZE-SWAP_SIZE))
139ROOTFS_START=$((BOOT_SIZE)) 144ROOTFS_START=$((BOOT_SIZE))
@@ -142,7 +147,7 @@ SWAP_START=$((ROOTFS_END))
142 147
143# MMC devices use a partition prefix character 'p' 148# MMC devices use a partition prefix character 'p'
144PART_PREFIX="" 149PART_PREFIX=""
145if [ ! "${DEVICE#/dev/mmcblk}" = "${DEVICE}" ]; then 150if [ ! "${DEVICE#/dev/mmcblk}" = "${DEVICE}" ] || [ ! "${DEVICE#/dev/loop}" = "${DEVICE}" ]; then
146 PART_PREFIX="p" 151 PART_PREFIX="p"
147fi 152fi
148BOOTFS=$DEVICE${PART_PREFIX}1 153BOOTFS=$DEVICE${PART_PREFIX}1
@@ -197,7 +202,12 @@ unmount_device
197# 202#
198echo "" 203echo ""
199echo "Formatting $BOOTFS as vfat..." 204echo "Formatting $BOOTFS as vfat..."
200mkfs.vfat $BOOTFS -n "efi" 205if [ ! "${DEVICE#/dev/loop}" = "${DEVICE}" ]; then
206 mkfs.vfat -I $BOOTFS -n "efi"
207else
208 mkfs.vfat $BOOTFS -n "efi"
209
210fi
201 211
202echo "Formatting $ROOTFS as ext3..." 212echo "Formatting $ROOTFS as ext3..."
203mkfs.ext3 $ROOTFS -L "root" 213mkfs.ext3 $ROOTFS -L "root"