fs/ext2: Remove support for auto-calculation of rootfs size
PATCH 1/4 fs/ext2: Remove support for auto-calculation of rootfs size
Auto-calculation of the rootfs size cannot be done in a reliable way as it depends on the host filesystem and is broken on non ext4 host. [1] [2] So let the user specify the size he wants for his rootfs.
[1] https://bugs.busybox.net/show_bug.cgi?id=8831
[2] https://bugs.busybox.net/show_bug.cgi?id=9496
--- Config.in.legacy | 14 ++++++++++++++ fs/ext2/Config.in | 12 ++---------- fs/ext2/ext2.mk | 1 - package/mke2img/mke2img | 20 +------------------- 4 files changed, 17 insertions(+), 30 deletions(-)
Config.in.legacy +14 -0
@@ -145,6 +145,20 @@ endif ############################################################################### comment "Legacy options removed in 2017.05" +config BR2_TARGET_ROOTFS_EXT2_EXTRA_BLOCKS + int "extra size in blocks has been removed" + default 0 + help + Since the support for auto calculation of the filesystem size has been + removed, this option is now useless and must be 0. + You may want to check that BR2_TARGET_ROOTFS_EXT2_BLOCKS matchs + your needs. + +config BR2_TARGET_ROOTFS_EXT2_EXTRA_BLOCKS_WRAP + bool + default y if BR2_TARGET_ROOTFS_EXT2_EXTRA_BLOCKS != 0 + select BR2_LEGACY + config BR2_PACKAGE_SYSTEMD_KDBUS bool "systemd-kdbus has been removed" select BR2_LEGACY
fs/ext2/Config.in +2 -10
@@ -45,21 +45,13 @@ config BR2_TARGET_ROOTFS_EXT2_LABEL string "filesystem label" config BR2_TARGET_ROOTFS_EXT2_BLOCKS - int "exact size in blocks (leave at 0 for auto calculation)" - default 0 + int "exact size in blocks" + default 65536 config BR2_TARGET_ROOTFS_EXT2_INODES int "exact number of inodes (leave at 0 for auto calculation)" default 0 -config BR2_TARGET_ROOTFS_EXT2_EXTRA_BLOCKS - int "extra size in blocks" if BR2_TARGET_ROOTFS_EXT2_BLOCKS = 0 - default 0 - help - Enter here the number of extra blocks of free space you - want on your filesystem. By default, Buildroot will not - leave much space free. - config BR2_TARGET_ROOTFS_EXT2_EXTRA_INODES int "extra inodes" if BR2_TARGET_ROOTFS_EXT2_INODES = 0 default 0
fs/ext2/ext2.mk +0 -1
@@ -9,7 +9,6 @@ EXT2_OPTS = -G $(BR2_TARGET_ROOTFS_EXT2_GEN) -R $(BR2_TARGET_ROOTFS_EXT2_REV) ifneq ($(strip $(BR2_TARGET_ROOTFS_EXT2_BLOCKS)),0) EXT2_OPTS += -b $(BR2_TARGET_ROOTFS_EXT2_BLOCKS) endif -EXT2_OPTS += -B $(BR2_TARGET_ROOTFS_EXT2_EXTRA_BLOCKS) ifneq ($(strip $(BR2_TARGET_ROOTFS_EXT2_INODES)),0) EXT2_OPTS += -i $(BR2_TARGET_ROOTFS_EXT2_INODES)
package/mke2img/mke2img +1 -19
@@ -17,14 +17,12 @@ main() { # Default values gen=2 rev=1 - nb_extra_blocks=0 nb_extra_inodes=0 - while getopts :hb:B:i:I:r:d:o:G:R:l:u: OPT; do + while getopts :hb:i:I:r:d:o:G:R:l:u: OPT; do case "${OPT}" in h) help; exit 0;; b) nb_blocks=${OPTARG};; - B) nb_extra_blocks=${OPTARG};; i) nb_inodes=${OPTARG};; I) nb_extra_inodes=${OPTARG};; r) nb_res_blocks=${OPTARG};;
@@ -64,22 +62,6 @@ main() { fi nb_inodes=$((nb_inodes+nb_extra_inodes)) - # calculate needed blocks - if [ -z "${nb_blocks}" ]; then - # size ~= superblock, block+inode bitmaps, inodes (8 per block), - # blocks; we scale inodes / blocks with 10% to compensate for - # bitmaps size + slack - nb_blocks=$(du -s -k "${root_dir}" |sed -r -e 's/[[:space:]]+.*$//') - nb_blocks=$((500+(nb_blocks+nb_inodes/8)*11/10)) - if [ ${gen} -ge 3 ]; then - # we add 1300 blocks (a bit more than 1 MiB, assuming 1KiB blocks) - # for the journal - # Note: I came to 1300 blocks after trial-and-error checks. YMMV. - nb_blocks=$((nb_blocks+1300)) - fi - fi - nb_blocks=$((nb_blocks+nb_extra_blocks)) - # Upgrade to rev1 if needed if [ ${rev} -ge 1 ]; then tune2fs_O_opts+=",filetype,sparse_super"
Signature · 1 line
2.7.3
PATCH 2/4 package/mke2img: use mkfs to generate rootfs image
mkfs is now capable of generating rootfs images. Use mkfs intead of genext2fs. Use the default mkfs' options but disable 64bit flag as it's incompatible with older version of U-Boot.
--- fs/ext2/Config.in | 2 +- package/mke2img/Config.in.host | 1 - package/mke2img/mke2img | 80 +++++++++--------------------------------- package/mke2img/mke2img.mk | 2 +- 4 files changed, 18 insertions(+), 67 deletions(-)
fs/ext2/Config.in +1 -1
@@ -45,7 +45,7 @@ config BR2_TARGET_ROOTFS_EXT2_LABEL string "filesystem label" config BR2_TARGET_ROOTFS_EXT2_BLOCKS - int "exact size in blocks" + int "exact size in KB" default 65536 config BR2_TARGET_ROOTFS_EXT2_INODES
package/mke2img/Config.in.host +0 -1
@@ -1,7 +1,6 @@ config BR2_PACKAGE_HOST_MKE2IMG bool "host mke2img" select BR2_PACKAGE_HOST_E2FSPROGS - select BR2_PACKAGE_HOST_GENEXT2FS help Easily create filesystems of the extend familly: ext2/3/4.
package/mke2img/mke2img +16 -64
105 lines not on this page · raw message
package/mke2img/mke2img.mk +1 -1
@@ -4,7 +4,7 @@ # ################################################################################ -HOST_MKE2IMG_DEPENDENCIES = host-genext2fs host-e2fsprogs +HOST_MKE2IMG_DEPENDENCIES = host-e2fsprogs define HOST_MKE2IMG_INSTALL_CMDS $(INSTALL) -D -m 0755 package/mke2img/mke2img $(HOST_DIR)/usr/bin/mke2img
Signature · 1 line
2.7.3
PATCH 2/4 package/mke2img: use mkfs to generate rootfs image
Quoted 6 lines · S?bastien Szymanski
mkfs is now capable of generating rootfs images. Use mkfs intead of genext2fs. Use the default mkfs' options but disable 64bit flag as it's incompatible with older version of U-Boot.
Signed-off-by S?bastien Szymanski <[email protected]>---
[snip]
Quoted 26 lines
package/mke2img/mke2img +2
-9@@ -10,9 +10,8 @@ set -e main() { local OPT OPTARG local nb_blocks nb_inodes nb_res_blocks root_dir image gen rev label uuid - local -a genext2fs_opts - local -a tune2fs_opts - local tune2fs_O_opts + local -a mkfs_opts + local mkfs_O_opts # Default values gen=2@@ -62,80 +61,33 @@ main() { fi nb_inodes=$((nb_inodes+nb_extra_inodes)) - # Upgrade to rev1 if needed - if [ ${rev} -ge 1 ]; then - tune2fs_O_opts+=",filetype,sparse_super" - fi - - # Add a journal for ext3 and above
package/mke2img/mke2img main() { · line 65
Quoted 10 lines
package/mke2img/mke2img +2
-8- if [ ${gen} -ge 3 ]; then - tune2fs_opts+=( -j -J size=1 ) - fi - - # Add ext4 specific features - if [ ${gen} -ge 4 ]; then - tune2fs_O_opts+=",extents,uninit_bg,dir_index" - fi + # Disable 64bit flag as it's incompatible with older U-Boot versions + mkfs_O_opts+=",^64bit"
This is a bit unfortunate. Actually, reading the man page, it shouldn't even be
needed: if the filesystem is less than 4TB, then mke2fs will not use 64bit. And if it's larger than 4TB, you just can't create it without the 64bit option...
package/mke2img/mke2img main() { · line 69
Quoted 6 lines
package/mke2img/mke2img +2
-2# Add our -O options (there will be at most one leading comma, remove it) - if [ -n "${tune2fs_O_opts}" ]; then - tune2fs_opts+=( -O "${tune2fs_O_opts#,}" ) + if [ -n "${mkfs_O_opts}" ]; then + mkfs_opts+=( -O "${mkfs_O_opts#,}" )
Since now the ^64bit is the only -O option, and it's always there, you can just
use an unconditional
mkfs_opts+=( -O ^64bit )
Quoted 15 lines
package/mke2img/mke2img +1
-8fi # Add the label if specified if [ -n "${label}" ]; then - tune2fs_opts+=( -L "${label}" ) + mkfs_opts+=( -L "${label}" ) fi - # Generate the filesystem - genext2fs_opts=( -z -b ${nb_blocks} -N ${nb_inodes} -d "${root_dir}" ) - if [ -n "${nb_res_blocks}" ]; then - genext2fs_opts+=( -m ${nb_res_blocks} ) - fi - genext2fs "${genext2fs_opts[@]}" "${image}" -
package/mke2img/mke2img main() { · line 80
Quoted 10 lines
package/mke2img/mke2img +1
-6- # genext2fs does not generate a UUID, but fsck will whine if one - # is missing, so we need to add a UUID. - # Of course, this has to happen _before_ we run fsck. - # Also, some ext4 metadata are based on the UUID, so we must - # set it before we can convert the filesystem to ext4. - # If the user did not specify a UUID, we generate a random one. + # If the user did not specify a UUID, mkfs will generate a random one. # Although a random UUID may seem bad for reproducibility, there # already are so many things that are not reproducible in a # filesystem: file dates, file ordering, content of the files...
Hm, this becomes less and less true... With BR2_REPRODUCIBLE, the file dates
and content should be fixed. So if only we can also fix the ordering, then the ext2 could also be reproducible... But that's not for this patch of course.
Quoted 27 lines
package/mke2img/mke2img +2
-23- tune2fs -U "${uuid:-random}" "${image}" - - # Upgrade the filesystem - if [ ${#tune2fs_opts[@]} -ne 0 ]; then - tune2fs "${tune2fs_opts[@]}" "${image}" + if [ -n "${UUID}" ]; then + mkfs_opts+=( -U "${UUID}" ) fi - # After changing filesystem options, running fsck is required - # (see: man tune2fs). Running e2fsck in other cases will ensure - # coherency of the filesystem, although it is not required. - # 'e2fsck -pDf' means: - # - automatically repair - # - optimise and check for duplicate entries - # - force checking - # Sending output to oblivion, as e2fsck can be *very* verbose, - # especially with filesystems generated by genext2fs. - # Exit codes 1 & 2 are OK, it means fs errors were successfully - # corrected, hence our little trick with $ret. - ret=0 - e2fsck -pDf "${image}" >/dev/null || ret=$? - case ${ret} in - 0|1|2) ;; - *) errorN ${ret} "failed to run e2fsck on '%s' (ext%d)\n" \ - "${image}" ${gen} - esac
package/mke2img/mke2img main() { · line 86
Quoted 10 lines
package/mke2img/mke2img +2
-8- printf "\n" - trace "e2fsck was successfully run on '%s' (ext%d)\n" "${image}" ${gen} - printf "\n" - - # Remove count- and time-based checks, they are not welcome - # on embedded devices, where they can cause serious boot-time - # issues by tremendously slowing down the boot. - tune2fs -c 0 -i 0 "${image}" + # Generate the filesystem + mkfs_opts+=( -d "${root_dir}" -N ${nb_inodes} -T small -F )
I have a small preference to specify the options explicitly instead of -T small
(i.e. -b 1024 -I 128).
Regards,
Arnout
Quoted 21 lines
package/mke2img/mke2img +4
-0+ if [ -n "${nb_res_blocks}" ]; then + mkfs_opts+=( -m ${nb_res_blocks} ) + fi + mkfs.ext${gen} "${mkfs_opts[@]}" "${image}" "${nb_blocks}" } help() {package/mke2img/mke2img.mk +1
-1@@ -4,7 +4,7 @@ # ################################################################################ -HOST_MKE2IMG_DEPENDENCIES = host-genext2fs host-e2fsprogs +HOST_MKE2IMG_DEPENDENCIES = host-e2fsprogs define HOST_MKE2IMG_INSTALL_CMDS $(INSTALL) -D -m 0755 package/mke2img/mke2img $(HOST_DIR)/usr/bin/mke2img
Signature · 6 lines
Arnout Vandecappelle arnout at mind be Senior Embedded Software Architect +32-16-286500 Essensium/Mind http://www.mind.be G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle GPG fingerprint: 7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
PATCH 2/4 package/mke2img: use mkfs to generate rootfs image
Hello,
Quoted 9 lines · Arnout Vandecappelle
package/mke2img/mke2img main() { · line 86
Quoted 6 lines
package/mke2img/mke2img +2
-4- # Remove count- and time-based checks, they are not welcome - # on embedded devices, where they can cause serious boot-time - # issues by tremendously slowing down the boot. - tune2fs -c 0 -i 0 "${image}" + # Generate the filesystem + mkfs_opts+=( -d "${root_dir}" -N ${nb_inodes} -T small -F )I have a small preference to specify the options explicitly instead of -T small
(i.e. -b 1024 -I 128).
What do we force a block size of 1 KB ? 1 KB is really a terrible choice for most filesystem sizes in nowadays storage devices, and 4 KB is often much more appropriate.
mkfs.ext234 is capable of selecting a good block size automatically, so why should we force a block size here?
See:
-b block-size
Specify the size of blocks in bytes. Valid block-size values are 1024, 2048 and 4096 bytes per block. If omitted, block-size is heuristically determined by the filesystem size and the expected usage of the filesystem (see the -T option).
So I would not set -T small, and I would not pass any -b or -I option.
Best regards,
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
PATCH 2/4 package/mke2img: use mkfs to generate rootfs image
In reply to Arnout VandecappelleHello,
Quoted 39 lines · Arnout Vandecappelle
Quoted 3 lines · S?bastien Szymanski
Signed-off-by S?bastien Szymanski <[email protected]>---
[snip]
Quoted 32 lines
package/mke2img/mke2img +2
-15@@ -10,9 +10,8 @@ set -e main() { local OPT OPTARG local nb_blocks nb_inodes nb_res_blocks root_dir image gen rev label uuid - local -a genext2fs_opts - local -a tune2fs_opts - local tune2fs_O_opts + local -a mkfs_opts + local mkfs_O_opts # Default values gen=2@@ -62,80 +61,33 @@ main() { fi nb_inodes=$((nb_inodes+nb_extra_inodes)) - # Upgrade to rev1 if needed - if [ ${rev} -ge 1 ]; then - tune2fs_O_opts+=",filetype,sparse_super" - fi - - # Add a journal for ext3 and above - if [ ${gen} -ge 3 ]; then - tune2fs_opts+=( -j -J size=1 ) - fi - - # Add ext4 specific features - if [ ${gen} -ge 4 ]; then
Quoted 8 lines
package/mke2img/mke2img main() { · line 65
Quoted 4 lines
package/mke2img/mke2img +2
-2- tune2fs_O_opts+=",extents,uninit_bg,dir_index" - fi + # Disable 64bit flag as it's incompatible with older U-Boot versions + mkfs_O_opts+=",^64bit"This is a bit unfortunate. Actually, reading the man page, it shouldn't even be
needed: if the filesystem is less than 4TB, then mke2fs will not use 64bit. And if it's larger than 4TB, you just can't create it without the 64bit option...
Yes, but the 64bit flag is enabled by default since e2fsprogs 1.43 for ext4 filesystem. However, as I use -T small, the flag is not set. Also, I agree with Thomas about not using -T small option.
I think the user should be able to select the flags he wants. Should I add a string symbol (i.e, BR2_TARGET_ROOTFS_EXT2_OPTIONS) that is passed directly to mkfs or a bool symbol just for the 64bit flag (i.e, BR2_TARGET_ROOTFS_EXT2_O_64BIT) ?
Regards,
Quoted 109 lines
package/mke2img/mke2img main() { · line 69
Quoted 7 lines
package/mke2img/mke2img +2
-2# Add our -O options (there will be at most one leading comma, remove it) - if [ -n "${tune2fs_O_opts}" ]; then - tune2fs_opts+=( -O "${tune2fs_O_opts#,}" ) + if [ -n "${mkfs_O_opts}" ]; then + mkfs_opts+=( -O "${mkfs_O_opts#,}" )Since now the ^64bit is the only -O option, and it's always there, you can just
use an unconditionalmkfs_opts+=( -O ^64bit )Quoted 15 lines
package/mke2img/mke2img +1
-8fi # Add the label if specified if [ -n "${label}" ]; then - tune2fs_opts+=( -L "${label}" ) + mkfs_opts+=( -L "${label}" ) fi - # Generate the filesystem - genext2fs_opts=( -z -b ${nb_blocks} -N ${nb_inodes} -d "${root_dir}" ) - if [ -n "${nb_res_blocks}" ]; then - genext2fs_opts+=( -m ${nb_res_blocks} ) - fi - genext2fs "${genext2fs_opts[@]}" "${image}" -package/mke2img/mke2img main() { · line 80
Quoted 10 lines
package/mke2img/mke2img +1
-6- # genext2fs does not generate a UUID, but fsck will whine if one - # is missing, so we need to add a UUID. - # Of course, this has to happen _before_ we run fsck. - # Also, some ext4 metadata are based on the UUID, so we must - # set it before we can convert the filesystem to ext4. - # If the user did not specify a UUID, we generate a random one. + # If the user did not specify a UUID, mkfs will generate a random one. # Although a random UUID may seem bad for reproducibility, there # already are so many things that are not reproducible in a # filesystem: file dates, file ordering, content of the files...Hm, this becomes less and less true... With
BR2_REPRODUCIBLE, the file dates
and content should be fixed. So if only we can also fix the ordering, then the ext2 could also be reproducible... But that's not for this patch of course.Quoted 27 lines
package/mke2img/mke2img +2
-23- tune2fs -U "${uuid:-random}" "${image}" - - # Upgrade the filesystem - if [ ${#tune2fs_opts[@]} -ne 0 ]; then - tune2fs "${tune2fs_opts[@]}" "${image}" + if [ -n "${UUID}" ]; then + mkfs_opts+=( -U "${UUID}" ) fi - # After changing filesystem options, running fsck is required - # (see: man tune2fs). Running e2fsck in other cases will ensure - # coherency of the filesystem, although it is not required. - # 'e2fsck -pDf' means: - # - automatically repair - # - optimise and check for duplicate entries - # - force checking - # Sending output to oblivion, as e2fsck can be *very* verbose, - # especially with filesystems generated by genext2fs. - # Exit codes 1 & 2 are OK, it means fs errors were successfully - # corrected, hence our little trick with $ret. - ret=0 - e2fsck -pDf "${image}" >/dev/null || ret=$? - case ${ret} in - 0|1|2) ;; - *) errorN ${ret} "failed to run e2fsck on '%s' (ext%d)\n" \ - "${image}" ${gen} - esacpackage/mke2img/mke2img main() { · line 86
Quoted 10 lines
package/mke2img/mke2img +2
-8- printf "\n" - trace "e2fsck was successfully run on '%s' (ext%d)\n" "${image}" ${gen} - printf "\n" - - # Remove count- and time-based checks, they are not welcome - # on embedded devices, where they can cause serious boot-time - # issues by tremendously slowing down the boot. - tune2fs -c 0 -i 0 "${image}" + # Generate the filesystem + mkfs_opts+=( -d "${root_dir}" -N ${nb_inodes} -T small -F )I have a small preference to specify the options explicitly instead of -T small
(i.e. -b 1024 -I 128).Regards,
ArnoutQuoted 21 lines
package/mke2img/mke2img +4
-0+ if [ -n "${nb_res_blocks}" ]; then + mkfs_opts+=( -m ${nb_res_blocks} ) + fi + mkfs.ext${gen} "${mkfs_opts[@]}" "${image}" "${nb_blocks}" } help() {package/mke2img/mke2img.mk +1
-1@@ -4,7 +4,7 @@ # ################################################################################ -HOST_MKE2IMG_DEPENDENCIES = host-genext2fs host-e2fsprogs +HOST_MKE2IMG_DEPENDENCIES = host-e2fsprogs define HOST_MKE2IMG_INSTALL_CMDS $(INSTALL) -D -m 0755 package/mke2img/mke2img $(HOST_DIR)/usr/bin/mke2img
Signature · 5 lines
S?bastien Szymanski Software Engineer, Armadeus Systems sebastien.szymanski at armadeus.com Tel: +33 (0)9 72 29 41 44 Fax: +33 (0)9 72 28 79 26
PATCH 2/4 package/mke2img: use mkfs to generate rootfs image
Quoted 4 lines · S?bastien Szymanski
I think the user should be able to select the flags he wants. Should I add a string symbol (i.e,
BR2_TARGET_ROOTFS_EXT2_OPTIONS) that is passed directly to mkfs or a bool symbol just for the 64bit flag (i.e,BR2_TARGET_ROOTFS_EXT2_O_64BIT) ?
bool option doesn't make much sense IMO. String option is better, and for me
it's OK to default it to ^64bit.
I would then take this patch without the ^64bit, and add theBR2_TARGET_ROOTFS_EXT2_FEATURES option in a later patch. (Note that it should be called _FEATURES, since the man page refers to it as features.) It may be a good idea BTW to include a reference to the man page in the help text:
For more information about the features which can be set, see the manual page ext4(5).
(taken from the mke2fs man page).
Regards,
Arnout
Signature · 6 lines
Arnout Vandecappelle arnout at mind be Senior Embedded Software Architect +32-16-286500 Essensium/Mind http://www.mind.be G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle GPG fingerprint: 7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
PATCH 3/4 package/mke2img: remove unused package
In reply to Sébastien SzymanskiNow that we use mkfs to generate ext filesystem image, call mkfs directly from fs/ext2/ext2.mk and remove mke2img package.
--- Config.in.legacy | 6 ++ DEVELOPERS | 1 - fs/ext2/Config.in | 2 +- fs/ext2/ext2.mk | 25 +++---- package/Config.in.host | 1 - package/mke2img/Config.in.host | 10 --- package/mke2img/mke2img | 148 ----------------------------------------- package/mke2img/mke2img.mk | 13 ---- 8 files changed, 20 insertions(+), 186 deletions(-) delete mode 100644 package/mke2img/Config.in.host delete mode 100755 package/mke2img/mke2img delete mode 100644 package/mke2img/mke2img.mk
Config.in.legacy +6 -0
@@ -145,6 +145,12 @@ endif ############################################################################### comment "Legacy options removed in 2017.05" +config BR2_PACKAGE_HOST_MKE2IMG + bool "host mke2img has been removed" + select BR2_LEGACY + help + We now call mkfs directly to generate ext filesystem image. + config BR2_TARGET_ROOTFS_EXT2_EXTRA_BLOCKS int "extra size in blocks has been removed" default 0
DEVELOPERS +0 -1
@@ -1665,7 +1665,6 @@ F: package/libiscsi/ F: package/libseccomp/ F: package/linux-tools/ F: package/mesa3d-headers/ -F: package/mke2img/ F: package/nbd/ F: package/nut/ F: package/nvidia-driver/
fs/ext2/Config.in +1 -1
@@ -1,6 +1,6 @@ config BR2_TARGET_ROOTFS_EXT2 bool "ext2/3/4 root filesystem" - select BR2_PACKAGE_HOST_MKE2IMG + select BR2_PACKAGE_HOST_E2FSPROGS help Build an ext2/3/4 root filesystem
fs/ext2/ext2.mk +13 -12
@@ -4,32 +4,33 @@ # ################################################################################ -EXT2_OPTS = -G $(BR2_TARGET_ROOTFS_EXT2_GEN) -R $(BR2_TARGET_ROOTFS_EXT2_REV) +EXT2_OPTS = -d $(TARGET_DIR) +EXT2_OPTS += -r $(BR2_TARGET_ROOTFS_EXT2_REV) -ifneq ($(strip $(BR2_TARGET_ROOTFS_EXT2_BLOCKS)),0) -EXT2_OPTS += -b $(BR2_TARGET_ROOTFS_EXT2_BLOCKS) +NB_INODES := $(strip $(BR2_TARGET_ROOTFS_EXT2_INODES)) +ifeq ($(NB_INODES),0) +NB_INODES = $(shell echo $$(($$(find $(TARGET_DIR) | wc -l) + 400))) endif - -ifneq ($(strip $(BR2_TARGET_ROOTFS_EXT2_INODES)),0) -EXT2_OPTS += -i $(BR2_TARGET_ROOTFS_EXT2_INODES) -endif -EXT2_OPTS += -I $(BR2_TARGET_ROOTFS_EXT2_EXTRA_INODES) +EXT2_OPTS += -N $(shell echo $$(($(NB_INODES) + $(BR2_TARGET_ROOTFS_EXT2_EXTRA_INODES)))) ifneq ($(strip $(BR2_TARGET_ROOTFS_EXT2_RESBLKS)),0) -EXT2_OPTS += -r $(BR2_TARGET_ROOTFS_EXT2_RESBLKS) +EXT2_OPTS += -m $(BR2_TARGET_ROOTFS_EXT2_RESBLKS) endif +EXT2_OPTS += -O ^64bit +EXT2_OPTS += -T small -F + # qstrip results in stripping consecutive spaces into a single one. So the # variable is not qstrip-ed to preserve the integrity of the string value. EXT2_LABEL := $(subst ",,$(BR2_TARGET_ROOTFS_EXT2_LABEL)) ifneq ($(EXT2_LABEL),) -EXT2_OPTS += -l "$(EXT2_LABEL)" +EXT2_OPTS += -L "$(EXT2_LABEL)" endif -ROOTFS_EXT2_DEPENDENCIES = host-mke2img +ROOTFS_EXT2_DEPENDENCIES = host-e2fsprogs define ROOTFS_EXT2_CMD - PATH=$(BR_PATH) mke2img -d $(TARGET_DIR) $(EXT2_OPTS) -o $@ + PATH=$(BR_PATH) mkfs.ext$(BR2_TARGET_ROOTFS_EXT2_GEN) $(EXT2_OPTS) $@ $(BR2_TARGET_ROOTFS_EXT2_BLOCKS) endef rootfs-ext2-symlink:
package/Config.in.host +0 -1
@@ -24,7 +24,6 @@ menu "Host utilities" source "package/lpc3250loader/Config.in.host" source "package/lttng-babeltrace/Config.in.host" source "package/mfgtools/Config.in.host" - source "package/mke2img/Config.in.host" source "package/mkpasswd/Config.in.host" source "package/mtd/Config.in.host" source "package/mtools/Config.in.host"
package/mke2img/Config.in.host deleted +0 -10
@@ -1,10 +0,0 @@ -config BR2_PACKAGE_HOST_MKE2IMG - bool "host mke2img" - select BR2_PACKAGE_HOST_E2FSPROGS - help - Easily create filesystems of the extend familly: ext2/3/4. - - This tool is bundled by, and specific to Buildroot. However, it can - be used from post-images scripts is needed. - - https://code.google.com/p/mke2img/
package/mke2img/mke2img deleted +0 -148
148 lines not on this page · raw message
package/mke2img/mke2img.mk deleted +0 -13
@@ -1,13 +0,0 @@ -################################################################################ -# -# mke2img -# -################################################################################ - -HOST_MKE2IMG_DEPENDENCIES = host-e2fsprogs - -define HOST_MKE2IMG_INSTALL_CMDS - $(INSTALL) -D -m 0755 package/mke2img/mke2img $(HOST_DIR)/usr/bin/mke2img -endef - -$(eval $(host-generic-package))
Signature · 1 line
2.7.3
PATCH 3/4 package/mke2img: remove unused package
Quoted 2 lines · S?bastien Szymanski
Now that we use mkfs to generate ext filesystem image, call mkfs directly from
fs/ext2/ext2.mkand remove mke2img package.
"and" in the commit log is a flag that something is up: you're doing two
things, so it should be two patches. First let fs/ext2 use the new script, then remove mke2img.
But when you look at it that way, patch 2 becomes pretty useless. Since patch 2
anyway largely rewrites the script entirely, I would just drop it and immediately call mke2fs directly from the .mk file.
[snip]
fs/ext2/ext2.mk line 9
Quoted 13 lines
fs/ext2/ext2.mk +2
-2@@ -4,32 +4,33 @@ # ################################################################################ -EXT2_OPTS = -G $(BR2_TARGET_ROOTFS_EXT2_GEN) -R $(BR2_TARGET_ROOTFS_EXT2_REV) +EXT2_OPTS = -d $(TARGET_DIR) +EXT2_OPTS += -r $(BR2_TARGET_ROOTFS_EXT2_REV) -ifneq ($(strip $(BR2_TARGET_ROOTFS_EXT2_BLOCKS)),0)
This should have been removed in patch 1. Without the auto-calculation, if no
size is given, genext2fs will fail I think. Well, with size 0 it will also fail, but probably with a more obvious error message.
fs/ext2/ext2.mk line 10
Quoted 2 lines
fs/ext2/ext2.mk +1
-1-EXT2_OPTS += -b $(BR2_TARGET_ROOTFS_EXT2_BLOCKS) +NB_INODES := $(strip $(BR2_TARGET_ROOTFS_EXT2_INODES))
Why do you need := here?
fs/ext2/ext2.mk line 12
Quoted 2 lines
fs/ext2/ext2.mk +2
-0+ifeq ($(NB_INODES),0) +NB_INODES = $(shell echo $$(($$(find $(TARGET_DIR) | wc -l) + 400)))
Not sure, but perhaps also drop this autocalculation of number of inodes?
mke2fs will use a number of inodes depending on the filesystem size, which is possibly more useful than this autocalculation... Anyway, can be done in a later patch.
If you do keep NB_INODES, it's not needed to go through $(shell...), you can
just do
NB_INODES = $$(( $(BR2_TARGET_ROOTFS_EXT2_EXTRA_INODES) + \ `find $(TARGET_DIR) | wc -l` + 400 ))
(Note that we prefer `` over $() to reduce the double-dollaring.)
Also, the variable name should be prefixed with EXT2_.
fs/ext2/ext2.mk line 14
Quoted 7 lines
fs/ext2/ext2.mk +1
-5endif - -ifneq ($(strip $(BR2_TARGET_ROOTFS_EXT2_INODES)),0) -EXT2_OPTS += -i $(BR2_TARGET_ROOTFS_EXT2_INODES) -endif -EXT2_OPTS += -I $(BR2_TARGET_ROOTFS_EXT2_EXTRA_INODES) +EXT2_OPTS += -N $(shell echo $$(($(NB_INODES) + $(BR2_TARGET_ROOTFS_EXT2_EXTRA_INODES))))
Easier to include this calculation above, so just -N $(NB_INODES) here.
Quoted 13 lines
fs/ext2/ext2.mk +4
-1ifneq ($(strip $(BR2_TARGET_ROOTFS_EXT2_RESBLKS)),0) -EXT2_OPTS += -r $(BR2_TARGET_ROOTFS_EXT2_RESBLKS) +EXT2_OPTS += -m $(BR2_TARGET_ROOTFS_EXT2_RESBLKS) endif +EXT2_OPTS += -O ^64bit +EXT2_OPTS += -T small -F + # qstrip results in stripping consecutive spaces into a single one. So the # variable is not qstrip-ed to preserve the integrity of the string value. EXT2_LABEL := $(subst ",,$(BR2_TARGET_ROOTFS_EXT2_LABEL)) ifneq ($(EXT2_LABEL),)
fs/ext2/ext2.mk line 33
Quoted 10 lines
fs/ext2/ext2.mk +3
-3-EXT2_OPTS += -l "$(EXT2_LABEL)" +EXT2_OPTS += -L "$(EXT2_LABEL)" endif -ROOTFS_EXT2_DEPENDENCIES = host-mke2img +ROOTFS_EXT2_DEPENDENCIES = host-e2fsprogs define ROOTFS_EXT2_CMD - PATH=$(BR_PATH) mke2img -d $(TARGET_DIR) $(EXT2_OPTS) -o $@ + PATH=$(BR_PATH) mkfs.ext$(BR2_TARGET_ROOTFS_EXT2_GEN) $(EXT2_OPTS) $@ $(BR2_TARGET_ROOTFS_EXT2_BLOCKS)
I have a slight preference to use mke2fs -t extX rather than mkfs.extX (which
allows adding the GEN option to EXT2_OPTS), but that's just personal preference.
Regards,
Arnout
Quoted 3 lines
fs/ext2/ext2.mk +0
-0endef rootfs-ext2-symlink:
[snip]
Signature · 6 lines
Arnout Vandecappelle arnout at mind be Senior Embedded Software Architect +32-16-286500 Essensium/Mind http://www.mind.be G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle GPG fingerprint: 7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
PATCH 4/4 fs/ext2: Make filesystem size a string
In reply to Sébastien SzymanskiIt allows the user to enter a size with 'k', 'm', 'g', or 't' suffix. Also drop BR2_TARGET_ROOTFS_EXT2_BLOCKS and use BR2_TARGET_ROOTFS_EXT2_SIZE instead.
--- Config.in.legacy | 13 +++++++++++++ fs/ext2/Config.in | 11 ++++++++--- fs/ext2/ext2.mk | 2 +- 3 files changed, 22 insertions(+), 4 deletions(-)
Config.in.legacy +13 -0
@@ -145,6 +145,19 @@ endif ############################################################################### comment "Legacy options removed in 2017.05" +config BR2_TARGET_ROOTFS_EXT2_BLOCKS + int "exact size in KB has been removed" + default 65536 + help + This option has been removed in favor of BR2_TARGET_ROOTFS_EXT2_SIZE. + Set this option to 65536 and set BR2_TARGET_ROOTFS_EXT2_SIZE to your + needs. + +config BR2_TARGET_ROOTFS_EXT2_BLOCKS_WRAP + bool + default y if BR2_TARGET_ROOTFS_EXT2_BLOCKS != 65536 + select BR2_LEGACY + config BR2_PACKAGE_HOST_MKE2IMG bool "host mke2img has been removed" select BR2_LEGACY
fs/ext2/Config.in +8 -3
@@ -44,9 +44,14 @@ config BR2_TARGET_ROOTFS_EXT2_REV config BR2_TARGET_ROOTFS_EXT2_LABEL string "filesystem label" -config BR2_TARGET_ROOTFS_EXT2_BLOCKS - int "exact size in KB" - default 65536 +config BR2_TARGET_ROOTFS_EXT2_SIZE + string "exact size" + default "64M" + help + The size of the filesystem image. If it does not have a suffix, it is + interpreted as power-of-two kilobytes. If it is suffixed by 'k', 'm', + 'g', 't' (either upper-case or lower-case), then it is interpreted in + power-of-two kilobytes, megabytes, gigabytes, terabytes, etc. config BR2_TARGET_ROOTFS_EXT2_INODES int "exact number of inodes (leave at 0 for auto calculation)"
fs/ext2/ext2.mk +1 -1
@@ -30,7 +30,7 @@ endif ROOTFS_EXT2_DEPENDENCIES = host-e2fsprogs define ROOTFS_EXT2_CMD - PATH=$(BR_PATH) mkfs.ext$(BR2_TARGET_ROOTFS_EXT2_GEN) $(EXT2_OPTS) $@ $(BR2_TARGET_ROOTFS_EXT2_BLOCKS) + PATH=$(BR_PATH) mkfs.ext$(BR2_TARGET_ROOTFS_EXT2_GEN) $(EXT2_OPTS) $@ $(strip $(BR2_TARGET_ROOTFS_EXT2_SIZE)) endef rootfs-ext2-symlink:
Signature · 1 line
2.7.3
PATCH 4/4 fs/ext2: Make filesystem size a string
Quoted 16 lines · S?bastien Szymanski
It allows the user to enter a size with 'k', 'm', 'g', or 't' suffix. Also drop
BR2_TARGET_ROOTFS_EXT2_BLOCKSand useBR2_TARGET_ROOTFS_EXT2_SIZEinstead.Signed-off-by S?bastien Szymanski <[email protected]>--- Config.in.legacy | 13 +++++++++++++ fs/ext2/Config.in | 11 ++++++++--- fs/ext2/ext2.mk | 2 +- 3 files changed, 22 insertions(+), 4 deletions(-)Config.in.legacy +0
-0
Config.in.legacy endif · line 150
Quoted 6 lines
Config.in.legacy +3
-0@@ -145,6 +145,19 @@ endif ############################################################################### comment "Legacy options removed in 2017.05" +config BR2_TARGET_ROOTFS_EXT2_BLOCKS + int "exact size in KB has been removed" + default 65536
This should be "default 0" (and 0 everywhere else as well). The legacy handling
always compares to the previous Buildroot release, and in 2017.02 the default was 0.
If this doesn't make it into 2017.05, that's something else entirely. But I'm
sure we'll get it for 2017.05...
Config.in.legacy endif · line 154
Quoted 4 lines
Config.in.legacy +4
-0+ help + This option has been removed in favor of BR2_TARGET_ROOTFS_EXT2_SIZE. + Set this option to 65536 and set BR2_TARGET_ROOTFS_EXT2_SIZE to your + needs.
See below, BR2_TARGET_ROOTFS_EXT2_SIZE can be set automatically.
Quoted 14 lines
Config.in.legacy +6
-0+ +config BR2_TARGET_ROOTFS_EXT2_BLOCKS_WRAP + bool + default y if BR2_TARGET_ROOTFS_EXT2_BLOCKS != 65536 + select BR2_LEGACY + config BR2_PACKAGE_HOST_MKE2IMG bool "host mke2img has been removed" select BR2_LEGACYfs/ext2/Config.in +0
-0
fs/ext2/Config.in config BR2_TARGET_ROOTFS_EXT2_REV · line 49
Quoted 9 lines
fs/ext2/Config.in +3
-3@@ -44,9 +44,14 @@ config BR2_TARGET_ROOTFS_EXT2_REV config BR2_TARGET_ROOTFS_EXT2_LABEL string "filesystem label" -config BR2_TARGET_ROOTFS_EXT2_BLOCKS - int "exact size in KB" - default 65536 +config BR2_TARGET_ROOTFS_EXT2_SIZE + string "exact size" + default "64M"
Default should be 60M, of course.
We can do a little bit better for legacy handling, because we can actually use
the old int value as the string default:
default BR2_TARGET_ROOTFS_EXT2_BLOCKS if BR2_TARGET_ROOTFS_EXT2_BLOCKS != 0 #
legacy 2017.05
Quoted 13 lines
fs/ext2/Config.in +5
-0+ help + The size of the filesystem image. If it does not have a suffix, it is + interpreted as power-of-two kilobytes. If it is suffixed by 'k', 'm', + 'g', 't' (either upper-case or lower-case), then it is interpreted in + power-of-two kilobytes, megabytes, gigabytes, terabytes, etc. config BR2_TARGET_ROOTFS_EXT2_INODES int "exact number of inodes (leave at 0 for auto calculation)"fs/ext2/ext2.mk +0
-0
fs/ext2/ext2.mk endif · line 33
Quoted 5 lines
fs/ext2/ext2.mk +1
-1@@ -30,7 +30,7 @@ endif ROOTFS_EXT2_DEPENDENCIES = host-e2fsprogs define ROOTFS_EXT2_CMD - PATH=$(BR_PATH) mkfs.ext$(BR2_TARGET_ROOTFS_EXT2_GEN) $(EXT2_OPTS) $@ $(BR2_TARGET_ROOTFS_EXT2_BLOCKS) + PATH=$(BR_PATH) mkfs.ext$(BR2_TARGET_ROOTFS_EXT2_GEN) $(EXT2_OPTS) $@ $(strip $(BR2_TARGET_ROOTFS_EXT2_SIZE))
This should be qstrip, not strip. Strip is useless, there are no quotes around it.
Oh, forgot to mention in my previous mail: this line is too long.
Regards,
Arnout
Quoted 4 lines
fs/ext2/ext2.mk +0
-0endef rootfs-ext2-symlink:
Signature · 6 lines
Arnout Vandecappelle arnout at mind be Senior Embedded Software Architect +32-16-286500 Essensium/Mind http://www.mind.be G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle GPG fingerprint: 7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
PATCH 1/4 fs/ext2: Remove support for auto-calculation of rootfs size
In reply to Sébastien SzymanskiQuoted 8 lines · S?bastien Szymanski
Auto-calculation of the rootfs size cannot be done in a reliable way as it depends on the host filesystem and is broken on non ext4 host. [1] [2] So let the user specify the size he wants for his rootfs.
[1] https://bugs.busybox.net/show_bug.cgi?id=8831
[2] https://bugs.busybox.net/show_bug.cgi?id=9496Signed-off-by S?bastien Szymanski <[email protected]>
Small comments below, but
Quoted 12 lines
--- Config.in.legacy | 14 ++++++++++++++ fs/ext2/Config.in | 12 ++---------- fs/ext2/ext2.mk | 1 - package/mke2img/mke2img | 20 +------------------- 4 files changed, 17 insertions(+), 30 deletions(-)Config.in.legacy +0
-0
Config.in.legacy endif · line 152
Quoted 8 lines
Config.in.legacy +5
-0@@ -145,6 +145,20 @@ endif ############################################################################### comment "Legacy options removed in 2017.05" +config BR2_TARGET_ROOTFS_EXT2_EXTRA_BLOCKS + int "extra size in blocks has been removed" + default 0 + help + Since the support for auto calculation of the filesystem size has been
Line too long, wrap at 72 columns (where tab counts for 8).
Config.in.legacy endif · line 154
Quoted 2 lines
Config.in.legacy +2
-0+ removed, this option is now useless and must be 0. + You may want to check that BR2_TARGET_ROOTFS_EXT2_BLOCKS matchs
matches
Config.in.legacy endif · line 160
Quoted 6 lines
Config.in.legacy +6
-0+ your needs. + +config BR2_TARGET_ROOTFS_EXT2_EXTRA_BLOCKS_WRAP + bool + default y if BR2_TARGET_ROOTFS_EXT2_EXTRA_BLOCKS != 0 + select BR2_LEGACY
Great solution!
Quoted 9 lines
Config.in.legacy +1
-0+ config BR2_PACKAGE_SYSTEMD_KDBUS bool "systemd-kdbus has been removed" select BR2_LEGACYfs/ext2/Config.in +0
-0
fs/ext2/Config.in config BR2_TARGET_ROOTFS_EXT2_LABEL · line 49
Quoted 7 lines
fs/ext2/Config.in +2
-2@@ -45,21 +45,13 @@ config BR2_TARGET_ROOTFS_EXT2_LABEL string "filesystem label" config BR2_TARGET_ROOTFS_EXT2_BLOCKS - int "exact size in blocks (leave at 0 for auto calculation)" - default 0 + int "exact size in blocks" + default 65536
I think this default is quite useless: it is too large for a 64M card, and
wastes a lot of space on a 128M card. So setting it to 60M or 120M would be more appropriate.
Regards,
Arnout
Quoted 72 lines
fs/ext2/Config.in +0
-8config BR2_TARGET_ROOTFS_EXT2_INODES int "exact number of inodes (leave at 0 for auto calculation)" default 0 -config BR2_TARGET_ROOTFS_EXT2_EXTRA_BLOCKS - int "extra size in blocks" if BR2_TARGET_ROOTFS_EXT2_BLOCKS = 0 - default 0 - help - Enter here the number of extra blocks of free space you - want on your filesystem. By default, Buildroot will not - leave much space free. - config BR2_TARGET_ROOTFS_EXT2_EXTRA_INODES int "extra inodes" if BR2_TARGET_ROOTFS_EXT2_INODES = 0 default 0fs/ext2/ext2.mk +0
-1@@ -9,7 +9,6 @@ EXT2_OPTS = -G $(BR2_TARGET_ROOTFS_EXT2_GEN) -R $(BR2_TARGET_ROOTFS_EXT2_REV) ifneq ($(strip $(BR2_TARGET_ROOTFS_EXT2_BLOCKS)),0) EXT2_OPTS += -b $(BR2_TARGET_ROOTFS_EXT2_BLOCKS) endif -EXT2_OPTS += -B $(BR2_TARGET_ROOTFS_EXT2_EXTRA_BLOCKS) ifneq ($(strip $(BR2_TARGET_ROOTFS_EXT2_INODES)),0) EXT2_OPTS += -i $(BR2_TARGET_ROOTFS_EXT2_INODES)package/mke2img/mke2img +1
-19@@ -17,14 +17,12 @@ main() { # Default values gen=2 rev=1 - nb_extra_blocks=0 nb_extra_inodes=0 - while getopts :hb:B:i:I:r:d:o:G:R:l:u: OPT; do + while getopts :hb:i:I:r:d:o:G:R:l:u: OPT; do case "${OPT}" in h) help; exit 0;; b) nb_blocks=${OPTARG};; - B) nb_extra_blocks=${OPTARG};; i) nb_inodes=${OPTARG};; I) nb_extra_inodes=${OPTARG};; r) nb_res_blocks=${OPTARG};;@@ -64,22 +62,6 @@ main() { fi nb_inodes=$((nb_inodes+nb_extra_inodes)) - # calculate needed blocks - if [ -z "${nb_blocks}" ]; then - # size ~= superblock, block+inode bitmaps, inodes (8 per block), - # blocks; we scale inodes / blocks with 10% to compensate for - # bitmaps size + slack - nb_blocks=$(du -s -k "${root_dir}" |sed -r -e 's/[[:space:]]+.*$//') - nb_blocks=$((500+(nb_blocks+nb_inodes/8)*11/10)) - if [ ${gen} -ge 3 ]; then - # we add 1300 blocks (a bit more than 1 MiB, assuming 1KiB blocks) - # for the journal - # Note: I came to 1300 blocks after trial-and-error checks. YMMV. - nb_blocks=$((nb_blocks+1300)) - fi - fi - nb_blocks=$((nb_blocks+nb_extra_blocks)) - # Upgrade to rev1 if needed if [ ${rev} -ge 1 ]; then tune2fs_O_opts+=",filetype,sparse_super"
Signature · 6 lines
Arnout Vandecappelle arnout at mind be Senior Embedded Software Architect +32-16-286500 Essensium/Mind http://www.mind.be G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle GPG fingerprint: 7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
Thomas Petazzoni
AppliedPATCH 1/4 fs/ext2: Remove support for auto-calculation of rootfs size
In reply to Sébastien SzymanskiHello,
Quoted 7 lines · S?bastien Szymanski
Auto-calculation of the rootfs size cannot be done in a reliable way as it depends on the host filesystem and is broken on non ext4 host. [1] [2] So let the user specify the size he wants for his rootfs.
[1] https://bugs.busybox.net/show_bug.cgi?id=8831
[2] https://bugs.busybox.net/show_bug.cgi?id=9496
Quoted 7 lines
Signed-off-by S?bastien Szymanski <[email protected]>--- Config.in.legacy | 14 ++++++++++++++ fs/ext2/Config.in | 12 ++---------- fs/ext2/ext2.mk | 1 - package/mke2img/mke2img | 20 +------------------- 4 files changed, 17 insertions(+), 30 deletions(-)
Applied to master after taking into account the suggestion of Arnout to use a 60MB size by default.
Thanks!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com