v1.10.0 swapon: swapfile has holes - blocksize ?

Denys Vlasenko vda.linux at googlemail.com
Wed Mar 26 20:20:43 UTC 2008


On Wednesday 26 March 2008 18:24, Jonathan Moore wrote:
> I quickly downloaded and built BusyBox v1.10.0. But it still gave the same "hole" problem. See below.
> 
> Are there any debug flags I can turn on ? I'll start going through the documentation. I'm relatively new to BusyBox, and I'm wondering if I'm just missing something out required to create a swapfile.
> 
> I made BusyBox using the following commands:
> 
> make defconfig
> export ARCH=powerpc
> export CROSS_COMPILE=ppc_6xx-
> PATH=$PATH:/home/jm0069/ws/MCU/MCU_dev/MCU/Tools/ELDK/usr/bin/
> make
> 
> /var/tmp $ dd if=/dev/zero of=swapfile bs=1M count=20
> 20+0 records in
> 20+0 records out
> /var/tmp $ ls -l
> -rw-r--r--    1 root     0        20971520 Jan  2 08:31 swapfile
> /var/tmp $ mkswap swapfile
> Setting up swapspace version 1, size = 20967424 bytes
> /var/tmp $ swapon swapfile
> swapon: swapfile has holes   <==========================
> swapon: swapfile: Invalid argument

Remember this messages! Now, read on.

> /var/tmp $ swapon --help
> BusyBox v1.10.0 (2008-03-26 17:58:17 CET) multi-call binary
> 
> Usage: swapon [-a] [DEVICE]
> 
> Start swapping on DEVICE
> 
> Options:
>         -a      Start swapping on all swap devices

I'm sorry, but this is untrue.

# cd busybox-1.10.0
# grep -r 'holes' .
./util-linux/swaponoff.c:     /* test for holes */
./util-linux/swaponoff.c:               bb_error_msg("warning: swap file has holes");
./e2fsprogs/old_e2fsprogs/ext2fs/ext2fs.h: * to deal with files that contain "holes".
./e2fsprogs/old_e2fsprogs/e2fsck.c:                blkaddr pattern looks right (all non-holes up to

Look closely. In 1.10.0, message is "swap file has holes".
"swap file", not "swapfile". Also there is word "warning",
so that user knows that unless swapon() call fails,
it is not an error (merely warning).

Your message is different. How is that possible?

You can obtain more data by adding this message:

        if (S_ISREG(st.st_mode))
{
bb_error_msg("blocks %lld size %%lld", (unsigned long long)st.st_blocks, (unsigned long long)st.st_size);
                if (st.st_blocks * (off_t)512 < st.st_size)
                        bb_error_msg("warning: swap file has holes");
}

--
vda



More information about the busybox mailing list