13

Wouldn't it be nice if I could just get my system set up right after I install it, with all of the themes and programs and SDKs that I want, and then just save that snapshot? Like a backup, except I'd be able to boot that image and install it on whatever machine I'd like to?

I'm pretty sure this is possible. In fact, I know that it is to some extent.

https://help.ubuntu.com/community/LiveCDCustomizationFromScratch

But is there a better way? Does someone know magic that I can use? Can't I just save my system state so that when I install some unsupported server software and I brick my system, I don't need to spend another hour setting it up?

  • Are you running a "bare metal" installation or a virtual machine? – Wildcard Apr 11 '16 at 18:28
  • This would be bare metal. As in I want to get my perfect "starting point setup" to start from, so instead of popping in a USB with a freshly-downloaded image, I have a custom image that I can boot from and install. – Jacob Apr 11 '16 at 18:29
  • You may want to look into "creating a Vagrant box." – Wildcard Apr 11 '16 at 18:32
  • @derobert Only noticed your comment now, but I was already typing my answer then... – Fabby Apr 11 '16 at 19:26
  • 1
    @Fabby Comments aren't answers. Even if you shamelessly stole it and turned it into an answer, that's fine with me—you added four additional paragraphs of explanation, you deserve to have the answer for that. – derobert Apr 11 '16 at 20:10
10

I use both CloneZilla and Back In Time to do system and data back-ups respectively.

The advantage of CloneZilla over built-in tools like dd is that it uses its own partclone which creates very small images (it recognizes sparse files, can use a number of compression utilities, ...) and falls back to ddrescue which allows reading of damaged hard drives! (Nice to have that very last back-up before the HDD finally gives up completely.)

You should however have (at a minimum) a separate / and /home if you want to easily differentiate between your OS and user config files.

Nothing is as flexible, robust and fast as CloneZilla to do full off-line image/disk back-ups (and I'm always reading back-up manuals if someone mentions its favourite back-up tool to see whether they've got something better then I have)

If you put CloneZilla onto a 512 MByte bootable partition of an external USB HDD, you can just boot it on any machine and restore any backup you've made to the partition taking the rest of that same HDD.

Warning: if you restore the same system back-up to multiple machines all these machines will be clones of one another with the same host name, time zone, IP (if static), ... so all these need to be personalised after "restore"...

Alternatively, I have a bootable USB SLC stick that has a full install of Linux (in my case lubuntu) without any proprietary drivers and a leading FAT partition, no swap partition but a swap file inside the / partition that I can boot on any machine (so far) and that I use to disinfect Windows machines (or just work on someone else's machine without touching their data if they're paranoid).

  • 1
    BTW: You might want to mention some of the stuff that'll need to be changed to make multiple machines from one using Clonezilla (e.g., change hostname, IP, ...) – derobert Apr 11 '16 at 20:10
3

Yes there is a way. The machine doesn't even always need to be the same, since Linux creates the /dev, /proc and /sys filesystems on the fly as the kernel boots which gives you a lot of freedom to make some pretty drastic hardware changes.

Let's say your OS is installed on disk /dev/sda. You can make an ISO of /dev/sda and all of its partitions, whatever they may be, with the following command:

dd if=/dev/sda of=/path/to/image.iso

The downside to this is that the image will be the full size of the disk you specified as if (input file), even if that disk is not full.

If you'd like to clone the disk directly from /dev/sda, simply insert another disk and use something like:

dd if=/dev/sda of=/dev/sdb
1

You might want to look into squashfs. It's what the "live" versions generally use, and you can "unsquash" it directory by directory to whatever partitions you like. It's scriptable, extensible and takes command parms from a list file, if you like. Like a zip file that actually works as a static filesystem without full extraction. It has it's limitations, of course, but with a bit of work it will let you do what you want with more granularity than Clonezilla and more brains than dd. The linux forums will have something on creating your own live image.

0

if the machine will always be the same, using dd might come in handy in this situation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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