In my daily work at Canonical I use VM's quite often to test Ubuntu Web Apps and new browser releases in different environments. I use a MacBook Pro 15" (mid 2012) as the main computer, currently running Ubuntu 13.04. This computer had rEFIt to boot and the default OSX system. Of the 500 GB, just 75 were dedicated to Linux, so I was forced to delete VM's or backup them in an external hard disk to re-use them. Finally, I decided to buy a SSD, which are quite cheap nowadays.
The SSD I bought was a Samsung 840 250 GB (not Pro version, which has some additional features). It costs 179 €.
This are the steps I followed to move my Ubuntu setup from a HD to a SSD.
- Burn a DVD with Ubuntu. I reused an old 12.04 disk, the -mac version.
- Boot Ubuntu from the DVD.
- Attach an external USB drive. This is used to (backup and) copy the partition from the HD to the SSD.
- Run gparted as root to copy the Linux partition (in my case, an ext4).
To copy the partition, I resized the USB drive partitions to live room to the HD's Linux partition, which is 75 GB. Then, in gparted I selected the partition from the HD, selected "Copy" from the partition menu and then "Paste" it in the spare space in the USB drive. This step took +40 minutes. At this point, the Linux partition is available in the external disk.
After that, I switched off the computer and replaced the HD with the SSD. Follow the link to see how. Now, the second part: to move and setup the system to the solid state disk. The SSD disk was blank, so it needed proper configuration.
- Boot Ubuntu from the DVD.
- Attach the external USB drive.
- Run gparted.
- Create a partition table in the SSD. I used GUID Partition Table (gpt) format, the one the original HD uses.
- Partition the SDD.
- Create an EFI partition. The first partition has FAT32 format, 200 MB in size, "EFI" as label and "grub_boot" flag.
- Create the swap partition. At the end of the disk, I created a 10 GB "linux-swap" partition.
- The rest of the disk will be available for the main Linux partition.
- Copy the Linux partition to the SSD. In gparted, select the Linux partition in the USB drive, copy and paste it in the SSD. This takes +45 minutes.
- Resize the Linux partition to fill the entire disk and flag it as "boot".
Congratulations! The Linux partition is now copied bit-by-bit in the SSD. However, it cannot boot. The reasons are: rEFIt (the bootloader) is not installed; the Linux partitions are not properly configured. To do that, we need to modify the file /etc/fstab in the Linux partition (SSD).
And this is the final third step: setup the system to properly boot. In my SSD, /dev/sda1 is the EFI partition, /dev/sda2 the Linux partition and /dev/sda3 the swap partition. You may have different setup. /etc/fstab must be changed to reflect this addresses. From a terminal:
$ sudo mkdir /media/root
$ sudo mount /dev/sda2 /media/root
The Linux partition is accesible in the directory /media/root/. The file /etc/fstab/ of the Linux partition can be edited now at /media/root/etc/fstab/
$ gksu gedit /media/root/etc/fstab
This is the original content:
# /etc/fstab: static file system information.## Use 'blkid' to print the universally unique identifier for a# device; this may be used with UUID= as a more robust way to name devices# that works even if disks are added and removed. See fstab(5).## <file system> <mount point> <type> <options> <dump> <pass>proc /proc proc nodev,noexec,nosuid 0 0# / was on /dev/sda5 during installationUUID=24acabd4-2fcb-49aa-9fb3-ce9e657d4465 / ext4 errors=remount-ro,user_xattr 0 1# swap was on /dev/sda7 during installationUUID=c40532ab-5716-47bc-9b95-3672b834c6a2 none swap sw 0 0
Here, the modifications:
# / was on /dev/sda5 during installation
/dev/sda2 / ext4 discard,errors=remount-ro,user_xattr 0 1
# swap was on /dev/sda7 during installation
/dev/sda3 none swap sw 0 0
The blkid command can be run as root to find out the UUID strings of the devices and use them instead.
Then, I downloaded the compiled version of rEFInd, which is a fork of the rEFIt bootloader and able to run from Linux, Mac and Windows.
$ cd /media/root/root/
$ sudo wget http://downloads.sourceforge.net/project/refind/0.6.11/refind-bin-0.6.11.zip
This is almost done. We now "log" into the Linux partition (SSD) to apply the changes and setup the bootloaders. In order to do that successfully, the /proc and /dev from the live DVD are mounted to the Linux partition and the EFI partition (this is needed by rEFInd).
$ sudo mkdir /media/root/boot/efi
$ sudo mount -B /proc /media/root/proc
$ sudo mount -B /dev /media/root/dev
$ sudo mount /dev/sda1 /media/root/boot/efi
$ sudo chroot /media/root/
Now we're "logged" in the Linux partition as the root user. This is when GRUB and rEFInd are installed in the SSD to be able to boot Linux from the Mac.
# mount -t sysfs sysfs /sys
# cd /root/
# unzip refind-bin-0.6.11.zip
# cd refind-bin-0.6.11
# ./install-bin.sh --esp --alldrivers
# grub-install /dev/sda
# update-grub
# exit
And that's all. The system should be able to boot the Linux partition from the SSD.
Some caveats and open questions:
- I installed rEFInd first, without GRUB. rEFInd and the system wasn't able to boot.
- For some reasons, rEFInd in my system is much slower than rEFIt. It takes around 40 seconds to show up.
- After installing GRUB, I'm not able to mount the EFI partition. Now has an unkown partition format.
- Does GRUB really needs rEFInd?
References
Recent Comments