2

It is possible to move an installed Linux from one drive to another or from one disk to another by two methods:

  1. dd command which copies sector by sector including boot sector
  2. cp command, and then installing/updating grub

These are very handy and easy methods, but I have no seen any instruction for using these methods for installing a new Linux on a new machine. Is there any disadvantage for this?

For example, we can boot from a Live CD, and copy the files of a minimal installed Linux (without grub); then installing grub through chroot. In other words, we can have a minimal linux on a USB drive, and install it on any machine (by boot from it, copy itself, chroot, etc).

The only things that should be altered (to my knowledge) is grub and fstab from on machine to another. Is there any disadvantage or drawback?

NOTE: I know that Live CD installers somehow do a similar task, but I am curious if simple copying can cause problem on a new machine?

strugee
  • 14,951
Googlebot
  • 1,959
  • 3
  • 26
  • 41
  • Live CDs and USB-drive distributions are very different beasts. A live CD is designed to run from read-only media and often uses tricks like file system overlays and such, which is not needed when running from read/write media such as a USB flash drive. The former has complexity which simply is not needed for an installed distribution. USB flash drive installations are much closer to a plain Linux distribution installation. – user Mar 08 '13 at 08:54
  • Right. Live CD/USB images that offer an "install to hard drive" mode generally run an actual installation process from their parent distros rather than doing a 1:1 copy of the active system. – Shadur-don't-feed-the-AI Mar 08 '13 at 09:02
  • 1
    For variations, see other questions tagged [tag:cloning]. – Gilles 'SO- stop being evil' Mar 08 '13 at 21:51

1 Answers1

4

Yes,

Mount the two disks to i.e /old and /new, and issue a rsync between them, (AS ROOT)

rsync -av --delete /old /new

Afterwards chroot into /new and restore grub configuration. (and fstab)

daisy
  • 54,555
  • Thanks for your supportive reply. I want to know if there is a possible for copying an installed linux to another machine (with different specification). Or is it safe to copy a working linux between different machines (not disks). – Googlebot Mar 08 '13 at 03:29
  • @All I don't get it, over network? If it's local, I already gave you a workable way – daisy Mar 08 '13 at 03:32
  • @All it's all safe, I've done this multiple time, just remember to fix the fstab and other stuff you might think of – daisy Mar 08 '13 at 03:33
  • @warl0ck It's still safe even if it's not local; rsync can do its magic over a network just as easily, after all. – Shadur-don't-feed-the-AI Mar 08 '13 at 08:59