Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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% /
share|improve this question

3 Answers 3

up vote 1 down vote accepted

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.

share|improve this answer
    
Thanks for the nice answer. Can you add how to install bootloader (esp. if using GParted or Clonezilla Live)? –  Noble P. Abraham Sep 14 '12 at 4:26
1  
@NobleP.Abraham It depends on your bootloader. The easiest thing is to chroot into the backup and run the bootloader installation program from there (e.g. for Grub: update-grub; grub-install /dev/something). By the way, are you making a backup, or an installation that can be used independently? If the latter, you should change a few things that should be globally unique. See Moving linux install to a new computer and How can I most easily migrate all my apps and settings from one Ubuntu install to another? –  Gilles Sep 14 '12 at 11:25
    
Thanks, those links are much useful. I am trying to clone the installation, to be used independently. That's why I removed the /backup and /partition tags. (But it is added again :( ) –  Noble P. Abraham Sep 14 '12 at 14:22

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

share|improve this answer

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.