Friday, May 14, 2010

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
How To Take Backup Using dd Command
dd command is used to take backup or copy file  from one hard drive  to the another hard disk.
And for creating any file with specified file space.
For copy a Enter disk using these command  Trick | Tips we can take the backup
count= no of count for bytes
noerror= read the data even through error occur.
[san@backup ~]#dd if=/dev/sda5 of=/dev/sdb6 bs=4096 conv=notrunc,noerror
  noerror   It will continue to  read the dick after face the error -Redhat Rhel5 Base script
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

0 comments:

Flag counter

free counters