Moving an eeeXubuntu install from SDHC to SSD

When I first installed eeeXubuntu on my Eee PC I wanted to keep the default Xandros installation intact so I could use it to help sort out any issues that arose during the eeeXubuntu install. To this end I installed eeeXubuntu on an 8 GB SDHC card leaving the internal 4 GB sold state disk alone.

The install was painless and I never once booted back to Xandros so I decided it was time to dump Xandros and move the eeeXubuntu install to the SSD. I had already started customizing eeeXubuntu so I did not want to bother with a reinstall. A couple users on the EeeUser forums were asking how to accomplish this so I detailed the steps I took.

I just did this today.

First thing to do is repartition the SSD. I wanted to use suspend to disk so I needed a swap partition the size of the amount of RAM. You can just go with one partition if this is not important to you.

Partition Layout Before:


Device Boot Start End Blocks Id System
/dev/sda1 * 1 300 2409718+ 83 Linux
/dev/sda2 301 484 1477980 83 Linux
/dev/sda3 485 485 8032+ c W95 FAT32 (LBA)
/dev/sda4 486 486 8032+ ef EFI (FAT-12/16/32)

After:

Device Boot Start End Blocks Id System
/dev/sda1 * 1 419 3365586 83 Linux
/dev/sda2 420 484 522112+ 82 Linux swap / Solaris
/dev/sda3 485 485 8032+ c W95 FAT32 (LBA)
/dev/sda4 486 486 8032+ ef EFI (FAT-12/16/32)

Create the file systems (omit the second command if you're not using swap)
sudo mkfs.ext2 -L LABEL /dev/sda1
sudo mkswap /dev/sda2

Mount the new root file system
sudo mkdir /mnt/tmp
sudo mount /dev/sda1 /mnt/tmp

Clean out old *.deb files (optional)
sudo apt-get clean

Copy the old directories to the new new root file system. (Exclude /tmp /sys /proc /dev /lost+found /media /mnt)
This will take a few minutes (open a second terminal and use "df" to check on progress)
sudo cp -a bin boot etc initrd initrd.img lib opt root sbin srv usr var vmlinuz home /mnt/tmp/

Create empty directories for the omitted directories
cd /mnt/tmp
sudo mkdir dev sys proc mnt tmp media

Create the required device nodes in /dev
cd /mnt/tmp/dev
sudo mknod -m 660 console c 5 1
sudo mknod -m 660 null c 1 3

Open /mnt/tmp/etc/fstab with your preferred editor and make /dev/sda1 your root partition
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc /proc proc defaults 0 0
/dev/sda1 / ext2 defaults,noatime,errors=remount-ro 0 1
tmpfs /var/tmp tmpfs noatime 0 0
tmpfs /tmp tmpfs noatime 0 0

Modify the Grub configuration on the SDHC to boot from the SDD
Open /boot/grub/menu.lst and copy an existing entry, changing the root parameter so it looks like this
title           Ubuntu 7.10, kernel 2.6.22-14-generic from SDD
root (hd0,0)
kernel /boot/vmlinuz-2.6.22-14-generic root=/dev/sda1 ro quiet splash
initrd /boot/initrd.img-2.6.22-14-generic
quiet

Reboot the system choose the newly added "from SDD" option

Once booted verify that you've booted from the correct disk by typing "df"
/dev/sda1 should be your root partition
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1 3.2G 1.9G 1.1G 64% /

Final step is to install grub on the SDD
sudo grub-install /dev/sda

Remove the SDHC and reboot the system, it should now boot directly in to xubuntu from the SDD

You may need to change the BIOS boot order to keep it from booting off the SDHC when it's inserted.