Clonezilla like app for the desktop?
What I am looking for is a way to clone hard drives (mainly windows partitions) while staying inside of the Ubuntu OS. I do not want to create a partition on the hard drive to boot off of and I am not wanting to use a boot cd. The only thing I can even think of that is close is the 32bit version of ghost that can run from the desktop in windows.
It doesn't have to be clonezilla, but that is the only linux cloning software I have used and have almost used it exclusively since I discovered it. If there is no way to use clonezilla from the desktop, then I will accept an alternative program. The main thing is that it clones drives and runs from within Ubuntu.
Thank you for your time in advance
Solution 1:
Clonezilla uses dd
behind the scenes.
About disks and partitions
A whole disk is a device like /dev/sda
. This is the first disk, the second disk is /dev/sdb
, the third /dev/sdc
, etc. Older disks connected through an IDE cable are named like hda
, hdb
, ... A disk can have multiple partitions like /dev/sda1
. The second partition on disk /dev/sda
is /dev/sda2
and so on. An image (literal copy of bytes) can be made from both a partition and disk. Note that first 512 bytes of a disk contains the MBR (Master Boot Record).
A partition should not be mounted when creating or restoring images, otherwise data loss may occur when reading from it (creating an image) or unexpected bahavior and data corruption if you're writing to it (restoring from a image).
In the below examples, /dev/sda1
is the partition from which an image should be created.
Partitions and disk devices in /dev
are only writable by the superuser (root) and users of the disk
group. I dislike running everything as root, so for safety (in case you made a typo for example), I change the group temporary to myself, so I can read and write to it:
sudo chgrp my_user_name /dev/sda1
If you skip the above command, you've to prefix the below dd
commands with sudo
.
Basics
The basic command for creating an image from a partition is:
dd if=/dev/sda1 of=disk.img
if
means "input file", of
means "output file". Everything in Linux is a file, even devices.
To restore such an image, run:
dd if=disk.img of=/dev/sda1
The order does not matter, you could have written the above as dd of=/dev/sda1 if=disk.img
too.
Compressed images
Since partitions are generally big, it's recommended to compress the data before writing it to the image:
dd if=/dev/sda1 | gzip > disk.img.gz
This works because if of
is omitted, the output is written to "standard output" which is the pipe to the compress program gzip
. The output of that is written to disk.img
.
To restore such a compressed image, run:
gunzip -c disk.img.gz | dd of=/dev/sda1
Here, gunzip
is the reverse command of gzip. -c
causes the output be written to standard output which is the pipe to the dd
command. Because if
is omitted on dd
, the input is read from "standard input" which is the output of gunzip
.
Reading from an image without restoring it
Uncompressed images can be mounted so you can read from it. Should you've compressed your partition images, uncompress them first (disk.img.gz
will be removed, disk.img
will be created. Be sure to have enough space!):
gunzip disk.img.gz
Alternatively, uncompress an image without touching the image itself:
gunzip -c disk.img.gz > disk.img
Now create a directory on which the disk can be mounted and mount the image read-only (ro
):
sudo mkdir /mnt/wind
sudo mount -o ro disk.img /mnt/wind
You can now view your files in /mnt/wind
. When done, unmount it and remove the obsolete mount point:
sudo umount /mnt/wind
sudo rmdir /mnt/wind
Less size, more CPU usage, longer backup and restore duration
If time is not an issue and you don't have much storage space, you could use the bzip2
compression format. Simply replace gzip
by bzip2
in the above. It's common to use the .bz2
extension for bzip2-compressed files, so do so.
Solution 2:
Do you want to clone one hard disk to other? There are several ways to do that. I generally prefer dd command. Please note that to use this command, you would need sudo access.
-
To clone Hard disk 1 into Hard disk 2. Note that Hard disk 2 must be of greater size than hard disk 1. If your source hard disk is sda and target hard disk is sdb then you can copy all contents of sda to sdb using following command.
dd if=/dev/sda of=/dev/sdb
-
To clone whole hard disk 1 into an image, use following command. Note that ~/disk1.img should be residing on different disk
dd if=/dev/sda of=~/disk1.img
-
To clone single partition into image, use following command. Note that image file should not reside on same partition.
dd if=/dev/sda1 of=~/drive1.img
-
To restore image, use following command.
dd if=drive1.img of=/dev/sda1 - For Partition dd if=disk1.img of=/dev/sda - For whole hard disk
-
You can also save space by compressing image file.
gzip disk1.img - This will generate disk1.img.gz bzip2 disk1.img - This will generate disk1.img.bz2
Courtesy: Linux Backup: Hard Disk Clone with "dd"