LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Newbie seeks strategy for cloning system drive (https://www.linuxquestions.org/questions/linux-newbie-8/newbie-seeks-strategy-for-cloning-system-drive-4175552363/)

Adams Seven 09-01-2015 05:43 PM

Newbie seeks strategy for cloning system drive
 
I installed Linux Mint 17.2 four days ago, and realize I don't know how to clone an image file of my boot drive.

This 'disk cloning' article -- https://wiki.archlinux.org/index.php/Disk_cloning -- told me how to use DD. I tried to run it, but learned that DD needs an unmounted drive. Does that mean I can only use DD by booting from a DVD drive and running DD from the CD/DVD?

Another article pointed me toward Clonezilla. I started to tinker with that, then decided that I should seek feedback from experienced users on other options. If anyone can suggest a strategy for cloning or backing up the boot drive, I'm eager to hear it!

I'm willing to pay for a separate USB drive as a back-up medium, and also to buy commercial software, if necessary.

frankbell 09-01-2015 06:27 PM

Take a look at Clonezilla.

wpeckham 09-01-2015 08:24 PM

Cloning
 
Are you sure that you understand what "cloning a drive" means?

It is taking one drive that is loaded and usable, and a second that is empty and blank, and copying from the full drive to the empty in such detail that they are logically identical.

For most purposes, that means you can have the first drive mounted, but the empty drive you clone TO should be an unmounted device. You do not want file system or device activity using the drive while you are attempting to write boot blocks and partition information onto it.

Did I clear anything up, totally confuse you, or just waste bandwidth?
;-)

syg00 09-01-2015 08:50 PM

I have similar reservations.

<soapbox>
"dd" is absolutely the worst option for a backup ... other than no backup at all
</soapbox>

OK, now that's out of the way - why do you think you need to "clone" the system drive ?.
How many drives do you have ?. Is Windows in the mix ?.

There are plenty of reasons to do this, but pitfalls await the unwary. Recently I suggested relax-and-recover, however the OP in that thread responded by saying s?he had trouble with restoring. I have yet to test it, so can't comment, but it looks a good idea.
I also use mondorescue but it can be (mighty) slow if you verify the backed up image(s). I use this to image a system just after I have it all set up at a point where I might want to restore an a clean image. Windoze and all. Note I have never had to use this to bring back a full machine.
Generally I just back up my data since that is what is valuable - the system can always be re-installed pretty easily. Another option (even for the system) is fsarchiver - it verifies the data as it is backed up.

All the above options ensure the filesystem is readable (with errors reported), and only back up the used portion of a filesystem. "dd" does none of that, and cannot be trusted to make a good, usable copy. Linux being what it is, there are plenty of other options.

fatmac 09-02-2015 03:42 AM

Welcome aboard.

Cloning images your system, I think you only need to back up your files, unless you intend on making a second identical installation from your cloned image.

Your personal data is all that you need to back up, this can be done easily, you can just copy them to an external disk, archive them using tar & gzip/bzip2 & store on external media, or use rsync to copy & incrementally update your back up.

Germany_chris 09-02-2015 05:23 AM

Every computer I own has a boot drive clone total failure = me selecting a new boot drive or popping in a different one in and I'm back to work.

aarcov 09-02-2015 05:35 AM

What type of backup are you after exactly? Is it one where you will be frequently updating the data, or just an initial original backup (if all it is only a backup of a fresh install, may I ask why this is needed?). For data that is frequently changing there are many options availible, from the humble rsync, to the more complex backuppc (I really like this one) and bacula.

jpollard 09-02-2015 06:53 AM

Quote:

Originally Posted by Adams Seven (Post 5414462)
I installed Linux Mint 17.2 four days ago, and realize I don't know how to clone an image file of my boot drive.

This 'disk cloning' article -- https://wiki.archlinux.org/index.php/Disk_cloning -- told me how to use DD. I tried to run it, but learned that DD needs an unmounted drive. Does that mean I can only use DD by booting from a DVD drive and running DD from the CD/DVD?

nope. It just means you need to be careful, and decide what you actually need.

The reason it says "dismounted" is that it is the easiest way to make sure filesystems on the disk don't change while you are making the copy.

Since you want to clone the system disk, you CAN do it - but the best way is to boot into single user mode, with the root disk mounted read only. This allows you to use the disk to read programs from(as in running the shell, using dd). It also means that the root filesystem can not be modified during the copy.

You CAN do it while on-line... But what it looks like if you use the disk in another system (or having to replace the system disk for some reason) is that the system crashed. The filesystem is dirty... and depending on how many changes occured during the copy, the filesystem MAY not be usable.

I've done that... but I also knew exactly what files were open for modification, and tested it to see if things rebuilt properly in the target disk before it was ever used.

Quote:


Another article pointed me toward Clonezilla. I started to tinker with that, then decided that I should seek feedback from experienced users on other options. If anyone can suggest a strategy for cloning or backing up the boot drive, I'm eager to hear it!

I'm willing to pay for a separate USB drive as a back-up medium, and also to buy commercial software, if necessary.
Clonezilla knows filesystems, which allows it to use the filesystem during the copy - and knows how to copy the non-filesystem based information (such as partition table, boot blocks...) which can make some things easier.

from: http://clonezilla.org/

One of the problems with using dd occurs because some information gets copied that needs changing (clonezilla does that I believe) Things like volume labels, UUID labels, logical volume headers... can cause boot failures if the clone disk is left in the system after the clone is completed; and the system gets rebooted. This happens because the boot system tries to identify the disk it is to boot by one of the labels (a common lable for the root filesystem is "root" - if there are two "root" filesystems, the boot code can't determine which one to use).

Adams Seven 09-02-2015 08:04 AM

First: thanks to all who responded! I'm grateful to you for taking the time to help a very new user.

I asked about cloning because I'm here from the Windows world, and used system image to make a back-up copy of my boot drive under Win 7. But I should point out that I don't have to do it that way with Linux.

I compute with two drives: the boot SSD, with Linux Mint installed, and a separate data drive. After several days of configuration work, the boot drive is now loaded with personal settings and Linux software. I'd be S.O.L. if this boot SSD were to fail now, because I don't have a back-up of it. (I do have back-ups of the data drive.)

I'm still figuring out my way around the Linux file system, but see that my user account is under the /home directory, and that many programs seem to live in /usr/share. There may be other configuration files scattered in other directories I don't now know enough to inspect. I'd like to back up all those personalized directories and files, and be confident that I can easily restore them if the SSD dies.

I could live with swapping in a fresh boot drive and installing a fresh copy of Linux Mint on it, so long as I can easily and safely copy over all my personalized stuff to quickly make it whole again. If the new installation of Linux Mint would choke if I copied over, say, the whole /usr/share directory, then I'm barking up the wrong tree, and need to look again at Clonezilla.

If I can do the job with rsync or tar, then great! Or I can investigate FSArchiver (thanks, syg00) or backuppc, as aarcov suggests. (Although I'd like to get a copy of backuppc separately from sourceforge, after reading articles like: http://www.howtogeek.com/218764/warn...ou-can-help-it )

descendant_command 09-02-2015 08:28 AM

Quote:

Originally Posted by aarcov (Post 5414700)
there are many options availible, from the humble rsync, to the more complex backuppc (I really like this one) and bacula.

For an Indiana Jones metaphor, backuppc and bacula are the dudes with the garish outfits and the leaping and spinning and the flashing swords - rsync is the guy in the hat that fires one shot then walks off with the girl ... ;)

syg00 09-02-2015 08:46 AM

Quote:

Originally Posted by Adams Seven (Post 5414747)
I'm still figuring out my way around the Linux file system, but see that my user account is under the /home directory, and that many programs seem to live in /usr/share. There may be other configuration files scattered in other directories I don't now know enough to inspect. I'd like to back up all those personalized directories and files, and be confident that I can easily restore them if the SSD dies.

Set up a separate partition for /home. Back that up (fsarchiver is good for a baseline backup). Backup /etc.

The beauty of a separate /home is that you can totally re-install, and use the /home again at install time. Use the same users(s) and password(s) and it'll all "just work". Then install all the packages you need (you can use apt to list them if you want). Then either use the /etc backup to tell you what you had, or just copy particular config files back over the new system. Carefully. Easy - and clean.

Of course, backups need to be current, so you might want to look at differential backups so you only lose a little in a catastrophe rather than weeks or months worth.

aarcov 09-02-2015 09:02 AM

Backuppc should be in the repo's. It sounds like you may not be to concerned about having multiple backups over some time period, so what I would probably do (assuming you have another drive/share that is large enough) is use either part image or clonezilla to copy the drive to an image file and then occasionally run rsync for a seperate backup of just those two folders (perhaps every time you make a major change, or as a scheduled task). This way you have a copy of your original drive and a more recent backup of your configurations and such.

kilgoretrout 09-02-2015 09:07 AM

If you use tar, rsync, fsarchiver or backup software that use rsync or tar under the hood, you will be able to restore your boot drive but you will not be able to boot off it since those tools do not backup the mbr. There are ways to reinstall the bootloader, grub, once you restore from that backup, but they are somewhat complex for someone new to linux. Clonezilla does backup the mbr and restores from a clonezilla backup will leave you with a bootable machine. For that reason alone, I would recommend clonezilla.

Ihatewindows522 09-02-2015 09:17 AM

Could also run Deja Dup from a live USB.

schneidz 09-02-2015 09:24 AM

i would boot a live-usb on the usb drive. then run something like:
Code:

dd if=/dev/sda of=/home/liveuser/sda.iso bs=8192
this assumes that the usb disk is bigger than the internal disk.
caution: dd can be very destructive and care should be given which device is being written to.
related:
http://www.linuxquestions.org/questi...es-4175551279/


All times are GMT -5. The time now is 04:57 AM.