I Have a dual boot machine (windows+ubuntu) with 350 GB HDD. I wish to clone only ubuntu to the 120GB SDD. How can I accomplish this.

PS: I have copied Linux partition(sda5) to SDD using "dd", What i need to do to preserve the geometry of a disk so that it can boot.

Disk /dev/sda: 298.1 GiB, 320072933376 bytes, 625142448 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x000f3d7c

Device     Boot     Start       End   Sectors  Size Id Type
/dev/sda1  *         2048    718847    716800  350M  7 HPFS/NTFS/exFAT
/dev/sda2          718848 200712992 199994145 95.4G  7 HPFS/NTFS/exFAT
/dev/sda3       369358848 625139711 255780864  122G  6 FAT16
/dev/sda4       200714238 369358847 168644610 80.4G  5 Extended
/dev/sda5       200714240 353449983 152735744 72.9G 83 Linux
/dev/sda6       353452032 369358847  15906816  7.6G 82 Linux swap / Solaris

Start over. Read this whole answer through at least once before you start, and make sure you understand it. If necessary copy it to an editor and fix up the assumed references to /dev/sdaX and /dev/sdbX. Really. You want to get these right because you have a very easy opportunity to break your existing installation completely and utterly. Really.

  1. Partition the SSD.

    • You may need an UEFI boot partition.
    • You will need a partition that is at least the size of your /dev/sda5 Linux partition.
    • You may want a Swap partition.
  2. Copy the Linux partition you want to keep

    • Boot from a rescue disk
    • ASSUMING the target is /dev/sdb2, run cat /dev/sda5 >/dev/sdb2
    • Don't bother with dd. Using cat is no slower and usually far faster
  3. Resize the target filesystem to fit the partition

    • ASSUMING the target is /dev/sdb2 and your filesystem type is ext3 or ext4, run resize2fs /dev/sdb2
  4. Still using the rescue disk

    • ASSUMING the target is /dev/sdb2, run chroot /dev/sdb2 /bin/bash
    • Run the following commands, but be aware that your commands may vary depending on distribution

      grub-install /dev/sdb   # Second disk
  5. Reboot and ensure that the new system can start up

  6. Fix up the swap partition if you have one

    • ASSUMING your new swap is /dev/sdb3, run mkswap /dev/sdb3
    • Edit /etc/fstab to update (or comment out) the swap UUID definition
  7. Remove your old disk and reboot

    • You may need to change the grub boot parameters temporarily to reference hd0() rather than hd1(). If so...
    • Run the following commands, or their equivalents, once more

      grub-install /dev/sda    # First disk, this time
  8. Reboot once more

    • By this stage it should be booting smoothly

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.