3 # copy a linear file from srcFile to destination disk in a loop until writeSize MBs is written
4 # destinationDisk is a SMR Host Aware Disk eg. /dev/sdb
6 if [ "$#" -lt 3 ]; then
7 echo "Usage ./linearCopy.sh srcFile destinationDisk writeSize(MB)"
11 if [ "$(id -u)" != "0" ]; then
12 echo "Please run as sudo user"
25 #chunkSize=4096 # in bytes
26 chunkSize=1048576 # in bytes
27 fileSize=`stat --printf="%s" $srcFile`
29 numChunksInFile=`echo "$fileSize * (1048576 / $chunkSize)" | bc`
30 chunksLeft=$(( $(($writeSize * 1048576)) / $chunkSize))
33 echo "fileSize = $fileSize"
35 if [ "$(($fileSize % 512))" -ne 0 ]; then
36 echo "$srcFile not 512 byte aligned"
40 if [ "$(($chunkSize % 512))" -ne 0 ]; then
41 echo "$chunkSize not 512 byte aligned"
45 if [ "$fileSize" -lt "$chunkSize" ]; then
46 echo "filesize $fileSize should be greater than chunkSize $chunkSize"
51 numFileChunks=$(($fileSize / $chunkSize))
52 if [ $verbose == true ]; then
53 echo "numFileChunks = $numFileChunks"
56 smrLBAStart=33554432 # TODO query from SMR Drive
59 offset=$(( $smrLBAStart / $(( $chunkSize / 512)) ))
61 if [ $verbose == true ]; then
62 echo "chunksLeft = $chunksLeft, offset = $offset"
67 while [ "$chunksLeft" -gt 0 ]; do
68 chunkNum=$(($chunkNum + 1))
69 if [ $verbose == true ]; then
70 echo "CHUNK $chunkNum `date +%H:%M:%S`" >> time
72 dd if=$srcFile of=$destDisk seek=$offset bs=$chunkSize 2> tmp
73 cat tmp | grep MB >> time # > /dev/null 2>&1
74 if [ $verbose == true ]; then
75 echo "chunksLeft = $chunksLeft, offset = $offset"
77 chunksLeft=$(($chunksLeft - $numFileChunks))
78 offset=$(($offset + $numFileChunks))
85 if [ $verbose == false ]; then
88 echo "Time Stamp for Chunk Writes"