Hands on: Brush up your images
Running the command again
R E L A T E D   C O N T E N T
ADVERTISEMENT

Hands on: Brush up your image

Linux can treat an image file – an exact copy of your disk data – as a device itself

Barry Shilliday, Personal Computer World 22 Mar 2007
ADVERTISEMENT

A partition on a hard drive holds a filesystem, which is an ordered and structured layout on the disk for files and directories to be stored on.

Linux – or any other operating system – must be able to understand how this layout works to read and write to it, and thus access the files in any way, and it does this using a filesystem driver.

The raw data on the disk, however, needs no such understanding. The operating system needs only to be able to read and write to the disk itself which, in an operating system such as Linux, is handled completely separately from the filesystem drivers.

A raw image of a drive or partition can be created using the dd or ddrescue commands. These read every byte on the drive and duplicate it exactly. The resulting file is known as an image, since it reflects the exact contents of the original.

Any filesystem can be duplicated in this way, so long as Linux can read each byte from the source successfully.

Loop filesystems
When you mount a block device (such as a partition), you make it accessible for reading and writing. A typical mount command is something such as:

# mount /dev/hda1 /var/myfiles

Here the filesystem stored on the hda1 partition is laid onto the root filesystem in the /var/myfiles directory. This is standard across all forms of Unix and you have no doubt seen or used the command before.

However, what difference is there between a device file such as /dev/hda1 and an image file created by duplicating the data on that device? Each contains the same data, laid out in exactly the same way.

It would be useful if Linux could treat the image file like a device and mount it as such. And it can.

As above, the driver that handles the filesystem (such as ext3 or Fat) is entirely separate from the driver that handles the disk drive (such as IDE or Sata); one is effectively layered on top of the other.

This means that the only practical difference between mounting an image file and mounting a device is at the lowest level: the filesystem driver is the same.


All Open Source and Linux
Tags: Linux and Unix

Like this story? Spread the news by clicking below:

Post this to Delicious del.icio.us    Post this to Digg Digg this    Post this to reddit reddit!

Permalink for this story
R E A D E R   C O M M E N T S
M A R K E T P L A C E
Get your free demo of Numara Track-It! 8 - the leading help desk solution for IT related issues.
Make presentations, review documents & share your entire desktop. 30-day free trial! (cc required).
Discover how remote support can fuel your IT business in ways you've never thought of before.
Apply ITIL best practices at your service desk while eliminating integration cost. Learn more here.
WAN based, automated, daily vulnerability assessments. Click here to try and request our whitepapers.
Have your product or service listed here >   
Sponsored links
F E A T U R E D   J O B S
Hertfordshire, United Kingdom | Tesco.com
Database Operations Team Leader - Hertfordshire Who's behind the world's most successful online retailer?Just over 10 years ago we started Tesco.com (aka Dotcom). Today, we've an incredible 750,000 active customers and sales at just under £1 ... more >
London, United Kingdom | BP
Business Analyst - £ Competitive - London About BP Our business is the exploration, production, refining, trading and distribution of energy. This is what we do, and we do it on a truly global scale. ... more >
United Kingdom | Ofgem
IT Network and Security Engineer £40,000 per annum The Office of Gas and Electricity Markets (Ofgem) is the regulator for Britain's gas and electricity industries. Our role is to protect consumers and enable them to ... more >
Hertfordshire, United Kingdom | Tesco.com
Senior Business Analyst - Hertfordshire Who's behind the world's most successful online retailer? Just over 10 years ago we started Tesco.com (aka Dotcom). Today, we've an incredible 750,000 active customers and sales at just under ... more >
More job opportunities