Skip to contentSkip to conversation

Auto resizing ext2/ext3 images (from Poky)

PATCH Koen Kooi 4 participants 5 messages Dec 5, 2008 – Jan 20, 2009 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Koen Kooi

author
#1 lore raw
Quoted 9 lines · Marcin Juszkiewicz

During my work for OpenedHand I wrote one usefull thing which we used for ext2/ext3 images - autosizing.

In few words: it checks how big rootfs is, adds IMAGE_EXTRA_SPACE amount of kilobytes to it and gives that size to genext2fs.

Below is a patch with code changes. Check it and say what You think about it. One thing is missing - support for fixed size ext2/3 images big enough to fit resulting rootfs.

Looks good to me.

regards,

Koen

Quoted 36 lines
classes/image.bbclass +1 -0
index e9c0ecd..901ab34 100644
@@ -107,6 +107,7 @@ fakeroot do_rootfs () {
 
  	${IMAGE_PREPROCESS_COMMAND}
 
+	ROOTFS_SIZE=`du -ks ${IMAGE_ROOTFS}|awk '{print ${IMAGE_EXTRA_SPACE} + $1}'`
  	${@get_imagecmds(d)}
 
  	${IMAGE_POSTPROCESS_COMMAND}
conf/bitbake.conf +1 -1
index 8a754fd..159f17f 100644
@@ -302,9 +302,9 @@ IMAGE_CMD = ""
  IMAGE_CMD_jffs2 = "mkfs.jffs2 -x lzo --root=${IMAGE_ROOTFS} --faketime --output=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.jffs2 ${EXTRA_IMAGECMD}"
  IMAGE_CMD_yaffs2 = "mkyaffs2image ${EXTRA_IMAGECMD} ${IMAGE_ROOTFS} ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.yaffs2"
  IMAGE_CMD_cramfs = "mkcramfs ${IMAGE_ROOTFS} ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.cramfs ${EXTRA_IMAGECMD}"
-IMAGE_CMD_ext2 = "genext2fs -b ${IMAGE_ROOTFS_SIZE} -d ${IMAGE_ROOTFS} ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.ext2 ${EXTRA_IMAGECMD}"
+IMAGE_CMD_ext2 = "genext2fs -b ${ROOTFS_SIZE} -d ${IMAGE_ROOTFS} ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.ext2 ${EXTRA_IMAGECMD}"
  IMAGE_CMD_ext2.gz = "rm -rf ${DEPLOY_DIR_IMAGE}/tmp.gz&&  mkdir ${DEPLOY_DIR_IMAGE}/tmp.gz; genext2fs -b ${IMAGE_ROOTFS_SIZE} -d ${IMAGE_ROOTFS}

${DEPLOY_DIR_IMAGE}/tmp.gz/${IMAGE_NAME}.rootfs.ext2 ${EXTRA_IMAGECMD}; gzip -f -9 ${DEPLOY_DIR_IMAGE}/tmp.gz/${IMAGE_NAME}.rootfs.ext2; mv ${DEPLOY_DIR_IMAGE}/tmp.gz/${IMAGE_NAME}.rootfs.ext2.gz ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.ext2.gz; rmdir ${DEPLOY_DIR_IMAGE}/tmp.gz" -IMAGE_CMD_ext3 = "genext2fs -b ${IMAGE_ROOTFS_SIZE} -d ${IMAGE_ROOTFS} ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.ext3 ${EXTRA_IMAGECMD}; tune2fs -j ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.ext3"
+IMAGE_CMD_ext3 = "genext2fs -b ${ROOTFS_SIZE} -d ${IMAGE_ROOTFS} ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.ext3 ${EXTRA_IMAGECMD}; tune2fs -j ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.ext3"
IMAGE_CMD_ext3.gz = "rm -rf ${DEPLOY_DIR_IMAGE}/tmp.gz&& mkdir ${DEPLOY_DIR_IMAGE}/tmp.gz; genext2fs -b ${IMAGE_ROOTFS_SIZE} -d ${IMAGE_ROOTFS}
${DEPLOY_DIR_IMAGE}/tmp.gz/${IMAGE_NAME}.rootfs.ext3 ${EXTRA_IMAGECMD}; tune2fs -j ${DEPLOY_DIR_IMAGE}/tmp.gz/${IMAGE_NAME}.rootfs.ext3; gzip -f -9 ${DEPLOY_DIR_IMAGE}/tmp.gz/${IMAGE_NAME}.rootfs.ext3; mv ${DEPLOY_DIR_IMAGE}/tmp.gz/${IMAGE_NAME}.rootfs.ext3.gz ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.ext3.gz; rmdir ${DEPLOY_DIR_IMAGE}/tmp.gz"
IMAGE_CMD_squashfs = "mksquashfs ${IMAGE_ROOTFS} ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.squashfs ${EXTRA_IMAGECMD} -noappend" IMAGE_CMD_squashfs-lzma = "mksquashfs-lzma ${IMAGE_ROOTFS} ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.squashfs-lzma ${EXTRA_IMAGECMD} -noappend"

#2 lore raw
In reply to a message not in the archive
Quoted 3 lines · Marcin Juszkiewicz

During my work for OpenedHand I wrote one usefull thing which we used for ext2/ext3 images - autosizing.

Great! I often face this issue of not fitting everything in a predefined image size. This patch should be very helpful!

Quoted 12 lines

In few words: it checks how big rootfs is, adds IMAGE_EXTRA_SPACE amount of kilobytes to it and gives that size to genext2fs.

Below is a patch with code changes. Check it and say what You think about it. One thing is missing - support for fixed size ext2/3 images big enough to fit resulting rootfs.

classes/image.bbclass +0 -0
index e9c0ecd..901ab34 100644

classes/image.bbclass fakeroot do_rootfs () { · line 110

Quoted 4 lines
classes/image.bbclass +1 -0
@@ -107,6 +107,7 @@ fakeroot do_rootfs () {
 
 	${IMAGE_PREPROCESS_COMMAND}
 
+	ROOTFS_SIZE=`du -ks ${IMAGE_ROOTFS}|awk '{print ${IMAGE_EXTRA_SPACE} + $1}'`

Can it be done like this:

ROOTFS_SIZE=`du -ks ${IMAGE_ROOTFS}|awk '{size = ${IMAGE_EXTRA_SPACE} + $1; \
print (size > ${IMAGE_ROOTFS_SIZE} ? size : ${IMAGE_ROOTFS_SIZE}) }'`

Quoted 3 lines
classes/image.bbclass +0 -0
 	${@get_imagecmds(d)}
 
 	${IMAGE_POSTPROCESS_COMMAND}
Signature · 1 line
Denys
#3 lore raw
Quoted 8 lines · On Friday 05 of December 2008 18:48:06 Denys Dmytriyenko wrote:
Quoted 6 lines · Marcin Juszkiewicz

In few words: it checks how big rootfs is, adds IMAGE_EXTRA_SPACE amount of kilobytes to it and gives that size to genext2fs.

Below is a patch with code changes. Check it and say what You think about it. One thing is missing - support for fixed size ext2/3 images big enough to fit resulting rootfs.

Quoted 5 lines

Can it be done like this:

ROOTFS_SIZE=`du -ks ${IMAGE_ROOTFS}|awk '{size = ${IMAGE_EXTRA_SPACE}
+ $1; \ print (size > ${IMAGE_ROOTFS_SIZE} ? size :
${IMAGE_ROOTFS_SIZE}) }'`

Yes, it can - I pushed my patch and your code went too (as separate commit).

Regards,

Signature · 3 lines
JID:      [email protected]
Website:  http://marcin.juszkiewicz.com.pl/
LinkedIn: http://www.linkedin.com/in/marcinjuszkiewicz
#4 lore raw
Quoted 9 lines · Marcin Juszkiewicz
Quoted 7 lines · On Friday 05 of December 2008 18:48:06 Denys Dmytriyenko wrote:
Quoted 6 lines · Marcin Juszkiewicz

In few words: it checks how big rootfs is, adds IMAGE_EXTRA_SPACE amount of kilobytes to it and gives that size to genext2fs.

Below is a patch with code changes. Check it and say what You think about it. One thing is missing - support for fixed size ext2/3 images big enough to fit resulting rootfs.

Quoted 8 lines
Quoted 5 lines

Can it be done like this:

ROOTFS_SIZE=`du -ks ${IMAGE_ROOTFS}|awk '{size = ${IMAGE_EXTRA_SPACE}
+ $1; \ print (size > ${IMAGE_ROOTFS_SIZE} ? size :
${IMAGE_ROOTFS_SIZE}) }'`

Yes, it can - I pushed my patch and your code went too (as separate commit).

Thanks. I wonder why it can't be also applied to ext2.gz and ext3.gz images.

Signature · 1 line
Denys
#5 lore raw
Quoted 12 lines · Denys Dmytriyenko
Quoted 11 lines · Marcin Juszkiewicz
Quoted 10 lines · On Friday 05 of December 2008 18:48:06 Denys Dmytriyenko wrote:
Quoted 6 lines · Marcin Juszkiewicz

In few words: it checks how big rootfs is, adds IMAGE_EXTRA_SPACE amount of kilobytes to it and gives that size to genext2fs.

Below is a patch with code changes. Check it and say what You think about it. One thing is missing - support for fixed size ext2/3 images big enough to fit resulting rootfs.

Can it be done like this:

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

ROOTFS_SIZE=`du -ks ${IMAGE_ROOTFS}|awk '{size = ${IMAGE_EXTRA_SPACE}
+ $1; \ print (size > ${IMAGE_ROOTFS_SIZE} ? size :
${IMAGE_ROOTFS_SIZE}) }'`

Yes, it can - I pushed my patch and your code went too (as separate commit).

Thanks. I wonder why it can't be also applied to ext2.gz and ext3.gz images.

Tangentally, is there a reason we can't have:
IMAGE_CMD_ext2 = "...."
IMAGE_CMD_ext2.gz = "${IMAGE_CMD_ext2} ; gzip ..." ?

Signature · 1 line
Tom Rini