Basics of Raw Devices


o bind the first raw device /dev/raw/raw1 to the /dev/sdz SCSI disk or LUN you can execute the following command: # raw /dev/raw/raw1 /dev/sdz Now when you run the dd command on /dev/raw/raw1, it will write directly to /dev/sdz bypassing the OS block buffer cache: Warning The following command will overwrite data on dev/sdz # dd if=/dev/zero of=/dev/sdz count=1 To permanently bind /dev/raw/raw1 to /dev/sdz, add an entry to the /etc/sysconfig/rawdevices file: /dev/raw/raw1 /dev/sdz Now when you run /etc/init.d/rawdevices it will read the /etc/sysconfig/rawdevices file and execute the raw command for each entry: /etc/init.d/rawdevices start To have /etc/init.d/rawdevices run each time the system boot, it can be activated by executing the following command: chkconfig rawdevices on Note For each block device you need to use another raw device. To bind the third raw device to the second partition of /dev/sdz, the entry in /etc/sysconfig/rawdevices would look like this: /dev/raw/raw3 /dev/sdz2 Or to bind the 100th raw device to /dev/sdz, the entry in /etc/sysconfig/rawdevices would look like this: /dev/raw/raw100 /dev/sdz

USE DD COMMAND

Linux DD
The basic command structure is as follows:

Code:
dd if=<source> of=<target> bs=<byte size> ("USUALLY" some power of 2, and usually not less than 512 bytes (ie, 512, 1024, 2048, 4096, 8192, 16384, but can be any reasonable whole integer value.) skip= seek= conv=<conversion>

Source is the data being read. Target is where the data gets written.

Warning!! If you reverse the source and target, you can wipe out a lot of data. This feature has inspired the nickname “dd” Data Destroyer. Warning!! Caution should be observed when using dd to duplicate encrypted partitions.

Examples: duplicate one hard disk partition to another hard disk partition: Sda2 and sdb2 are partitions. You want to duplicate sda2 to sdb2.

Code:
dd if=/dev/sda2 of=/dev/sdb2 bs=4096 conv=notrunc,noerror

If sdb2 doesn’t exist, dd will start at the beginning of the disk, and create it. Be careful with order of if and of. You can write a blank disk to a good disk if you get confused. If you duplicate a smaller partition to a larger one, using dd, the larger one will now be formatted the same as the smaller one. And there will be no space left on the drive. The way around this is to use

Code:
rsync

, as described below.

To make an iso image of a CD: This duplicates sector for sector. MyCD.iso will be a hard disk image file of the CD.

code:
dd if=/dev/hdc of=/home/sam/myCD.iso bs=2048 conv=sync,no
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s