1

I would like to create an image file of my system and then load that file and get my system back, as it is right now.

The reason I am asking that, is that I would like to upgrade my laptop's hard drive (I have bought an ssd). Please note that I don't need to clone only my root partition.

Since I use my laptop for three months or so, I have installed some stuff, which I don't want to lose (programs,configuration,etc.).

My questions are:

  1. What s the best way to create that image

  2. How can I load it after the upgrade

  3. Is there a problem (and if so, can this be solved in some way?) since my drive has a 700 GB storage space and the ssd has 256 GB

  4. In what media should I store that file(I think it will be a little big.So CDs,DVDs,another external hard drive?)

I had a look at Clonezilla but as I can see in some tutorials I can only clone one partition.

What I need is to clone / ,swap and /media/{username} partitions and then restore them in the new drive.

My current partition layout is :

Number  Start   End    Size    Type      File system     Flags    
 1      1049kB  250GB  250GB   primary   ext4            boot    
 2      250GB   255GB  4999MB  extended    
 5      250GB   255GB  4999MB  logical   linux-swap(v1)    
 3      255GB   750GB  495GB   primary   ntfs

df -h gives :

Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       230G   34G  184G  16% /
none            4,0K     0  4,0K   0% /sys/fs/cgroup
udev            2,5G   12K  2,5G   1% /dev
tmpfs           510M  1,2M  509M   1% /run
none            5,0M     0  5,0M   0% /run/lock
none            2,5G  107M  2,4G   5% /run/shm
none            100M   52K  100M   1% /run/user
/dev/sda3       462G  5,7G  456G   2% /media/johnnemo/E

Could you please provide me the steps needed to achieve this goal(or at least one link that explains them in detail)?

Thanks in advance.

7
  • CloneZilla can clone the entire disk (i'd say that's what it is typically used for). See, for example: clonezilla.org/show-live-doc-content.php?topic=clonezilla-live/…. Another tool for this would be Fog.
    – muru
    Oct 24 '14 at 13:49
  • Sure..I just updated the post..
    – John
    Oct 24 '14 at 14:06
  • I do...the first one is my home partition...I don't think there are 2 slots(I have only one drive).The total space is 700 Gb.The ntfs one gets 461 GB. The /home 232 GB and the swap area 4.66 GB..
    – John
    Oct 24 '14 at 14:25
  • Then where is the root (/) partition? I think the first one is the root partition (it even has a boot flag). I was wondering about the space used (x GB out of 461 GB in the NTFS drive, for example) (if you're unsure, use df -h).
    – muru
    Oct 24 '14 at 14:29
  • Is there any command to display the mount points as well as the space of any partition to help you a bit more?
    – John
    Oct 24 '14 at 14:31
1

I'll post a way that doesn't use disk images. In this case the operation is a bit involved.

All told, you have about 40GB of data on a 750 GB disk. Making disk images of the full thing would be considerable waste of time and space.

What I'd recommend, given that the SSD is a much smaller disk, is copy the content and not the entire disk/partition:

  1. Plan the layout of the new disk according to the disk usage. Example: 100GB for / (includes /home), 5 GB for swap, and the remaining ~150 GB for the NTFS partition.
  2. Archive the content to an external drive (DVDs too small) with around 40GB of space. To do this, boot to a live USB, connect your external disk and do:

    sudo mount /dev/sda1 /mnt
    sudo tar -zcf /media/some-disk/root.tar.gz -C /mnt .
    sudo umount /mnt
    sudo mount /dev/sda3 /mnt
    sudo tar -zcf /media/some-disk/E.tar.gz -C /mnt .
    sudo umount /mnt
    

    Here /media/some-disk is where the external disk got mounted. We're creating compressed archives, which might save a bit of space, so you could make do with less than 40GB of free space on the disk.

  3. Swap your disks, boot again to the live USB, use GParted or Disks or your preferred partition tool to make the corresponding partitions. Lets assume they're numbered the same way. Now we extract the files.

    sudo mount /dev/sda3 /mnt
    sudo tar -zxf /media/some-disk/E.tar.gz -C /mnt
    sudo umount /mnt
    sudo mount /dev/sda1 /mnt
    sudo tar -zxf /media/some-disk/root.tar.gz -C /mnt
    

    Note that I haven't unmounted /mnt and that it has the root filesystem mounted on it.

  4. Now we set it up to boot correctly. This involves updating GRUB and the system's fstab. This is a regularly seen issue on AskUbuntu when the OP resizes their partitions. The steps are:

    • Note the UUIDs of the new root and swap partition. Use the blkid or lsblk commands. For example:

      $ sudo blkid
      /dev/sda1: UUID="d3504dc2-8f01-48f1-be05-d265110e2e73" TYPE="ext4
      /dev/sda5: UUID="1895a8c0-f6ea-48fc-a074-ead385f6c7f3" TYPE="swap 
      
    • chroot to the installed system:

      for i in /dev /dev/pts /sys /proc; do mount --bind $i /mnt$i; done
      chroot /mnt /bin/bash -l
      
    • In the chroot, update the fstab:

      sudo nano /etc/fstab
      

      Change the UUIDs of the root and swap partitions:

      # / was on /dev/sda1 during installation
      UUID=d3504dc2-8f01-48f1-be05-d265110e2e73 /               ext4    errors=remount-ro 0       1
      # swap was on /dev/sda5 during installation
      UUID=1895a8c0-f6ea-48fc-a074-ead385f6c7f3 none            swap    sw              0       0
      
    • Now install and update GRUB:

      grub-install /dev/sda
      update-grub
      
    • Exit the chroot and reboot:

      exit
      reboot
      
  5. Done.

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.