Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'd like to copy a disk image of my 160GB laptop disk which currently has only Mint installed (two primary partitions, one for root and one for swap, both of which occupy a total of 13GB on the disk, with the remainder unallocated) onto a 250GB external USB drive/disk (a spare disk I happen to have, with all space unallocated). Realizing there are all different backup strategies appropriate depending on varying factors, I've decided for now I'd simply like the ability to have an easily accessible and restorable image of what I have on the laptop disk in case of one of the two following scenarios:
1. The laptop disk fails or becomes corrupted.
2. I mess up the data on the laptop disk while doing something I don't know much about (accidentally or intentionally), like altering partitions, system configurations, etc. and lose operability and am unable to restore otherwise.
So far my limited disk backup experience in this regard has consisted of using Clonezilla, of which I've been able to create a disk-to-disk clone (as opposed to a disk to image copy). This is not what I desire, however, because such a disk to disk clone copies everything, even unallocated space. I'm wanting disk to image so that for example I could copy my Mint installation as mentioned, and whatever else I might eventually have on my laptop disk in addition, so that for example if I mess up my 160Gb laptop disk I could just restore it easily right back from the 250GB external disk to it's most recent state which had been copied onto that external disk. But of course, with a disk-to-disk clone image, an attempt to restore the copied 160GB disk from the bigger disk will not work, because with that method the full 250GB including the unallocated space will want to be restored onto the smaller disk but it obviously cannot. But with a disk to image method, restoring from an image on the bigger disk back onto the smaller disk can work because the image (as I understand it) will not include all the unallocated space but only the usable data which I was wanting to have restored.
I've tried unsuccessfully with Clonezilla to create an image of the laptop disk onto my external one. I am likely not doing something right while following the Clonezilla instructions, during the process with Clonezilla it recognizes both drives but the image creation onto the external disk aborts early with a Clonezilla error message "no input device!"
I'm also aware of using Linux dd utility command line method for drive image/cloning, and rsync and such, as well as consider other sensible backup strategies, which I would like to learn/practice but being a newbie was just hoping for now to get a reliable and understandable (and restorable!) disk image backup of my laptop drive as I've described in place.
Any comments/advice appreciated. Thanks.
Distribution: Mainly Devuan, antiX, & Void, with Tiny Core, Fatdog, & BSD thrown in.
Posts: 5,491
Rep:
Quote:
I'm also aware of using Linux dd utility command line method for drive image/cloning, and rsync and such, as well as consider other sensible backup strategies, which I would like to learn/practice but being a newbie was just hoping for now to get a reliable and understandable (and restorable!) disk image backup of my laptop drive as I've described in place.
Any comments/advice appreciated. Thanks.
'dd' is the obvious choice; dd if=/dev/<disk> of=disk.img bs=1M will create the file disk.img, to restore it just reverse the proceedure.
(dd of=/dev/<disk> if=disk.img bs=1M)
Please ensure you have a separate copy of your MBR, so that you can restore just that. dd if=/dev<disk> of=mbr.img bs=512 count=1
to restore it dd of=/dev<disk> if=mbr.img bs=512 count=1
Next option is to use tar & gzip/bzip2 in combination. Please refer to the man pages for specifics, but it works something like :-
tar -cfvz / /<disk>/<mount>/<point>/disk.tar; tar -xfvz disk.tar
If I were to do dd if=/dev/sda of=disk.img bs=1M , to create the file disk.img , then I understand that the file disk.img would be located in my working directory. What then would be the next step toward getting the file disk.img onto the external USB disk?
And, just to double check, will using this command create a disk image file that will definitely not include the unallocated space on the source disk?
Last edited by sgull; 03-20-2012 at 10:22 PM.
Reason: was informed the file disk.img would get located in working directory
If you only want to backup real files, not inc 'empty' disk space try MondoRescue http://www.mondorescue.org/
Depending on what would be considered 'empty', I just don't want to have to be backing up unallocated disk space. "Unused" space within the partitions I would want to include in the backup.
"Unused" space within the partitions I would want to include in the backup.
And why would that be ?.
I've not tried mondorescue (despite Chris constantly touting it), but it seems to be just the thing for this.
I'd suggest you go read the doco.
And why would that be ?. I've not tried mondorescue (despite Chris constantly touting it), but it seems to be just the thing for this. I'd suggest you go read the doco.
The reason I would want to include the unused space within the imaged partitions (of the imaged disk) is so that I could retain the sizing I previously may have allocated for particular partitions.
I read the doco of mondorescue but honestly to me it seems rather over-complicated (from my newbie-to-Linux perspective)for what I'm wanting to achieve.
From my quick read it appears mondo sorts all that for you. What you *really* need is the size and type of the partition/filesystem.
No sense copying all that dross around. Which is (one of the reasons) why "dd" is such an appalling choice for this task.
I would have thought the quickstart would be all you need - and eminently understandable.
I see nothing there about the swap - Chris is it managed as well (one would hope so).
At the first screenshot paragraph in the Mondorescue quick-start it says "If you want to backup/restore to/from a local partition or if you simply want to store the ISO images in a local directory until you have time or facilities to burn them to CD's, choose 'hard disk'.
Well, I'm not wanting to backup/restore to/from a local partition, I am wanting to backup/restore to/from a local disk. And I'm not wanting to store ISO images so that I can later burn them to CD's. I'm wanting, as I mentioned, to backup a restorable disk image of my laptop disk onto an external USB disk (hard disk). The quick-start instructions don't seem to indicate a clear method of how I might go about specifically doing that. Instead, right off the bat, it seems like it's going off track of what I want to do.
Last edited by sgull; 03-21-2012 at 09:51 AM.
Reason: correct spelling
Well, certainly don't mean to come across as 'constantly touting it'; just a tool I was recommended by a colleague & have used that can be the right answer in some circumstances ie if you don't want to shut-down the src system and you only want real files, not unused/ space eg like dd.
IOW, you can restore to a different sized disk/partition, so long as its big enough.
You could use clonezilla or dd or rsync or ... depends on what the restrictions/expectations are.
You could use clonezilla or dd or rsync or ... depends on what the restrictions/expectations are.
My expectation is to create an image my laptop disk which currently looks like this, with only Linux Mint installed: http://imagebin.org/204013 , and my further expectation is that this image should be restorable and bootable (with MBR also imaged), but the image not to include the unallocated space of the source disk.
Not sure what the restrictions of being able to accomplish this might be. I think the biggest restriction right now may be my not being able to understand how to go about it, using any of the above-mentioned methods, i.e, clonezilla, dd, or rsync. any further advice appreciated
Distribution: Mainly Devuan, antiX, & Void, with Tiny Core, Fatdog, & BSD thrown in.
Posts: 5,491
Rep:
dd if=/dev/sda1 of=/<ext-hdd-mount-point>/disk.img bs=1M to create an image of your 11.72gb partition.
dd if=/dev/sda of=/<ext-hdd-mount-point>/mbr.img bs=512 count=1 to copy your partition table
dd if=/<ext-hdd-mount-point>/disk.img of=/dev/sda1 bs=1M to restore the image to your disk (11.72gb)
dd if=/<ext-hdd-mount-point>/mbr.img of=/dev/sda bs=512 count=1 to restore you mbr partition table
Should do what you want.
(The method you use is up to you)
dd if=/dev/sda1 of=/<ext-hdd-mount-point>/disk.img bs=1M to create an image of your 11.72gb partition.
dd if=/dev/sda of=/<ext-hdd-mount-point>/mbr.img bs=512 count=1 to copy your partition table
dd if=/<ext-hdd-mount-point>/disk.img of=/dev/sda1 bs=1M to restore the image to your disk (11.72gb)
dd if=/<ext-hdd-mount-point>/mbr.img of=/dev/sda bs=512 count=1 to restore you mbr partition table
Thanks fatmac.
Questions:
1. ext-hdd-mount-point as above would be my second (backup) disk, correct? so /dev/sdb in that place within the command line(s)?
2. What about my 1gb swap partition, would I not want to be imaging/restoring that also?
Distribution: Mainly Devuan, antiX, & Void, with Tiny Core, Fatdog, & BSD thrown in.
Posts: 5,491
Rep:
Quote:
Originally Posted by sgull
Thanks fatmac.
Questions:
1. ext-hdd-mount-point as above would be my second (backup) disk, correct? so /dev/sdb in that place within the command line(s)?
2. What about my 1gb swap partition, would I not want to be imaging/restoring that also?
Yes, /dev/sdb if that is how it gets mounted. (Depends on where & when it gets mounted.)
Swap doesn't get backed up, no need. (The swap space is in your mbr backup)
(If you do lose the swap partition, just remake it; there is nothing you need on swap.)
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.