Bug#612877: dphys-swapfile: memory computations are in MB, but my systems report it in kB - results in wrong swap file size

February 11th, 2011 - 04:10 am ET by Antonio Galea | Report spam
Package: dphys-swapfile
Version: 20061020-3
Severity: normal


When installing dphys-swapfile on a small ARM embedded with 64Mb of RAM
should configure 128Mb of swap file - instead, it reports I want a 128Gb
swap, then trims it back to the configured maximum of 2G - and fills my
uSD card trying to create it.

Memory detection is at /sbin/dphys-swapfile:51, namely

MEMSIZE="`head -1 /proc/meminfo | awk '{ print $2 }'`"

Both my FoxG20 ARM embedded board and my desktop machine report memory
in kB, but along in the script all computations are done as if meminfo
gives MB instead.
The line

MEMSIZE="`head -1 /proc/meminfo | awk '{ print int($2/1024) }'`"

might offer a naive fix for this issue, but a better approach
is to actually read from meminfo the correct multiplier.

As a side note, it would be way better if the script could refuse to
create a swap file larger than the available disk space.

Regards,

Antonio

Debian Release: 6.0
APT prefers stable
APT policy: (500, 'stable')
Architecture: armel (armv5tejl)

Kernel: Linux 2.6.35.9 (PREEMPT)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) (ignored: LC_ALL set to en_US.UTF-8)
Shell: /bin/sh linked to /bin/dash




To UNSUBSCRIBE, email to debian-bugs-dist-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
email Follow the discussionReplies 3 repliesReplies Make a reply

Replies

#1 Axel Beckert
February 11th, 2011 - 04:40 am ET | Report spam
tags 612877 + fixed-upstream confirmed
kthxbye

Hi Antonio,

thanks for your bug report.

Antonio Galea wrote:
When installing dphys-swapfile on a small ARM embedded with 64Mb of RAM
should configure 128Mb of swap file - instead, it reports I want a 128Gb
swap, then trims it back to the configured maximum of 2G - and fills my
uSD card trying to create it.

Memory detection is at /sbin/dphys-swapfile:51, namely

MEMSIZE="`head -1 /proc/meminfo | awk '{ print $2 }'`"

Both my FoxG20 ARM embedded board and my desktop machine report memory
in kB, but along in the script all computations are done as if meminfo
gives MB instead.
The line

MEMSIZE="`head -1 /proc/meminfo | awk '{ print int($2/1024) }'`"

might offer a naive fix for this issue, but a better approach
is to actually read from meminfo the correct multiplier.



This is a bug in the workaround for #564466, a missing /1024 as you
noticed. Upstream has rewritten that section completely already, but
not yet released a new version.

JFTR: This bug has also been reported against Ubuntu at
https://bugs.launchpad.net/ubuntu/+...bug/706764

As a side note, it would be way better if the script could refuse to
create a swap file larger than the available disk space.



You can set CONF_MAXSWAP in /etc/dphys-swapfile to set a manual limit.
IIRC the default manual limit is 2 GB which is obviously not enough
for your case.

This problem will probably be fixed with the fix for
http://bugs.debian.org/596187.

Regards, Axel
,''`. | Axel Beckert , 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



To UNSUBSCRIBE, email to
with a subject of "unsubscribe". Trouble? Contact

Similar topics