13

As I understand it, creating an image of a Linux system makes an exact copy of the OS and any user files/configurations/programs etc.

What I would love to do is create an image of my work PC and install it at home on my desktop. Can someone briefly explain the process of creating and installing images of Linux systems?

Home OS: Windows. Want: An image file that can be executed in a virtual machine (VMPlayer or VirtualBox) or booted directly on my home PC. I have tried clonesys but would appreciate a different method.

2
  • how is the system set up and what imaging tools do you have access to? if you are using lvm it's super easy and can run on a live system. Some of the other tools require offline imaging. – RobotHumans Dec 9 '10 at 13:34
  • You need to provide more detail here, in order to get useful answers. What was "the program" that you tried? What were the image files it produced (their name and size at least)? Are you looking to replace your current OS at home, dual-boot, or run the Linux image in a VM? In any case what is your current OS at home? Do you need to make the image while the OS is actually running or would stopping it for a time be acceptable? (note: edit the extra detail into your question rather than as a comment, or the info could end up hidden after more comments are added by others) – David Spillett Dec 9 '10 at 14:08
3

something you could try.

Prepare a live cd (doesn't matter which one). Have an external storage device large enough (same size as the work HD) to hold the image.

Put the live cd into your work computer and boot it up. Mount your external storage (or even network if you are so inclined)

Use dd to clone the hard drive on your work computer and store it as an image on your storage

Shutdown your work computer

do the same exact method on your home laptop, but instead of cloning your hard drive, you'll be putting your image on your hard drive essentially you have to reverse the if= and of= commands

You might have some hardware compatibility issues right out of the box unless the hardware of your home and work comps are the same. But it is all solvable :)

Enjoy.

4
  • OP said he wanted to create an image of a running system. A live CD means the system being cloned won't be running. – Andrew Ensley Jul 7 '11 at 16:39
  • @andrew, how about reading the actual question before just skimming the title. My answer is relevant. – g19fanatic Aug 5 '11 at 16:57
  • 1
    No offense intended. I did read the whole question. The title plus the question together indicate that the OP wanted to create the image while the system was running. Hence also his reference to clonesys. – Andrew Ensley Aug 5 '11 at 17:12
  • 1
    The OP mentions nothing of needing to image a running system. Re-read his question, i take it as meaning he has a 'working' linux system and wants to clone it(running in the title can mean 'working'). His mention of clonesys is arbitrary and chalked up to unfamiliarity. You read it as him wanting a running clone (which isn't possible without running it in a VM to start with...). It doesn't read that way at all to me. What he is asking is doable with my method (and others mentioned). – g19fanatic Sep 13 '11 at 1:55
2

http://www.linux-live.org/ gives you a really simple howto of the process:

Linux Live Kit is a set of shell scripts which allows you to create your own Live Linux from an already installed Linux distribution. The Live system you create will be bootable from CD-ROM or a disk device, for example USB Flash Drive, USB Pen Drive, Camera connected to USB port, and so on. People use Linux Live Kit to boot Linux from iPod as well.

0
1

You could use partimage to create an live image. But I think it's hard to get an working live image which you can easily transfer to one pc to the other.

When you can shutdown your work pc I would recommend a live cd with partimage and create an image to an usb stick and rewrite it on the home pc.

Or if you can't shutdown your pc, you could use dump (http://linux.about.com/od/commands/l/blcmdl8_dump.htm) to a file or over network (ssh).

0

You can easily clone the OS using Clonezilla (the Live CD), but just know that the destination drive must be as big, or bigger than the original. These steps will show you how to clone the disk to another.

NOTE - backup your data

1
  • 1
    OP said he wanted to create an image of a running system. A live CD means the system being cloned won't be running. – Andrew Ensley Jul 7 '11 at 16:40
0

Here's how I've just done that:

Preparation

Windows 10 desktop

  • Install VirtualBox

The following steps are to provide a way to copy the disk image. I didn't have an external storage device with enough space to hold my laptop's disk image so I mounted my Windows machine vía SSH. There are other ways to do this, but this was easiest for me in the situation.

  • Enable WSL and reboot when prompted
  • Install Ubuntu from the Windows Store
  • Start Ubuntu from the Start Menu
  • Run sudo apt install openssh-server to install sshd
  • Run sudo nano /etc/ssh/sshd_config to edit the sshd configuration
  • Change PasswordAuthentication no to PasswordAuthentication yes, then press Ctrl+x, y, enter to save
  • Run sudo /etc/init.d/ssh restart

The Windows Firewall dialog should pop up now, click Accept to allow incoming connections.

Linux laptop

Run sudo apt install sshfs virtualbox to give you the sshfs and vboxmanage commands.

Now's a good time to test you can make an SSH connection to your Windows machine

Creating a boot image

If, in the next section, you create an image of your entire disk instead of just the Linux partition, then you probably won't need to do this.

I wanted to save space so only took my Linux root partition, but this isn't bootable by itself so I created a bootable ISO image:

Linux laptop

  • Install packages required by grub-mkrescue: sudo apt install grub-pc-bin xorriso
  • Make a directory to hold the bootable files: mkdir -p efibootiso/boot/grub
  • Copy the Grub EFI bootloader: cp /usr/lib/grub/x86_64-efi/* efibootiso/boot/grub/
  • Copy your laptop's Grub configuration: cp /boot/grub/grub.cfg efibootiso/boot/grub
  • Make the image: grub-mkrescue -o boot.iso efibootiso
  • Copy it to your Windows machine: scp boot.iso username@windowsten:/mnt/d/VMs/WorkLaptop/

Creating the disk image

Linux laptop

  • Reboot and select advanced options, then recovery mode from the bootloader
  • Select network from the recovery menu to enable networking
  • Then select the root console option and press enter
  • Run mount to check your root partition (mine is /dev/sda8 )
  • Make a temporary directory to mount your Windows machine, eg: mkdir /run/windowsten
  • Mount your Windows machine, eg: sshfs username@windowsten:/ /run/windowsten
  • Change directory to the location you want to save your disk image, eg: cd /run/windowsten/mnt/d/VMs/WorkLaptop

Here's the trick, if you run mount -o remount,ro / now then you'll get told it's in use, so instead use the magic sysrq keys: SysRq+s to force sync, then SysRq+u to force remount readonly. (SysRq on my laptop was Alt Gr + Print Screen)

  • Now make the VDI file with vboxmanage convertfromraw /dev/sda8 worklaptop.vdi

This will take a long time. I got about 10GB/hour with both machines using 802.11n wifi. Next time I'll use a wired connection.

When It eventually finishes, you'll have a disk image of your laptop's Linux partition.

Windows 10 desktop

  • Start VirtualBox
  • Click New
    • Click Expert Mode
    • Give your VM a name
    • Select the OS type and version (eg. Linux, Ubuntu (64 bit)
    • Give it enough RAM
    • Select "Use an existing virtual hard disk file" radio button
    • Click the yellow folder icon
    • Browse to and select the VDI file from the previous step
    • Click Create
  • Select your new VM
  • Click Settings
    • Click Storage
    • Select the optical Drive
    • Click the disc icon and select "Choose Virtual Optical Disc File"
    • Browse to and select the boot.iso image
  • Click System
    • Verify the optical drive is above hard disk in the boot order
    • Check Enable EFI
    • Click OK

Now you should be able to boot your VM.

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.