2

I see a lot of dd related questions, but could not find answers to the following. If question/answers already exist, please point to them, then flag to close, delete or merge.

  1. Can a working linux installation (say on /dev/sda7) be cloned to an external hard disk partition (say /dev/sdb2), while on it? (/dev/sdb is a 1TB USB hard disk, /dev/sdb2 is of size 100GB)
  2. If not, can I do it using a live cd? Will the cloned partition on external drive be bootable?
  3. If it is not bootable, how to do that?

Why want to do that ? : Need to carry the cloned external drive than the laptop itself, with all the installed (& customized) programs and data.

Additional info (relevant parts only):

$ sudo fdisk -l
Disk /dev/sda: 160.0 GB, 160041885696 bytes
Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        2550    20482843+   7  HPFS/NTFS
/dev/sda7            5660        6904    10000431   83  Linux

$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda7             9.4G  7.4G  1.6G  83% /
daisy
  • 54,555

3 Answers3

2

DD is a wonderful utility for doing any of the tasks, but it is (potentially)problematic; mix up source and destination discs, you are screwed. There is a 'distribution' based on Debian that does everything you want using DD under the hood. It is clonezilla which can be downloaded from http://clonezilla.org/. I have used it on many different machines without a hitch. It will also copy the MBR so the disc could be booted.

Alan

apolinsky
  • 563
1

You can clone a mounted filesystem, but it's a bad idea because you'll be copying the filesystem in an inconsistent state. There's a real risk of losing data.

There are ways to clone a mounted filesystem, but they require preparation beforehand. For example, if the filesystem is on a block device that permits mirroring (such as LVM volumes or md-raid RAID1 volumes), you can create a mirror, then sever its link with the original. LVM also allows the creation of snapshots: an image of a filesystem, frozen in time, which can be safely read (cloning at the block device level is a bit iffier but possible in some cases).

So to answer your question: 1. no. 2. yes; yes but not automatically. 3. You need to install a bootloader on the external disk.

Since you'll need to reboot anyway, I recommend booting under a specialized tool for disk backups and maintenance, such as GParted or Clonezilla.

0

The easiest way is compress whole fs with partimage and restore it on the other computer.

daisy
  • 54,555