Commit 1fdecd0a authored by Dimitris Aragiorgis's avatar Dimitris Aragiorgis Committed by Nikos Skalkotos

Allow overriding dd and blockdev commands

Let the user provide their own dd and/or blockdev commands,
if desired.
Signed-off-by: default avatarDimitris Aragiorgis <dimitris.aragiorgis@gmail.com>
parent 5af6d49c
# Copyright (C) 2011-2016 GRNET S.A.
# Copyright (C) 2011-2016 GRNET S.A. and individual contributors
# Copyright (C) 2007, 2008, 2009 Google Inc.
#
# This program is free software; you can redistribute it and/or modify
......@@ -29,6 +29,8 @@ TAR="tar"
DATE="date -u" # Time in UTC
KVM="kvm"
MD5SUM="md5sum"
BLOCKDEV="blockdev"
DD="dd"
# Temporary use stderr as monitoring file descriptor.
# `create' will overwrite this
......@@ -227,7 +229,7 @@ create_floppy() {
target=$(mktemp -d)
add_cleanup rmdir "$target"
dd bs=512 count=2880 if=/dev/zero of="$img"
$DD bs=512 count=2880 if=/dev/zero of="$img"
mkfs.ext2 -F "$img" > /dev/null
mount "$img" "$target" -o loop
......
......@@ -175,9 +175,9 @@ if [ "$BACKEND_TYPE" = "local" ]; then
# Deploying an image file on a target block device is a streaming copy
# operation. Enable the direct I/O flag on the output fd to avoid polluting
# the host cache with useless data.
$monitor dd bs=4M if="$image_file" of="$target" oflag=direct iflag=fullblock
$monitor $DD bs=4M if="$image_file" of="$target" oflag=direct iflag=fullblock
else
$image_cmd | $monitor dd bs=4M of="$target" oflag=direct iflag=fullblock
$image_cmd | $monitor $DD bs=4M of="$target" oflag=direct iflag=fullblock
fi
report_info "Image copy finished."
......
......@@ -142,3 +142,5 @@
# TIMEOUT="timeout"
# CURL="curl"
# TAR="tar"
# BLOCKDEV="blockdev"
# DD="dd"
#!/bin/bash
# Copyright (C) 2012 GRNET S.A.
# Copyright (C) 2012-2016 GRNET S.A. and individual contributors
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -35,10 +35,10 @@ fi
# Export disk's predicted size to Ganeti.
# Used to provide a time estimate of the export process to the user.
if [ -n "$EXP_SIZE_FD" ]; then
blockdev --getsize64 "$blockdev" >&$EXP_SIZE_FD
$BLOCKDEV --getsize64 "$blockdev" >&$EXP_SIZE_FD
fi
dd if="$blockdev" bs=4M
$DD if="$blockdev" bs=4M
# Execute cleanups
cleanup
......
#!/bin/bash
# Copyright (C) 2012 GRNET S.A.
# Copyright (C) 2012-2016 GRNET S.A. and individual contributors
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -32,7 +32,7 @@ if [ ! -b "$blockdev" ]; then
add_cleanup $LOSETUP -d "$blockdev"
fi
dd of="$blockdev" bs=4M
$DD of="$blockdev" bs=4M
# Execute cleanups
cleanup
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment