Announcement

Collapse
No announcement yet.

How to create a backup/restore image of the OS

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How to create a backup/restore image of the OS

    I am running 9.10 on an Asus eee.
    It has 2 SSDs and NO OPTICAL drive:
    1) 4GB: OS
    2) 16GB: home directory

    I would like to create an image of the 1st drive to a 4GB USB stick.

    So that if 10.04 does not work out for some reason, I can just cast the image back on to the drive and be back in business with 9.10.

    It looks like Clonezilla might be what I am looking for. Any advice?

    p.s. can this be done with a single USB port? I have 3 and 2 are used by kb and mouse (though I guess I won't need a mouse..)
    KDE neon LTS 5.12

    #2
    Re: How to create a backup/restore image of the OS

    Check this out: http://en.wikipedia.org/wiki/Remastersys

    Please Read Me

    Comment


      #3
      Re: How to create a backup/restore image of the OS

      There is a very powerful cloning tool already in Linux. It is a program called dd.

      Read how to use it here.

      Another article gave this method:
      Best Laptop Backup: Purchase a laptop drive and an USB 2.0 drive enclosure (Total cost $100.00USD). Assemble the lappy drive into the external enclosure. Plug the external drive into the lappy USB port, and boot with The Knoppix live CD. Launch a terminal. This command will backup the existing drive:
      Code:

      dd if=/dev/hda of=/dev/sda bs=64k conv=notrunc,noerror

      This command will restore from the USB drive to the existing drive:
      Code:

      dd if=/dev/sda of=/dev/hda bs=64k conv=notrunc,noerror

      If the existing disk fails, you can boot from the external drive backup and have your system back instantaneously.
      Keep in mind that the destination drive has to be equal to or larger than the drive you want to back up. Any space not used will not be accessible.

      If you only want to back up the files on your drive you can use rsync:
      duplicating smaller partition or drive to larger partition or drive; or vice versa:
      Code:

      rsync -avH --exclude=/other_mount_point/ /mount_point/* /other_mount_point/

      You want to duplicate the root directory tree to another drive, but the other drive is larger. If you use dd, you will get a file system that is smaller then the larger destination drive. To duplicate files, not the file system: Format and mount the destination drive. Rsync will duplicate the files as files:
      Code:

      rsync -avH --exclude=/mnt/destination_drive/ /* /mnt/destination_drive/

      You need to run:
      Code:

      grub-install
      update-grub

      from a the rescue menu of an installation CD/DVD for the target to become bootable. If target was previously bootable, it remains bootable.
      "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
      – John F. Kennedy, February 26, 1962.

      Comment


        #4
        Re: How to create a backup/restore image of the OS

        Thanks all

        and thank you GreyGeek, I've never seen 'dd' explained so simply.

        since it is built in I will try 'dd' but:

        Where/when do I use the command? I'd have to be booted from a usb key correct?

        Also, does the destination have to be the same file format?
        KDE neon LTS 5.12

        Comment


          #5
          Re: How to create a backup/restore image of the OS

          I edited my previous comment to add info about using rsync, which is another way which backs up the files and hard links.

          Unlike rsync, to use dd on your HD you have to boot from another device, either a LiveCD or a LiveUSB. If you try to use dd on your system after you have booted into it you will mess up your system. dd ("data destroyer") backs up the empty space on your HD too. rsync only backs up files.

          So, for example, my notebook HD has 227G
          jerry@sonyvgnfw140e:~$ df -h
          Filesystem Size Used Avail Use% Mounted on
          /dev/sda1 227G 22G 194G 10% /
          but only 22G is used. dd will create a 227G partition image on the target HD starting at tract 0, sector 0 and exactly duplicating every byte on the source HD. If the destination drive is larger than 227G the extra space will not be available. Using rsync doesn't require that you boot a LiveCD or LiveUSB so as to not boot your target drive. You can boot up your PC normally and then as root (using sudo su - to create a root konsole) and then issue:

          rsync -avH --exclude=/mnt/destination_drive/ /* /mnt/destination_drive/
          "a" is the archive mode, "v" is the verbose setting, and "H" copies hard links. The source drive is the entire root ("/"), which includes everything under it, which is your entire system, including the destination drive, which is mounted at "/mnt/destination_drive", but the "--exclude" command prevents it from being backed up and creating an endless loop, copying itself onto itself until it wrote off the end of the destination drive.
          "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
          – John F. Kennedy, February 26, 1962.

          Comment


            #6
            Re: How to create a backup/restore image of the OS

            If you used GreyGeeks idea of a second laptop drive: why not get the same model drive that's now in your laptop? then with dd you could clone it ads often as you wanted and if the drive in your laptop fails, simply swap the drives and you're up and running!

            Please Read Me

            Comment


              #7
              Re: How to create a backup/restore image of the OS

              Excellent idea, Oshunlovr!

              I forgot to mention that if you use the rsync method you should include /proc/kcore in the excludes
              (... --excluse=/mnt/backup --exclude=/proc/kcore ... ) because kcore can get VERY large. It has been reported to be over 400 TiB in size! /proc/kcore is supposed to be an image of RAM but it seems to me it is an accumulation of the RAM image over time. Rebooting usually reduced it so something close to the actual size of your RAM, so it is a good idea to reboot just before you use rsync or dd to backup or clone.

              Another nice feature of rsync is that it is fast. Backing up to CD, DVD or USB often proceeds at a 2Mb/s or less. To my external HD my average transfer rate is over 16Mb/s.
              "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
              – John F. Kennedy, February 26, 1962.

              Comment


                #8
                Re: How to create a backup/restore image of the OS

                a) Your example saying dd needs ALL the space of a partition/hd not just what is used. Understood. Does this also apply when creating img's?

                b) I am not interested in backing up files only (I am already set up for that type of backup). So rsync doesn't apply b/c it only does files correct?

                c) Thank you for the idea, oshunluvr, but I just want to use a usb stick (I'd rather 'clone and restore' but reinstalling from scratch is not the end of the world.

                d) typing df -h, I find my usb stick is 3.8GB and sda1 is 3.7GB, so if I use 'dd', will I have trouble restoring since the destination will be smaller? or no trouble b/c the amount backed up is no greater than the destination.

                thanks!
                KDE neon LTS 5.12

                Comment


                  #9
                  Re: How to create a backup/restore image of the OS

                  dd literally makes a byte-for-byte copy period. So that means that not only does the target have to be at least the same size, it also means any bytes not used will be unusable. It copies 00 bytes as well as full bytes and the all take up the same space.

                  An image created by dd will be exactly the same size byte-for-byte as the source so your 3.7gb usb stick will not be large enough to hold a 3.8gb image file. However, some of the bytes on your usb stick that are used are holding format information. The point being that if your source partition is smaller in bytes than your UNformatted usb stick it will fit.

                  I don't know much about it, but it's possible that even with the dd copy your stick may still be un-bootable because usb devices may require a different type of format header. Regardless of that you can still restore from it.

                  Please Read Me

                  Comment

                  Working...
                  X