From: Paul Eggleton <paul.eggleton@linux.intel.com>
To: Andrei Gherzan <andrei@gherzan.ro>
Cc: yocto@yoctoproject.org
Subject: Re: [PATCH] sdcard-image: Use the size of the generated rootfs
Date: Thu, 04 Apr 2013 11:37:16 +0100 [thread overview]
Message-ID: <10424141.AW7YeVNGIV@helios> (raw)
In-Reply-To: <1363208280-32663-1-git-send-email-thaytan@noraisin.net>
On Thursday 14 March 2013 07:57:59 Jan Schmidt wrote:
> When constructing the SD card image, the code was using
> the inherited ROOTFS_SIZE, which is the size of the
> rootfs contents. When building (for example) a compressed
> rootfs, this allocates a partition much larger than necessary.
>
> Instead, take the size of the generated rootfs file that is
> about to be written into the generated image, and round it
> up to the IMAGE_ROOTFS_ALIGNMENT size.
>
> Fix some comments - the alignment is 4MiB, not 4KiB.
>
> Signed-off-by: Jan Schmidt <thaytan@noraisin.net>
> ---
> classes/sdcard_image-rpi.bbclass | 30 ++++++++++++++++++------------
> 1 file changed, 18 insertions(+), 12 deletions(-)
>
> diff --git a/classes/sdcard_image-rpi.bbclass
> b/classes/sdcard_image-rpi.bbclass index 421f561..3f0a16e 100644
> --- a/classes/sdcard_image-rpi.bbclass
> +++ b/classes/sdcard_image-rpi.bbclass
> @@ -13,14 +13,14 @@ inherit image_types
> # Default Free space =
> 1.3x # Use
> IMAGE_OVERHEAD_FACTOR to add more space #
> <---------> -# 4KiB 20MiB
> SDIMG_ROOTFS
> +# 4MiB 20MiB SDIMG_ROOTFS
> # <-----------------------> <----------> <---------------------->
> -# ------------------------ ------------ ------------------------
> ------------------------------- -# | IMAGE_ROOTFS_ALIGNMENT | BOOT_SPACE |
> ROOTFS_SIZE | IMAGE_ROOTFS_ALIGNMENT | -#
> ------------------------ ------------ ------------------------
> ------------------------------- -# ^ ^ ^
> ^ ^ -# |
> | | |
> | -# 0 4096 4KiB + 20MiB 4KiB + 20Mib +
> SDIMG_ROOTFS 4KiB + 20MiB + SDIMG_ROOTFS + 4KiB +#
> ------------------------ ------------ ------------------------ +# |
> IMAGE_ROOTFS_ALIGNMENT | BOOT_SPACE | ROOTFS_SIZE | +#
> ------------------------ ------------ ------------------------ +# ^
> ^ ^ ^ +# |
> | | | +# 0
> 4MiB 4MiB + 20MiB 4MiB + 20Mib + SDIMG_ROOTFS
>
>
> # Set kernel and boot loader
> @@ -29,7 +29,7 @@ IMAGE_BOOTLOADER ?= "bcm2835-bootfiles"
> # Boot partition volume id
> BOOTDD_VOLUME_ID ?= "${MACHINE}"
>
> -# Boot partition size [in KiB]
> +# Boot partition size [in KiB] (will be rounded up to
> IMAGE_ROOTFS_ALIGNMENT) BOOT_SPACE ?= "20480"
>
> # Set alignment to 4MB [in KiB]
> @@ -60,18 +60,24 @@ IMAGE_CMD_rpi-sdimg () {
> # Align partitions
> BOOT_SPACE_ALIGNED=$(expr ${BOOT_SPACE} + ${IMAGE_ROOTFS_ALIGNMENT} - 1)
> BOOT_SPACE_ALIGNED=$(expr ${BOOT_SPACE_ALIGNED} - ${BOOT_SPACE_ALIGNED} %
> ${IMAGE_ROOTFS_ALIGNMENT}) - SDIMG_SIZE=$(expr ${IMAGE_ROOTFS_ALIGNMENT} +
> ${BOOT_SPACE_ALIGNED} + $ROOTFS_SIZE + ${IMAGE_ROOTFS_ALIGNMENT})
> + ROOTFS_SIZE=`du -bks ${SDIMG_ROOTFS} | awk '{print $1}'`
> + # Round up RootFS size to the alignment size as well
> + ROOTFS_SIZE_ALIGNED=$(expr ${ROOTFS_SIZE} + ${IMAGE_ROOTFS_ALIGNMENT} - 1)
> + ROOTFS_SIZE_ALIGNED=$(expr ${ROOTFS_SIZE_ALIGNED} -
> ${ROOTFS_SIZE_ALIGNED} % ${IMAGE_ROOTFS_ALIGNMENT}) + SDIMG_SIZE=$(expr
> ${IMAGE_ROOTFS_ALIGNMENT} + ${BOOT_SPACE_ALIGNED} + ${ROOTFS_SIZE_ALIGNED})
> +
> + echo "Creating filesystem with Boot partition ${BOOT_SPACE_ALIGNED} KiB
> and RootFS ${ROOTFS_SIZE_ALIGNED} KiB"
>
> # Initialize sdcard image file
> - dd if=/dev/zero of=${SDIMG} bs=1 count=0 seek=$(expr 1024 \*
> ${SDIMG_SIZE}) + dd if=/dev/zero of=${SDIMG} bs=1024 count=0
> seek=${SDIMG_SIZE}
>
> # Create partition table
> parted -s ${SDIMG} mklabel msdos
> # Create boot partition and mark it as bootable
> parted -s ${SDIMG} unit KiB mkpart primary fat32
${IMAGE_ROOTFS_ALIGNMENT}
> $(expr ${BOOT_SPACE_ALIGNED} \+ ${IMAGE_ROOTFS_ALIGNMENT}) parted -s
> ${SDIMG} set 1 boot on
> - # Create rootfs partition
> - parted -s ${SDIMG} unit KiB mkpart primary ext2 $(expr
> ${BOOT_SPACE_ALIGNED} \+ ${IMAGE_ROOTFS_ALIGNMENT}) $(expr
> ${BOOT_SPACE_ALIGNED} \+ ${IMAGE_ROOTFS_ALIGNMENT} \+ ${ROOTFS_SIZE}) + #
> Create rootfs partition to the end of disk
> + parted -s ${SDIMG} -- unit KiB mkpart primary ext2 $(expr
> ${BOOT_SPACE_ALIGNED} \+ ${IMAGE_ROOTFS_ALIGNMENT}) -1s parted ${SDIMG}
> print
>
> # Create a vfat image with boot files
Looks like this is a patch for meta-raspberrypi although it isn't marked as
such. Andrei, have you seen this?
Cheers,
Paul
--
Paul Eggleton
Intel Open Source Technology Centre
next prev parent reply other threads:[~2013-04-04 10:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-13 20:57 [PATCH] sdcard-image: Use the size of the generated rootfs Jan Schmidt
2013-04-04 10:37 ` Paul Eggleton [this message]
2013-04-04 10:43 ` Jan Schmidt
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=10424141.AW7YeVNGIV@helios \
--to=paul.eggleton@linux.intel.com \
--cc=andrei@gherzan.ro \
--cc=yocto@yoctoproject.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.