Mercurial > illumos > illumos-gate
changeset 2511:cf2642e6cb5b onnv_46
6450577 create_ramdisk and root_archive incorrectly calculate ramdisk size an a compressed zfs fs
author | jongkis |
---|---|
date | Mon, 07 Aug 2006 18:14:05 -0700 |
parents | 6ae7b2fa232b |
children | 6e8ba96b45df |
files | usr/src/cmd/boot/scripts/create_ramdisk.ksh usr/src/cmd/boot/scripts/root_archive.ksh |
diffstat | 2 files changed, 30 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/usr/src/cmd/boot/scripts/create_ramdisk.ksh Mon Aug 07 15:49:15 2006 -0700 +++ b/usr/src/cmd/boot/scripts/create_ramdisk.ksh Mon Aug 07 18:14:05 2006 -0700 @@ -78,16 +78,20 @@ function getsize { - # Estimate image size, add %10 overhead for ufs stuff - total_size=0 - for file in $filelist - do - if [ -e "$ALT_ROOT/$file" ] ; then - du -sk "$ALT_ROOT/$file" | read size name - (( total_size += size )) - fi - done - (( total_size += total_size * 10 / 100 )) + # Estimate image size and add %10 overhead for ufs stuff. + # Note, we can't use du here in case we're on a filesystem, e.g. zfs, + # in which the disk usage is less than the sum of the file sizes. + # The nawk code + # + # {t += ($7 % 1024) ? (int($7 / 1024) + 1) * 1024 : $7} + # + # below rounds up the size of a file/directory, in bytes, to the + # next multiple of 1024. This mimics the behavior of ufs especially + # with directories. This results in a total size that's slightly + # bigger than if du was called on a ufs directory. + total_size=$(find $filelist -ls 2>/dev/null | nawk ' + {t += ($7 % 1024) ? (int($7 / 1024) + 1) * 1024 : $7} + END {print int(t * 1.10 / 1024)}') } function create_ufs @@ -222,7 +226,8 @@ # sanity check the archive before moving it into place # the file type check also establishes that the file exists at all # -ARCHIVE_SIZE=`du -k "$ALT_ROOT/$BOOT_ARCHIVE-new" | cut -f 1` +ARCHIVE_SIZE=$(/bin/ls -l "$ALT_ROOT/$BOOT_ARCHIVE-new" | + nawk '{print int($5 / 1024)}') file "$ALT_ROOT/$BOOT_ARCHIVE-new" | grep gzip > /dev/null if [ $? = 1 ] && [ -x /usr/bin/gzip ] || [ $ARCHIVE_SIZE -lt 5000 ]; then
--- a/usr/src/cmd/boot/scripts/root_archive.ksh Mon Aug 07 15:49:15 2006 -0700 +++ b/usr/src/cmd/boot/scripts/root_archive.ksh Mon Aug 07 18:14:05 2006 -0700 @@ -242,8 +242,20 @@ exit 1 fi - size=`du -sk "$UNPACKED_ROOT" | ( read size name; echo $size )` - size=`expr "$EXTRA_SPACE" \* 1024 + $size + \( $size \* 10 \) / 100` + # Estimate image size and add %10 overhead for ufs stuff. + # Note, we can't use du here in case $UNPACKED_ROOT is on a filesystem, + # e.g. zfs, in which the disk usage is less than the sum of the file + # sizes. The nawk code + # + # {t += ($7 % 1024) ? (int($7 / 1024) + 1) * 1024 : $7} + # + # below rounds up the size of a file/directory, in bytes, to the + # next multiple of 1024. This mimics the behavior of ufs especially + # with directories. This results in a total size that's slightly + # bigger than if du was called on a ufs directory. + size=$(find "$UNPACKED_ROOT" -ls | nawk ' + {t += ($7 % 1024) ? (int($7 / 1024) + 1) * 1024 : $7} + END {print int(t * 1.10 / 1024)}') /usr/sbin/mkfile ${size}k "$TMR"