# Prepare a simple raw container
mkdir -p /tmp/mnt
-dd if=/dev/zero of=/var/tmp/container.raw bs=1M count=256
+truncate -s 256M /var/tmp/container.raw
mkfs.ext4 /var/tmp/container.raw
mount -o loop /var/tmp/container.raw /tmp/mnt
cp -r /var/lib/machines/container1/* /tmp/mnt
create_dummy_container "$template"
# Create a simple image from the just created container template
image="$(mktemp /var/lib/machines/TEST-13-NSPAWN.image-XXX.img)"
- dd if=/dev/zero of="$image" bs=1M count=256
+ truncate -s 256M "$image"
mkfs.ext4 "$image"
mkdir -p /mnt
mount -o loop "$image" /mnt
root="$(mktemp -d /var/lib/machines/TEST-13-NSPAWN.rootidmap-path.XXX)"
# Create ext4 image, as ext4 supports idmapped-mounts.
mkdir -p /tmp/rootidmap/bind
- dd if=/dev/zero of=/tmp/rootidmap/ext4.img bs=4k count=2048
+ truncate -s $((4096*2048)) /tmp/rootidmap/ext4.img
mkfs.ext4 /tmp/rootidmap/ext4.img
mount /tmp/rootidmap/ext4.img /tmp/rootidmap/bind
trap "rootidmap_cleanup /tmp/rootidmap/" RETURN
root="$(mktemp -d /var/lib/machines/TEST-13-NSPAWN.owneridmap-path.XXX)"
# Create ext4 image, as ext4 supports idmapped-mounts.
mkdir -p /tmp/owneridmap/bind
- dd if=/dev/zero of=/tmp/owneridmap/ext4.img bs=4k count=2048
+ truncate -s $((4096*2048)) /tmp/owneridmap/ext4.img
mkfs.ext4 /tmp/owneridmap/ext4.img
mount /tmp/owneridmap/ext4.img /tmp/owneridmap/bind
trap "owneridmap_cleanup /tmp/owneridmap/" RETURN
ip link add $netdev type dummy
blk="$(mktemp)"
-dd if=/dev/zero of="$blk" bs=1M count=1
+truncate -s 1M "$blk"
loopdev="$(losetup --show -f "$blk")"
# Wait for devices created in the above being processed.
verity_size="$(du --apparent-size -k "$MINIMAL_IMAGE.verity" | cut -f1)"
signature_size=4
# 4MB seems to be the minimum size blkid will accept, below that probing fails
-dd if=/dev/zero of="$MINIMAL_IMAGE.gpt" bs=512 count=$((8192+root_size*2+verity_size*2+signature_size*2))
+truncate -s $(((8192+root_size*2+verity_size*2+signature_size*2)*512)) "$MINIMAL_IMAGE.gpt"
# sfdisk seems unhappy if the size overflows into the next unit, eg: 1580KiB will be interpreted as 1MiB
# so do some basic rounding up if the minimal image is more than 1 MB
if [[ "$root_size" -ge 1024 ]]; then
if [[ "$(findmnt -n -o FSTYPE /)" == btrfs ]]; then
btrfs filesystem mkswapfile -s 64M /swapfile
else
- dd if=/dev/zero of=/swapfile bs=1M count=64
+ fallocate -l 64M /swapfile
chmod 0600 /swapfile
mkswap /swapfile
fi
# Must not be in tmpfs due to exclusions. It also must be large and
# compressible so that the compression check succeeds later.
src=/etc/test-source-file
- dd if=/dev/zero of="$src" bs=1M count=1 2>/dev/null
+ fallocate -l 1M "$src"
tee "$defs/btrfs-compressed.conf" <<EOF
[Partition]
udevadm wait --settle --timeout=30 "${devices[0]}"
mount "${devices[0]}" "$mpoint"
for i in {1..4}; do
- dd if=/dev/zero of="$mpoint/lun$i.img" bs=1M count=32
+ truncate -s 32M "$mpoint/lun$i.img"
done
# Initialize a new iSCSI target <$target_name> consisting of 4 LUNs, each
# backed by a file
udevadm control --reload
TMP_DIR="$(mktemp -d -t -p / integrity.tmp.XXXXXX)"
-dd if=/dev/zero of="${TMP_DIR}/image" bs=1048576 count=64
-dd if=/dev/zero of="${TMP_DIR}/data" bs=1048576 count=64
+truncate -s 64M "${TMP_DIR}/image"
+truncate -s 64M "${TMP_DIR}/data"
LOOP="$(losetup --show -f "${TMP_DIR}/image")"
udevadm wait --timeout=30 --settle "${LOOP}"
systemd-umount "$WORK_DIR/overlay"
# Set up a simple block device for further tests
-dd if=/dev/zero of="$WORK_DIR/simple.img" bs=1M count=16
+truncate -s 16M "$WORK_DIR/simple.img"
mkfs.ext4 -L sd-mount-test "$WORK_DIR/simple.img"
LOOP="$(losetup --show --find "$WORK_DIR/simple.img")"
udevadm wait --timeout=60 --settle "$LOOP"