LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 11-22-2017, 12:06 AM   #1
Nomen luni
LQ Newbie
 
Registered: May 2016
Posts: 13

Rep: Reputation: Disabled
Making a perfect image of a running system?


Is there any software to make a perfect image of a running Linux system?

As I see it, something like Timeshift (rsync based) has no method to ensure all files are copied when in a consistent state- i.e. no way to copy all files as they exist in the same instant of time.

A solution based on a ZFS or BTRFS file system snapshot solves this, but still it doesn't account for what code is running at that time - so isn't it possible that although the disc is a perfect snapshot, if something was 'in the offing' on the processor that was about to make another modification it would cause a problem if this snapshot (minus processor state) was re-imaged.

Please let me know if I have any misconceptions here, and how can I make an exact snapshot of a running system that will not have any potential inconsistencies with the aim of imaging this to an identical machine if the first encounters hardware problems.

I'm running Linux Mint but this is not a Mint/Ubuntu specific question.

Thanks in advance.
 
Old 11-22-2017, 12:55 AM   #2
jsbjsb001
Senior Member
 
Registered: Mar 2009
Location: Earth, unfortunately...
Distribution: Currently: OpenMandriva. Previously: openSUSE, PCLinuxOS, CentOS, among others over the years.
Posts: 3,881

Rep: Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063
I think you need to define what you mean by a "perfect image" ?

The only way I know of to backup a Linux system (or any other system) would be to use backup/cloning software of some description. If your talking about backing up a system including what's in memory and while it's running...

You can't backup everything while the system is running. For example, files that are "in use" may not be able to be backed up.

If I'm understanding your question correctly, I don't think there is any "perfect" solution that members could suggest to you.

Why not just use hard drive based cloning software?
 
1 members found this post helpful.
Old 11-22-2017, 01:08 AM   #3
Nomen luni
LQ Newbie
 
Registered: May 2016
Posts: 13

Original Poster
Rep: Reputation: Disabled
The issue here is obtaining a snapshot of the system that is guaranteed to run without error if reinstated on the same hardware. (Assumptions: source system is not corrupt at time of imaging, no disc errors, no memory errors.)

Hard drive cloning software AFAIK does not answer the question of the running system and consistency thereof.

Is there anything similar to the volume shadow copy service on Windows, as an example?
https://technet.microsoft.com/en-us/.../ee923636.aspx
 
Old 11-22-2017, 01:12 AM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,128

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Linux snaps use filesystem freeze to ensure consistency on-disk. This generally works sufficiently, but database systems are a problem child. AFAIK, they still need to be closed and forced to disk. Same for anything else that directly manages its own I/O (direct or async I/O).
Transaction roll-back would maybe help in this case.

OpenSuSE snapper excludes portions of the filesystem(s) from snaps for rollback - see their reference manual for their reasons.
 
1 members found this post helpful.
Old 11-22-2017, 01:21 AM   #5
jsbjsb001
Senior Member
 
Registered: Mar 2009
Location: Earth, unfortunately...
Distribution: Currently: OpenMandriva. Previously: openSUSE, PCLinuxOS, CentOS, among others over the years.
Posts: 3,881

Rep: Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063
Quote:
Originally Posted by Nomen luni View Post
The issue here is obtaining a snapshot of the system that is guaranteed to run without error if reinstated on the same hardware. (Assumptions: source system is not corrupt at time of imaging, no disc errors, no memory errors.)

Hard drive cloning software AFAIK does not answer the question of the running system and consistency thereof.

Is there anything similar to the volume shadow copy service on Windows, as an example?
https://technet.microsoft.com/en-us/.../ee923636.aspx
Well, once again, there is no "perfect" solution, it depends on your requirements.

Typing into Google the following will give you a number of options to look at, "volume shadow copy like software for linux".

https://unix.stackexchange.com/quest...nternal-backup
https://serverfault.com/questions/23...-shadow-copies

The above is just two of them.

You should also understand that Linux is not Windows, there are fundamental differences between them.

Once again, hard drive cloning software should do what your asking for. This should make an exact copy of your system.

Maybe you should explain why you need a copy of a "running system" and more to the point why cloning software would not archive a similar result?

If you make a "clone" of your system, it's still going to make an exact copy of it, as it currently stands.

Last edited by jsbjsb001; 11-22-2017 at 01:23 AM.
 
1 members found this post helpful.
Old 11-22-2017, 01:28 AM   #6
Nomen luni
LQ Newbie
 
Registered: May 2016
Posts: 13

Original Poster
Rep: Reputation: Disabled
Thanks a lot syg. That's useful information and I will take a look at the reference you mention.
 
Old 11-22-2017, 09:59 AM   #7
batman23
Member
 
Registered: Mar 2004
Posts: 67

Rep: Reputation: 8
My Experience

Curious...

Just this week I had my primary harddrive with kernel and home directories have read errors.

Long story short (With a happy ending.)

I had another drive not the same size that I plugged into another linux system and partitioned accordingly.

I create an ext4 partition of a size that the files from failing partition could be copied over to with rsync.
I create the swap partition that would be needed.

Grub2 was installed on the new hard drive.

/etc/fstab was edited for the root partition using the correct /dev/sdaX entry instead of the old partition UUID.

I rebooted into the new hard drive and Grub2 did come up. Grub2 was able to bring up menu entries but from the previous systems /boot/default/grub.cfg

The main entry was edited and for the linux command within that entry, I removed the UUID for the root partition and replaced it with the /dev/sdaX

I was able to boot into the system and run "update-grub". This step would fix the /boot/default/grub.cfg to have the correct UUID for the root partition and swap partition.

I ran "blkid" to get the UUID for the new hard drives root partition and swap partition.

/etc/fstab was then replaced with the new UUID for the hard drive.

I rebooted and voila, my system is back up and running off the new hard drive. Working perfectly.

A test that I have not done is to then clone this hard drive with dd to create an image on another hard drive.
I am assuming that the image now would be perfect.

Things to consider are size of the new hard drive. I kept it small so cloning with dd would be small too. 30GB for example.

Why did I not try dd in the first place? (I actually tried it. Grub2 was only seeing a corrupted /boot/default/grub.cfg

1. My existing hard drive image would be too big to clone the entire drive.
2. Read errors would have shown up in the clone.

I kind of gave the quick description of what has worked for me.

It does not seem like what exactly you are looking to do, let me know if it might be thou.

Last edited by batman23; 11-22-2017 at 10:01 AM.
 
1 members found this post helpful.
Old 11-22-2017, 11:15 AM   #8
IsaacKuo
Senior Member
 
Registered: Apr 2004
Location: Baton Rouge, Louisiana, USA
Distribution: Debian Stable
Posts: 2,546
Blog Entries: 8

Rep: Reputation: 465Reputation: 465Reputation: 465Reputation: 465Reputation: 465
Quote:
Originally Posted by Nomen luni View Post
The issue here is obtaining a snapshot of the system that is guaranteed to run without error if reinstated on the same hardware. (Assumptions: source system is not corrupt at time of imaging, no disc errors, no memory errors.)

Hard drive cloning software AFAIK does not answer the question of the running system and consistency thereof.
While it's not a 100% guarantee, I have never had rsync fail me. Let me explain.

I use a number of systems with a "ramboot" hack. It involves a modification to initrd so that it copies the OS partition into a tmpfs file system in RAM. Then it continues to boot. I use rsync to copy the current tmpfs file system back over to the hard drive copy.

I do this while the system is running, including a GUI desktop environment and also various applications. The result is something similar to what would happen if the power suddenly cut out at the time I rsync. It's not 100% exactly the same, because files are copied over the course of a few seconds rather than at a specific instant in time.

But it works just fine. Each and every time.

Basically, all software is written keeping in mind the fact that the power could cut out at any time. Software which is badly written could, indeed, have bad errors if the power cuts out. But this is such a common failure mode that most software isn't written that badly.

An rsync pseudo-snapshot which copies over files across some seconds rather than an instant cutoff is close enough to a power failure that linux software is okay with it.
 
1 members found this post helpful.
Old 11-22-2017, 06:44 PM   #9
Nomen luni
LQ Newbie
 
Registered: May 2016
Posts: 13

Original Poster
Rep: Reputation: Disabled
More good info- thanks chaps.

I suspected rsync was usually 'good enough' as I don't see people complaining about problems with Timeshift used to image running systems. A file system that offers snapshots is then a step up from this and beyond that would be something where applications are 'snapshot aware' and can be signalled to get their affairs in order ahead of an impending snapshot (flushing to disc, consistent database states etc.)

So Isaac, why do you run from a tmpfs file system rather than, say, booting normally and just syncing to another directory? Sounds interesting.
 
Old 11-22-2017, 07:38 PM   #10
IsaacKuo
Senior Member
 
Registered: Apr 2004
Location: Baton Rouge, Louisiana, USA
Distribution: Debian Stable
Posts: 2,546
Blog Entries: 8

Rep: Reputation: 465Reputation: 465Reputation: 465Reputation: 465Reputation: 465
I use "RAMBOOT" for speed and silence, mainly. If you have a system with a good amount of RAM, it's even faster than an SSD. OTOH, if your computer is modern enough to have a USB3.0 port, you can get a really cheap USB3.0 thumbdrive that has pretty decent performance (slow by SSD standards, but still not bad).

RAMBOOT is mostly a good fit for laptops without USB3.0 ports.

NFS-RAMBOOT is a variant which loads an OS tarball from an nfs share (I still use rsync to copy back over to a normal file system tree; the use of a compressed tarball is just to make it load up faster over the network). Once the OS is loaded up, the laptop can be unplugged from the ethernet network. This is an interesting way to harden your laptop from potential attackers. Since the OS is strictly in RAM, it's impossible to just reboot the computer via liveCD or liveUSB to access the OS file system.

Alternatively, NFS-RAMBOOT is a good fit for a laptop or tablet PC which uses weird hard drive sizes or doesn't have a required caddy/cable. RAMBOOT off of USB also works.

NFS-RAMBOOT can also be a good fit when you have a lot of client computers but you only want to maintain one standard OS image.

That said, for fixed computers that are attached by gigabit ethernet, it generally makes more sense to use nfs-root rather than consuming a chunk of RAM on local storage of the OS file system. A single SSD or USB3.0 thumbdrive can store nfs-root for many computers, especially using btrfs (which can dedupe files).
 
Old 11-22-2017, 07:50 PM   #11
Nomen luni
LQ Newbie
 
Registered: May 2016
Posts: 13

Original Poster
Rep: Reputation: Disabled
Thanks for the detailed response, Isaac. Interesting possibilities I had never even considered. Sounds like it might be complicated to set up, though!
 
Old 11-22-2017, 08:55 PM   #12
IsaacKuo
Senior Member
 
Registered: Apr 2004
Location: Baton Rouge, Louisiana, USA
Distribution: Debian Stable
Posts: 2,546
Blog Entries: 8

Rep: Reputation: 465Reputation: 465Reputation: 465Reputation: 465Reputation: 465
I have detailed how-to instructions for RAMBOOT (with rsync) and NFS-RAMBOOT on my LinuxQuestions blog, as well as NFS root (which requires no custom initrd script code). I have refined and simplified things over the years.

https://www.linuxquestions.org/quest...aackuo-112178/
 
1 members found this post helpful.
Old 11-22-2017, 09:12 PM   #13
Nomen luni
LQ Newbie
 
Registered: May 2016
Posts: 13

Original Poster
Rep: Reputation: Disabled
Dude, much appreciated. I will read with interest.
 
Old 11-23-2017, 05:01 AM   #14
voleg
Member
 
Registered: Oct 2013
Distribution: RedHat CentOS Fedora SuSE
Posts: 354

Rep: Reputation: 51
I have an example of backup script that takes LVM snapshot then rsync it to NFS server.
Linux backup
Please do not leave backup NFS mounted. I've heard about someone did "rm -rf /" including it's (mounted) NFS backup server.
 
Old 11-23-2017, 05:57 AM   #15
Nomen luni
LQ Newbie
 
Registered: May 2016
Posts: 13

Original Poster
Rep: Reputation: Disabled
Cheers Voleg!
 
  


Reply

Tags
backup, image, snapshot



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Create an bootable image file of a running Slackware system aihaike Slackware 4 08-18-2016 02:26 PM
How to clone or create image of running system with RHEL7 mudasir.irfan Linux - Newbie 2 04-21-2016 06:27 AM
[SOLVED] Slackware 14.1 32bit system tarball/stage3 image/chroot image/bootstrap image vinipsmaker Slackware 20 05-14-2014 01:41 AM
Making system image of linux with clonezilla The Divine Architect Linux - Newbie 4 12-28-2011 01:56 PM
[SOLVED] Create ISO image of running Ubuntu system ken poy Linux - General 1 02-26-2011 10:23 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 09:30 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration