Moving partition containing Ubuntu (and Dropbox)

If you plan to move system with working Dropbox synchronization, please take a look at the notes below. TL;DR You have to use UUID from source partition.

Copy the partition to new drive

  1. Run Live distro with gparted. It is recommended that the user boots a LiveCD of the same release (11.10, 12.04, etc) as the release to be repaired
  2. Copy Ubuntu partition to new ssd disk
  3. Set boot flag
  4. Create new UUID for new partition (gparted created new partition with old source-UUID) from Disks app or tune2fs
  5. Copy new UUID outside (nas f.e.)
  6. SWAP – do not forget about SWAP partition!
  7. Reboot to regular, old Ubuntu

In my case I have 3 disks connected to SATA ports. New SSD disk is connected to SATA6 port

disk port sys dev partitioning
ST1000VX000 SATA1 hd0 sda MBR
WD10EZRX SATA5 hd1 sdb MBR
KingDian SATA6 hd2 sdc GPT

System boot priority is set to hd1. There are installed GRUB and my Ubuntu installation (sdb2)

I copied sdb2 to sdc1, create new UUID for new one in Disks app or by tune2fs -U random /dev/sdc1 and finally created swap sdc2 partition.

Now I have started Ubuntu from sdb2 and mount copied partition /dev/sdc1 from Disks app. Then mounted it at /media/loop/54079198...

Edit configuration files for the destination Ubuntu (@sdc)

GRUB files

UUID’s (I have shortened UUID’s to improve readability):

old: da519609...
new: 54079198...

Important: I changed it globally, because I have only one system partition on hd1 disk. Take care.

# Change hd1
sudo sed -i -- 's/hd1/hd2/g' /media/loop/54079198.../boot/grub/grub.cfg 
# Change UUID's
sudo sed -i -- 's/da519609.../54079198.../g' /media/loop/54079198.../boot/grub/grub.cfg 
# ... or do the same with $EDITOR
sudo vim /media/loop/54079198.../boot/grub/grub.cfg 


sudo sed -i -- 's/da519609.../54079198.../g' /media/loop/54079198.../etc/fstab

Backup MBR and GPT data

sudo dd if=/dev/sdb of=~/sdb.img bs=1 count=512
sudo dd if=/dev/sdc of=~/sdc.img bs=1 count=512

Install GRUB on new disk

sudo grub-install --boot-directory=/media/loop/54079198.../boot /dev/sdc

# Installing for i386-pc platform.
# grub-install: warning: this GPT partition label contains no BIOS Boot Partition; embedding won't be possible.
# grub-install: warning: Embedding is not possible.  GRUB can only be installed in this setup by using blocklists.  However, blocklists are UNRELIABLE and their use is discouraged..
# grub-install: error: will not proceed with blocklists.

FAILED! New disk is based on GPT

A small partition has to be created on the disk and marked as a code EF02 "BIOS boot partition" Remove swap partition and do it.

sudo gdisk /dev/sdc
# n, enter (first free sector), +200M, ef02,
# n, enter, enter, 8200, p, w
# 2       451041280       451450879   200.0 MiB   EF02  BIOS boot partition
sudo partprobe /dev/sdc
# Added SWAP once more again too

Install Grub again

sudo grub-install --boot-directory=/media/loop/54079198.../boot /dev/sdc
# Installing for i386-pc platform.
# Installation finished. No error reported.

Restart and boot from hd2

It works. Almost.

Dropbox installation sees that a new machine is trying to connect. I’ll try to use old UUID on new partition (don’t do that, see solution below):

Restart with Live Ubuntu

sudo tune2fs -U 98700f7b... /dev/sdb2
sudo tune2fs -U da519609... /dev/sdc1

# Mount destination partition and change UUID's
ubuntu@ubuntu:~$ sudo sed -i -- 's/54079198.../da519609.../g' /media/ubuntu/da519609.../boot/grub/grub.cfg 
ubuntu@ubuntu:~$ sudo sed -i -- 's/54079198.../da519609.../g' /media/ubuntu/da519609.../etc/fstab

# I think grub install with new UUID could be a good shot (I'm not sure if it's necessary, but...)
sudo grub-install --boot-directory=/media/ubuntu/da519609.../boot /dev/sdc

It’s not working… 🙁

Solution for Ubuntu with Dropbox sync

Start Live distro once more

  1. Restore original UUID to source partition
  2. Remove destination partition
  3. Copy partition with UUID in gparted
  4. Set boot flag on destination
  5. New UUID to source partition
  6. Grub was installed earlier, if not: sudo grub-install --boot-directory=/media/ubuntu/da519609.../boot /dev/sdc
  7. Reboot to new partition
  8. IT WORKS!!! Dropbox sync properly.

  • Link to documentation Grub2/Installing
  • Link to documentation MovingLinuxPartition

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.