Bash snippet - Allocate a file without physical pre-allocation (a sparse file).


SUBMITTED BY: DanielK

DATE: Aug. 13, 2016, 2:58 p.m.

FORMAT: Bash

SIZE: 183 Bytes

HITS: 770

  1. function alloc_file()
  2. {
  3. if [ $# -gt 1 ]; then
  4. dd if=/dev/zero bs=1 of="${1}" count=0 seek=${2}
  5. else
  6. echo "${FUNCNAME} <path> <size> [K,M,G suffixes allowed]"
  7. fi
  8. }

comments powered by Disqus