Comment 4 for bug 706764

Revision history for this message
Axel Beckert (xtaran) wrote : Re: [Bug 706764] Re: dphys-swapfile sets incorrect swap size

Hi,

Gerry Reno wrote:
> When I look at upstream 20061020-3:
> MEMSIZE="`head -1 /proc/meminfo | awk '{ print $2 }'`"
> looks like it still might be high by a factor of 1024 since MEMSIZE is in megabytes and meminfo is in kilobytes.
>
> That is why my patch adjusted for the difference:
> MEMSIZE=$(($(cat /proc/meminfo | awk '/^MemTotal/ { print $2 }') / 1024))

Indeed. Probably got through unnoticed because of the reintroduction
of a maximum size. Thanks for spotting that.

It's though fixed in the current upstream developement snapshot:

      MEMTOTAL="`grep '^MemTotal:' /proc/meminfo | awk '{ print $2 }'`"
      # make MBytes which rounded down will be about 10 too few, so add 10
      MEMSIZE="`echo "${MEMTOTAL} 1024 / 10 + p q" | dc`"
      # compute desired swap size, as factor * RAM
      CONF_SWAPSIZE="`echo "${MEMSIZE} ${CONF_SWAPFACTOR} * p q" | dc`"
      # remove any fractional MBytes
      CONF_SWAPSIZE="`echo "${CONF_SWAPSIZE}" | cut -f 1 -d '.'`"

  Regards, Axel
--
 ,''`. | Axel Beckert <email address hidden>, http://people.debian.org/~abe/
: :' : | Debian Developer, ftp.ch.debian.org Admin
`. `' | 1024D: F067 EA27 26B9 C3FC 1486 202E C09E 1D89 9593 0EDE
  `- | 4096R: 2517 B724 C5F6 CA99 5329 6E61 2FF9 CD59 6126 16B5