How to Use dd Command to Take Backup | dd Command Tricks and Tips

dd command is used to convert or copy a file. it has the following important parameter
if=input file
of=output file
bs=bytes
1024 bytes as 1 KB
512 bytes*2=1024 kilo bytes
So now I create file with 2 block for 512 bytes
[san@backup home]# dd if=/dev/sda of=/home/t.image bs=512 count=2
2+0 records in
2+0 records out
1024 bytes (1.0 kB) copied, 7.8353e-05 seconds, 13.1 MB/s
[san@backup home]# ls -lh t.image
-rw-r--r-- 1 san san 1.0K May  8 09:47 t.image
Now we are creating 1MB and count as one so it will create 1MB file.
/dev/zero it will create the file while reading the data it will return as zero.
[san@backup ~]# dd if=/dev/zero of=boot.img bs=1M count=1
1+0 records in
1+0 records out
1048576 bytes (1.0 MB) copied, 0.00297976 seconds, 352 MB/s
[san@backup ~]# ls -lh boot.img
-rw-r--r-- 1 san san 1.0M May  8 09:42 boot.img


To Clone the Entire Hard disk
#nohup dd if=/dev/sda of=/dev/sdb &
In the mean time to check Process Status
#ls -l /proc/”Process id of dd command”/fd/ (or)
#lsof -p “Process id of dd command
#watch du -sh "output Device Path"

How to Convert File From Lower Case to Upper Case
[root@localhost ~]# vi lowercase  >>type any lowercase document

[root@localhost ~]# dd if=lowercase of=uppercase conv=ucase
0+1 records in
0+1 records out
25 bytes (25 B) copied, 0.000138513 seconds, 180 kB/s

[root@localhost ~]# vi uppercase
open the file all the lower case character will be modified as uppercase

Related post