Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am running Ubuntu 11.04. But now due to some or other reasons I have to format my entire disk and reinstall the Ubuntu, But I have Installed many softwares on Natty. And when I'll reinstall the ubuntu, I have to again reinstall all those updates , drivers and softwares too. So I want to ask is there any way so that I can make an .iso image of installed Ubuntu along with all the softwares, preferences, drivers etc. existing in it ? Is there any way so that I can back up my whole OS along with all its softwares, drives, updates n all ?

share|improve this question
2  
Backing up the whole OS is a valid question, however, the reason you give: "I have to format my entire disk and reinstall the Ubuntu" seems odd. Why would you want to format the disk you have when you then want to reinstall really everything you currently have on it anyway? –  Martin Aug 5 '11 at 10:39

7 Answers 7

up vote 3 down vote accepted

there are various ways to do that. The simplest one is using remastersys

sudo remastersys dist 

You should install ubiquity package before working with remastersys

or you can use fsarchiver, redo-backup (A live cd)

How to backup your operating system

share|improve this answer
    
Remastersys..! It rocks..! Thank you @ jahid65. :) –  Avinash Sonawane Aug 9 '11 at 21:36

If you have Ubuntu installed on a single harddisk and you have another harddisk of equal or larger storage capacity, then cloning the disk is really simple:

sudo dd if=/<from disk> of=<to disk>

So, for example, if you want to clone sda to sdb, then you would do sudo dd if=/dev/sda of=/dev/sdb. That would retain all partitions, boot manager, etc.

Be careful to use the correct if (input file) and of (output file). The input file is the disk you want to copy. If you switch order, then you will clone the empty disk onto the full one, which will leave you with two blank disks. :)

Also make sure that the new disk has sufficient space to clone the first disk. Otherwise it'll just be chopped off at the end. There will be no warnings.

If you want to create an image, then simply replace of=/dev/sdb with of=/some_place/disk-image.raw. Store it on another disk.

share|improve this answer
    
I don't have any extra external hdd. I just want to restore or backup the whole OS along with all the updates, drivers n all into a single .iso file. so that when I'll format my disk and reinstall the Ubuntu I'll not be downloading and reinstalling that huge amount of data(softwares, drivers etc.) –  Avinash Sonawane Aug 5 '11 at 8:25
    
sure. Then, as I said on the last line: dd if=/dev/disktobackup of=somefile.img. That will be a complete copy of the disk, so you are going to have to store it somewhere. ISO-files are called that because of the ISO9660 filesystem used on CD-ROMs. We usually call them raw or img or something when we image a harddisk. –  Jo-Erlend Schinstad Aug 5 '11 at 12:44
    
@jo-erlend so will it work moving from one partition to another ? The bootloader and all sort of things ? –  Hari K T Aug 11 '11 at 18:24

In China, some friends use ucloner in Ubuntu to backup the OS.

https://code.google.com/p/ucloner/

UCloner is a backup/restore/clone tool designed for Ubuntu Linux. In some way it's just like Norton Ghost for Windows.

With UCloner you can backup your Ubuntu system to a squashfs image file. Directly from this image file you can boot up a PC into a so-called "Live Ubuntu" environment (need "casper" package).

An active ubuntu system can clone itself into a/some target partition(s) with the help of UCloner. Remember Agent Smith in Matrix ? yeah, that's it.

It has both command line and graphical interface. It's more flexible when running in command line interface.

UCloner is free software, distributed under GPL v2.

enter image description here

share|improve this answer

Once you get all your data and reinstall, you may want to try using Clonezilla to take an image of your OS. If something goes wrong, just pop in the OS image and you'll have your system back to where it was.

share|improve this answer

I have a script that migrates an Ubuntu install to another location, e.g. in your case you could migrate it to an external hard drive. The neat thing is that you can independently boot it and confirm that it's working before formatting your old drive. It's an exact copy - no configuring, reinstalling or tweaking required. You just have to prepare the target partition. (It also doesn't modify the current install so you can test the migrated one before formatting the old one.)

http://ubuntuforums.org/showthread.php?t=1519354

(Yes it's the wubi migration, but it does normal migrations too. I use it all the time to backup and restore different installs)

share|improve this answer

I answered "How to customize live Ubuntu CD?" with a way of creating live CDs from current installations. This means that you will not need to download all the packages again. This guide may seem long and hard, but it is mostly "follow along" and "copy and paste". Here it is, copied out and edited a bit:

Creating a live CD from an existing/new installation

A good way would be making a live CD from a current installation. This can be done using a virtual machine (just don't install any VM tools inside the guest OS)

So, first we need a fresh install(if you can't install it for real, try using a virtual machine) with only things that you need (in your case thunderbird, samba and ssh). Then we tweak the system and record where the tweaks are (e.g. you change your desktop background, the settings are in ~/.gconf or you add firefox shortcuts, they are located in ~/Desktop). This is needed for step 4.

  1. Set up some variables:

    export WORK=~/temp
    export CD=~/livecd
    export FORMAT=squashfs
    export FS_DIR=casper
    

    Replace ~/temp with a path to a temporary directory in which we will work in. Replace ~/livecd with a path to the CD tree.

  2. Make the folder structure. sudo mkdir -p ${CD}/{${FS_DIR},boot/grub} ${WORK}/rootfs

  3. Now we will need to install some packages:

    sudo apt-get install grub2 xorriso squashfs-tools
    
  4. Now we will copy the current installation, modify the exclude flags to fit your needs:

    sudo rsync -av --one-file-system --exclude=/proc/* --exclude=/dev/* \
    --exclude=/sys/* --exclude=/tmp/* --exclude=/home/* --exclude=/lost+found \
    --exclude=/var/tmp/* --exclude=/boot/grub/* --exclude=/root/* \
    --exclude=/var/mail/* --exclude=/var/spool/* --exclude=${WORK}/rootfs \
    --exclude=/etc/fstab --exclude=/etc/mtab --exclude=/etc/hosts \
    --exclude=/etc/timezone --exclude=/etc/shadow* --exclude=/etc/gshadow* \
    --exclude=/etc/X11/xorg.conf* --exclude=/etc/gdm/custom.conf \
    / ${WORK}/rootfs
    

    If you have a separate boot partition, execute this: sudo cp -av /boot/* ${WORK}/rootfs/boot
    If you want to copy your user configurations and files, modify this list as needed: CONFIG='.config .gconf Desktop someotherfolder andanotherfolder' And now we copy your configurations and files:

    cd ~ && for i in $CONFIG
    do
    sudo cp -rpv --parents $i ${WORK}/rootfs/etc/skel
    done        
    
  5. Now we chroot into the new system and modify it.

    sudo mount  --bind /dev/ ${WORK}/rootfs/dev
    sudo mount -t proc proc ${WORK}/rootfs/proc
    sudo mount -t sysfs sysfs ${WORK}/rootfs/sys
    sudo mount -t devpts devpts ${WORK}/rootfs/dev/pts
    sudo chroot ${WORK}/rootfs /bin/bash
    

    The next commands are done in chroot:

    LANG=
    apt-get update
    apt-get install casper
    

    Casper contains live scripts. Now the installer (gnome version) apt-get install ubiquity ubiquity-frontend-gtk Or if you want KDE:

    apt-get install ubiquity ubiquity-frontend-kde
    
  6. Update modules.dep and initramfs:

    depmod -a $(uname -r)
    update-initramfs -u -k $(uname -r)
    
  7. Remove non-system users - do not worry, we have copied the settings and data into the "skeleton" of users. That means all new users will have them.

    for i in `cat /etc/passwd | awk -F":" '{print $1}'`
    do
        uid=`cat /etc/passwd | grep "^${i}:" | awk -F":" '{print $3}'`
        [ "$uid" -gt "999" -a  "$uid" -ne "65534"  ] && userdel --force ${i} 2>/dev/null
    done
    
  8. Clean up:

    apt-get clean
    find /var/log -regex '.*?[0-9].*?' -exec rm -v {} \;
    find /var/log -type f | while read file
    do
        cat /dev/null | tee $file
    done
    rm /etc/resolv.conf /etc/hostname
    
  9. Exit chroot. exit

  10. Now, we copy the kernel:

    export kversion=`cd ${WORK}/rootfs/boot && ls -1 vmlinuz-* | tail -1 | sed 's@vmlinuz-@@'`
    sudo cp -vp ${WORK}/rootfs/boot/vmlinuz-${kversion} ${CD}/boot/vmlinuz
    sudo cp -vp ${WORK}/rootfs/boot/initrd.img-${kversion} ${CD}/boot/initrd.img
    sudo cp -vp ${WORK}/rootfs/boot/memtest86+.bin ${CD}/boot
    
  11. So that the installer doesn't install things like casper:

    sudo chroot ${WORK}/rootfs dpkg-query -W --showformat='${Package} ${Version}\n' | sudo tee ${CD}/${FS_DIR}/filesystem.manifest
    sudo cp -v ${CD}/${FS_DIR}/filesystem.manifest{,-desktop}
    REMOVE='ubiquity casper user-setup os-prober libdebian-installer4'
    for i in $REMOVE 
    do
        sudo sed -i "/${i}/d" ${CD}/${FS_DIR}/filesystem.manifest-desktop
    done        
    
  12. Unmount what we have mounted:

    sudo umount ${WORK}/rootfs/proc
    sudo umount ${WORK}/rootfs/sys
    sudo umount ${WORK}/rootfs/dev/pts
    sudo umount ${WORK}/rootfs/dev
    
  13. Convert to squashfs:

    sudo mksquashfs ${WORK}/rootfs ${CD}/${FS_DIR}/filesystem.${FORMAT}
    
  14. Make filesystem.size: echo -n $(sudo du -s --block-size=1 ${WORK}/rootfs | tail -1 | awk '{print $1}') | sudo tee ${CD}/casper/filesystem.size

  15. And md5: find ${CD} -type f -print0 | xargs -0 md5sum | sed "s@${CD}@.@" | grep -v md5sum.txt |sudo tee ${CD}/md5sum.txt

  16. Now grub.cfg:

    sudo nano ${CD}/boot/grub/grub.cfg
    

    (replace nano with your fav text editor, it doesn't matter) Paste this and save:

    set default="0"
    set timeout=10
    
    menuentry "Ubuntu GUI" {
    linux /boot/vmlinuz boot=casper quiet splash
    initrd /boot/initrd.img
    }
    
    
    menuentry "Ubuntu in safe mode" {
    linux /boot/vmlinuz boot=casper xforcevesa quiet splash
    initrd /boot/initrd.img
    }
    
    
    menuentry "Ubuntu CLI" {
    linux /boot/vmlinuz boot=casper textonly quiet splash
    initrd /boot/initrd.img
    }
    
    
    menuentry "Ubuntu GUI persistent mode" {
    linux /boot/vmlinuz boot=casper boot=casper persistent quiet splash
    initrd /boot/initrd.img
    }
    
    
    menuentry "Ubuntu GUI from RAM" {
    linux /boot/vmlinuz boot=casper nopersistent toram quiet splash
    initrd /boot/initrd.img
    }
    
    menuentry "Check Disk for Defects" {
    linux /boot/vmlinuz boot=casper integrity-check quiet splash
    initrd /boot/initrd.img
    }
    
    
    menuentry "Memory Test" {
    linux16 /boot/memtest86+.bin
    }
    
    
    menuentry "Boot from the first hard disk" {
    set root=(hd0)
    chainloader +1
    }
    
  17. Make the CD/DVD! sudo grub-mkrescue -o ~/live-cd.iso ${CD}

  18. Test it using a virtual machine!

All credit goes to capink, because the guide is from here.

share|improve this answer
    
@nickguletskii- Since I m completely a newbie, Is there any software to do this ? By the way thanks for your reply. –  Avinash Sonawane Aug 5 '11 at 8:26
    
@Avinash remastersys and/or Ubuntu Customization Kit. –  Uri Herrera Aug 5 '11 at 9:16
    
@Avinash Sonawane It will pretty much be a straight forward "copy and paste" routine, just take the commands and execute them. –  nickguletskii Aug 5 '11 at 9:27
    
Since I am totally a newbie.. I preferred Remastersys over just copying n pasting and that too so many commands. By the way these commands worked.! :) Thank you @nickguletskii :) –  Avinash Sonawane Aug 9 '11 at 21:38
    
@Avinash Sonawane No problem, and thanks for verifying! :) –  nickguletskii Aug 10 '11 at 5:42

What you can do is to backup your home directory and save a list of all packages that you have installed. To save the list of installed software use following command:

sudo dpkg --get-selections > package_list

This will create a file with a list of all pakcages/softwares that are installed on this system. You will need to backup this file to somewhere safe.

Then when you reinstall ubuntu on your machine you can use the following command to install all these software

sudo dpkg --set-selections < packages_list

This command WILL NOT install anything. It will just mark the packages for install. To install them, run the following command:

sudo apt-get -u dselect-upgrade

This will take time to complete as your system will download and install all the packages. After this command is complete replace your current home directory with the one you backedup previously.

Hope this helps

share|improve this answer
    
but don't I need to reinstall the packages in a new installed Ubuntu ? –  Avinash Sonawane Aug 5 '11 at 8:16
    
@Avinash: that command will reinstall the packages in the newly installed Ubuntu –  Jeremy Kerr Aug 5 '11 at 8:28
    
@Jeremy- i mean.. that command will fetch (download) the packages and then install them or I don't have to download anything whichever I have downloaded uptill now ? Actually i don't want to download anything which I already have since it consumes a considerable amount of time to download this huge data. –  Avinash Sonawane Aug 5 '11 at 8:34
    
@Avinash: sorry, forgot to add command to update. I have updated the answer plz check. –  binW Aug 5 '11 at 10:33
    
Not quite the method I'd use, but the overall effect is the same. –  MBraedley Aug 8 '11 at 20:13

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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