To Check if the 'dd' command is using Sparse :
#!/bin/bash
# set -x
file_name="tttt.img"
`dd if=/dev/zero of=$file_name bs=1024 count=10 seek=10`
sp_file_size=`du -h $file_name | awk '{print $1}'`
sp_file_size_app=`du -h --apparent-size $file_name | awk '{print $1}'`
echo " Comparing the actual & apparent file sizes ..."
if [ $sp_file_size == $sp_file_size_app ]; then
echo " Failed to create Sparse file: $file_name"
return 1
else
echo " Sparse file in deed sparsed... "
fi
本文介绍了一段bash脚本,用于验证使用'dd'命令生成的文件是否为稀疏文件。通过比较实际大小和显式大小,确保文件的有效性。

被折叠的 条评论
为什么被折叠?



