5

I am looking to use an embedded Linux distro such as Tiny Core as a automated recovery type tool.

Basically, the user would choose to boot into Tiny Core from the boot menu, then if a USB is plugged in containing a ghost type image of the drive (it would contain a unique UUID that udev rules would detect and only then would it start imaging), it would restore the entire hard drive. Now my problem is finding a utility like Ghost for Linux that will do the imaging.

The best part about Ghost is that

  1. it does a file-by-file copy so it's very fast and the resulting compressed image is small, and
  2. it dynamically resizes the drive so if you are imaging a 10 GB drive onto a 20 GB drive, it will image the drive and then resize it automatically, fixing the partition table if necessary.

dd is obviously not an option for this reason, it copies every sector of the drive and it does not have the ability to dynamically resize so if for some reason the destination drive is even 1 byte smaller than the source, it will fail. partimage has similar issues.

CloneZilla is the only tool for Linux that I've seen powerful enough to do something like this, but it's obviously it's own distro and not able to be integrated into a Linux distribution. Since CloneZilla is just a collection of low level tools though, anyone know how it actually clones a hard drive?

What would be the best way to do something like this? I've been searching for an answer on this for years and still have not found a solid solution. 'Til this day, we use an ancient version of Ghost because it images whatever we need flawlessly, but we'd like to get away from proprietary tools and DOS and head towards an open source solution.

1
  • Is this something that you want for backup/restore, or for initial deployment in a preconfigured/known-good state?
    – bahamat
    Jun 20, 2012 at 0:17

5 Answers 5

7

FSArchiver (http://www.fsarchiver.org/Main_Page) may do what you're looking for. Disk images include only data, not free space, and can be restored to disks of differing sizes.

1
  • 1
    FSArchiver looks like it may work, I will have to check this out, thanks a lot, I've never heard of it but it looks like a lot of Linux imaging tools use this. It also works at the file level, not sector, and recreates the filesystem so it may be just what I'm looking for.
    – Jack
    Jun 19, 2012 at 12:36
1

While this may not suit exactly your needs, it does much accommodate much more so than dd.

The program is ddrescue, and is a GNU utility. On most systems, the package is named gddrescue, though on Gentoo, for example, it is simply named ddrescue. It has error control -- if you run into errors, it'll keep going, but you can also have it stop after X errors, or X error rate (with -e and -E flags). You can have the image stored with sparse files with the -S flag, which will allocate free space with only the metadata; basically, free space in the image will take up negligible space, though the file itself will report the correct size when you do ls -hs. You can have it write to a log file, which is recommended.

Unfortunately, it does not do dynamic resizing; that is, it can't grow or shrink to fill a drive. But it does one thing and it does it well. For resizing, I recommend restoring the image with ddrescue, then resizing the drive with GParted (or use parted for resizing if you feel comfortable).

For more information, I recommend reading the ddrescue homepage and the man page for ddrescue.

0

How can you igonre the traditional dd command ??

See man pages of it, to clone any linux or window machine.

5
  • 2
    dd presents problems as mentioned above. It natively does a sector-by-sector copy (which makes it very slow, unless you move all the data to the front of the drive and zero out the rest) so if the target HDD is smaller than the source (even if only 1% of the drive is used), it will fail. dd is powerful yes, but not practical when imaging entire hard drives. Trust me, I've considered, and used this before. Dynamic resizing is something I haven't seen in any utility except for Ghost (maybe CloneZilla as well).
    – Jack
    Jun 19, 2012 at 12:04
  • It won't matter, if the target HDD is small. You can opt for bs and count arguments of DD to specify, how long you want to do dumping.
    – SHW
    Jun 19, 2012 at 12:20
  • The problem is the fact that these days, SSD controllers will flag certain blocks as "bad" and then the drives will be of varying sizes. So I have used dd in the past limiting the count to a certain number of blocks, but this requires resizing the drive afterwards, which there is no easy way to do afaik. How would I image an entire drive (with say 4 partitions) with dd to another drive that is not the same size? I don't think that is too transparent with dd.
    – Jack
    Jun 19, 2012 at 12:35
  • For 4 partitions, I will prefer to use DD partition-wise. If any block is BAD, I assume DD will ignore it and will not count it's presence.
    – SHW
    Jun 19, 2012 at 12:45
  • The question itself says dd is not an option, so that makes this a bad answer. Further, dd is not a backup tool; it is a swiss army knife. If you have dd not copy the whole drive, then you end up with a corrupt filesystem on the destination.
    – psusi
    Jun 19, 2012 at 13:29
0

For emergency recovery I use Parted Magic booted from USB. It has several useful imaging tools built in. And, booted from USB or CD, by default, it copies itself to ram and runs from there, freeing up the USB port or optical drive for other actions.

0

CloneZilla is the only tool for Linux that I've seen powerful enough to do something like this, but it's obviously it's own distro and not able to be integrated into a Linux distribution.

The clonezilla folks encourage you to use it in the form of their livecd or netboot system, but clonezilla is available as a Debian package and I have successfully installed and used it on a regular Debian system. I think the program you want to run is "ocs-sr".

Since CloneZilla is just a collection of low level tools though, anyone know how it actually clones a hard drive?

Fundmamentally the process of cloning a drive can be broken down into.

  1. Clone the partition table with adjustments for drive size if needed.
  2. Clone any boot code that lives outside of partitions
  3. Clone the content of partitions, again with adjustments for drive size if needed.
  4. Make any other adjusments needed so the system can boot.

The tricky part is that the details for each of those steps depend on what exactly is on the drive, afaict what clonezilla does that the lower level tools it's built-on don't is the ability to analyse the drive and work out what steps are needed to clone it.

To clone the actual partition data IIRC clonezilla can use either "partclone", "partimage" or "dd", i'm not sure which is the default nowadays. Unfortunately none of these tools can shrink a partition, so if your partitions won't fit on the target drive you are out of luck.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .