All of lore.kernel.org
 help / color / mirror / Atom feed
From: Saul Wold <sgw@linux.intel.com>
To: "Robert P. J. Day" <rpjday@crashcourse.ca>
Cc: "yocto@yoctoproject.org" <yocto@yoctoproject.org>,
	Darren Hart <dvhart@linux.intel.com>
Subject: Re: per-image ROOTFS sizes
Date: Wed, 12 Dec 2012 23:55:32 -0800	[thread overview]
Message-ID: <50C989F4.90004@linux.intel.com> (raw)
In-Reply-To: <alpine.DEB.2.02.1212121756210.30220@oneiric>

On 12/12/2012 03:16 PM, Robert P. J. Day wrote:
> On Wed, 12 Dec 2012, Trevor Woerner wrote:
>
>> On Wed, Dec 12, 2012 at 3:46 PM, Robert P. J. Day <rpjday@crashcourse.ca> wrote:
>>> so what happens if you try to set the appropriate variables above?
>>
>> When Yocto creates a VMDK, it creates 2 partitions:
>> - an MSDOS partition for the syslinux stuff
>> - the ext{3,4} partition of your root image
>>
>> When it then shmushes these two together into 1 file, it has to make
>> sure all the sizes are set correctly as per the information in the
>> disk's partition table. That's what all these calculations are doing
>> (I recognize it from similar work in my own scripts).
>>
>> Personally I have my own approach that can use either LILO or syslinux
>> for booting x86 (it can also create bootable ARM images with the
>> appropriate uboot/mlo); neither of the x86 solutions require a
>> separate MSDOS partition. Hopefully I'll find some time to examine how
>> Yocto is doing things and perhaps integrate my own findings into the
>> broader project(?).
>>
>> (please see https://github.com/twoerner/qemu-image-builder)
>>
>> I believe Yocto calculates the sizes (using IMAGE_ROOTFS_SIZE) from
>> code in poky/meta/classes/image_types.bbclass, which is also run for
>> the VMDK's calculations too.
>
>    and here's where i'm confused.  i'm *assuming* that the
> image-vmdk.bbclass file defines the creation of vmdk images, yes?  but
> that class file inherits directly only boot-directdisk.bbclass, and if
> i look in that class file, i don't see any further inherits that might
> process IMAGE_ROOTFS_SIZE.  i just see hardcoded calculations that
> build an image based on actual rootfs directory size.
>
>    so what am i missing?
>
Some serious magic!  It took me a while to reload my cache on this one.

All strapped in because here we go!

So you have selected the types of images you want to build by add it's 
type to IMAGE_FSTYPES, of which you can have multiple types.

When the do_rootfs() is run for an image, there is a call into 
image_types.bbclass via the ${@get_imagecmds(d)}, which returns a list 
of cmds to execute to create the various images selected via the above 
IMAGE_FSTYPES.  Of note here is that if vmdk or live is select, but not 
ext3 (soon to be ext4 we hope), then ext3 will be added to the types 
list, and vmdk and/or live will be removed.

in the get_imagecmds code, you can see that the OVERRIDES are updated 
locally to include the filesystem type, so that correct IMAGE_CMD can be 
selected via overrides and set into $cmd while the compressed version is 
set to $ccmd, then the runimagecmd is added to the cmds list (different 
than cmd, yes a little confusing).

runimagecmd is here the size computation occurs and the IMAGE_CMD is run 
via $cmd. Since we are not out side the get_imagecmds() context and do 
not have the localdata that set filesystem type overrides we won't seem 
them and beside runimagecmd will never get called for a vmdk or live 
image type! The underlying filesystem for those is the ext3 fs type.

Now that the rootfs has been created in the correct fs type (ext3) it 
mething to the TOTALSIZE and END3 computations in this code 
fragment:needs to be converted to vmdk, this is done via the 
image-vmdk.bbclass which is optionally inherited in image.bbclass.  This 
class slips the do_vmdkimg() function after do_bootdirectdisk, which is 
needed to get the right disk leve partitioning. The image-vmdk.bbclass 
inherits boot-directdisk.bbclass to get it incorporated correctly.  This 
is where Trevor correctly noted that that we are doing the multiple 
partition approach.

SO we cycle back to the initial question which is how to have 2 
different sizes for ext3 vanilla images vs a fixed size for the vmdk, 
right now that's really hard! Since we create an ext3 (4) for including 
mething to the TOTALSIZE and END3 computations in this code 
fragment:into the vmdk, that's where the sizing occurs.

What I think you are asking for is create a default sized ext3 and then 
allow the partition to be resized in the boot-directdisk partitioning 
code, since that's where the extra space would get accounted for.

Possibly we could add something to the TOTALSIZE and END3 computations 
in this code fragment:

         ROOTFSBLOCKS=`du -Lbks ${ROOTFS} | cut -f 1`
         TOTALSIZE=`expr $BLOCKS + $ROOTFSBLOCKS`
         END1=`expr $BLOCKS \* 1024`
         END2=`expr $END1 + 512`
         END3=`expr \( $ROOTFSBLOCKS \* 1024 \) + $END1`

That code feeds into the parted command, the dd that happens after that 
would have to change since we are dd'ing a ext3 and it does not know it 
has more space, this is the tricky part!  More thought is required, 
maybe a single malt (yes I was jealous).

Anyway, I hope have I not thoroughly confused everyone at this point.


Sau!



> rday
>


  reply	other threads:[~2012-12-13  7:55 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-11 21:05 per-image ROOTFS sizes Trevor Woerner
2012-12-12 19:59 ` Darren Hart
2012-12-12 20:14   ` Trevor Woerner
2012-12-12 20:19     ` Darren Hart
2012-12-12 21:28       ` Trevor Woerner
2012-12-12 20:46     ` Robert P. J. Day
2012-12-12 21:56       ` Trevor Woerner
2012-12-12 22:03         ` Robert P. J. Day
2012-12-12 22:55           ` Trevor Woerner
2012-12-12 23:18             ` Robert P. J. Day
2012-12-12 23:16         ` Robert P. J. Day
2012-12-13  7:55           ` Saul Wold [this message]
2012-12-13 13:03             ` Robert P. J. Day
2012-12-13 17:42               ` Saul Wold
2012-12-13 19:14                 ` Robert P. J. Day

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=50C989F4.90004@linux.intel.com \
    --to=sgw@linux.intel.com \
    --cc=dvhart@linux.intel.com \
    --cc=rpjday@crashcourse.ca \
    --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.