Commits
Kir Kolyshkin authored b5130d5a094
vps-create: fix checking needed disk space Oh this is quite a story. Sit down and listen, folks. First, since 14 Dec 2002 (coreutils-4.5.4) and up until to 6 Jan 2012 (coreutils-8.15), ls -lk was printing file size in kilobytes. It's man page (as of coreutils-8.15) was still saying that: -k, --kibibytes use 1024-byte blocks although info page is already fixed: `-k' `--kibibytes' Set the default block size to its normal value of 1024 bytes, overriding any contrary specification in environment variables (*note Block size::). This option is in turn overridden by the `--block-size', `-h' or `--human-readable', and `--si' options. The `-k' or `--kibibytes' option affects the per-directory block count written by the `-l' and similar options, and the size written by the `-s' or `--size' option. It does not affect the file size written by `-l'. For the rest of the story about ls -lk, see http://lists.gnu.org/archive/html/bug-coreutils/2011-11/msg00064.html Now to the real business. In vps-create we try to estimate if a filesystem hosting /vz/private has enough free space to hold the to-be-created container. In case we can't get the uncompressed template tarball size using compressor (both gzip and newer xv versions has this feature, while bzip2 doesn't), or the template is not compressed, we use ls -lk to show template tarball size in kilobytes (and compare the result to free blocks obtained via df). We also use empirical muplipliers of 3 for bzip2 and 4.7 for xv to estimate the uncompressed size. Now that ls -lk is showing file size in bytes, we need to divide its result by 1024 to convert to 1-k blocks. This is what the patch does (together with removing now-useless -k). Basically, this fixes inability to create a CT from tar.bzip2 or tar (or tar.xz using older xz utilitiles). http://bugzilla.openvz.org/2413 Reported-by: Richard H. <chain@rpgfiction.net> Signed-off-by: Kir Kolyshkin <kir@openvz.org>