Tell me more ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

My current situation is:

  • One hard disk
  • Dual boot Ubuntu 11.04 and Windows 7. Partitions:
    • 100MB Windows System thingy
    • 144GB Main Windows
    • 160GB Ubuntu
    • 4GB Swap
    • 12GB System Restore stuff

Now I want to install an 80GB SSD and move Ubuntu to it. AFAIK I need to:

  • Shrink the 160GB Ubuntu partition to 80GB
  • Copy it over to the SSD
  • Change fstab to mount the SSD as /

How do I do the second? And what do I need to do about Grub?

share|improve this question

2 Answers

up vote 26 down vote accepted

You want to copy the FILES, not the whole partition ( including its free space ), so you don't need to resize the partition first. Boot from the livecd and mount both the HD and SSD ( after formatting a partition on the SSD of course ), then copy all of the files over:

sudo cp -ax /media/hd /media/ssd

Use the correct names for the hd and ssd mount points of course. Then you just need to edit the /etc/fstab on the ssd to point to the new fs UUID ( you can look it up with blkid ). Finally you need to install grub on the ssd:

sudo -s
for f in sys dev proc ; do mount --bind /$f /media/ssd/$f ; done
chroot /media/ssd
grub-install /dev/ssd
update-grub

Of course, use the correct device for /dev/ssd. The whole disk, not a partition number. Finally reboot and make sure your bios is set to boot from the SSD.

share|improve this answer
2  
I'm posting this comment from my system running perfectly on the SSD. Thanks – Bart van Heukelom May 6 '11 at 12:14
1  
Just something I found doing this with a second PC: The live CD needs to be 64 bits if the OS you're moving is 64 bits too, or the chroot won't work. – Bart van Heukelom Aug 28 '11 at 22:45
What does the chroot command do, and why is it necessary? – codeape Oct 20 '11 at 12:26
@codeape, it makes the kernel pretend that the target directory ( /media/ssd ) is the root directory ( / ) so that when you run grub-install and update-grub they think they are being run from the hard disk, not the livecd, and will install correctly to the hard disk instead of trying to install to the livecd. – psusi Oct 20 '11 at 14:40
Ok, I see. Thanks. – codeape Oct 20 '11 at 14:48
show 3 more comments

Considering your HDD is /dev/sda and SSD is /dev/sdb and partitions are properly sized, you may use simple cp:

cp /dev/sdaX /dev/sdbY

Where X and Y are corresponding partition numbers.

However this method will copy 80GB of data and all sectors on your SSD will be marked as "occupied" initially.

share|improve this answer
Sound easy enough, but that last sentence doesn't mean much to me. Is it, or could it be, a problem? – Bart van Heukelom May 5 '11 at 14:56
Well it might negatively impact your SSD speed (however with TRIM support it would recover later). You may read en.wikipedia.org/wiki/TRIM for more information. But, you should really go the route described in the other reply (copy files, not partitions). If you still decide to copy the whole partition, you need to perform grub-install/grup-update as well. – Vilmantas Baranauskas May 6 '11 at 7:41
1  
I wouldn't recommend this approach, it will copy all the filesystem errors you may have on your old partition. The cp -ax approach is both quicker and safer. – Andrei Sosnin Nov 23 '12 at 17:36

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.