Let's download the list of ec2 images, get a list lucid ebs i386 amis
ec2-describe-images --all > /tmp/ec2-images $ grep '099720109477/ebs/ubuntu-images/ubuntu-lucid-10.04-i386' /tmp/ec2-images IMAGE ami-714ba518 099720109477/ebs/ubuntu-images/ubuntu-lucid-10.04-i386-server-20100427.1 099720109477 available public i386machine aki-754aa41c ebs paravirtual IMAGE ami-1234de7b 099720109477/ebs/ubuntu-images/ubuntu-lucid-10.04-i386-server-20100827 099720109477 available public i386 machine aki-5037dd39 ebs paravirtual IMAGE ami-6c06f305 099720109477/ebs/ubuntu-images/ubuntu-lucid-10.04-i386-server-20100923 099720109477 available public i386 machine aki-3204f15b ebs paravirtual IMAGE ami-480df921 099720109477/ebs/ubuntu-images/ubuntu-lucid-10.04-i386-server-20101020 099720109477 available public i386 machine aki-6603f70f ebs paravirtual IMAGE ami-a2f405cb 099720109477/ebs/ubuntu-images/ubuntu-lucid-10.04-i386-server-20101228 099720109477 available public i386 machine aki-3af50453 ebs paravirtual
Start our instance, if you were already running a lucid server, of course you wouldn't have to do that, but for our demo, we'll create a lucid instance to upgrade it to maverick
$ ec2-run-instances ami-a2f405cb --instance-type t1.micro -k default RESERVATION r-33271c59 553172479171 default INSTANCE i-05cd0169 ami-a2f405cb pending default 0 t1.micro 2011-01-12T20:42:12+0000 us-east-1d aki-3af50453 monitoring-disabled ebs paravirtual $ ec2-describe-instances | awk '-F\t' '$1 == "INSTANCE" { print $4 }' ec2-67-202-26-253.compute-1.amazonaws.com
Let's ssh into our to-be-upgraded server, install latest lucid upgrades
ssh ubuntu@ec2-67-202-26-253.compute-1.amazonaws.com screen -S upgrade sudo apt-get update sudo apt-get dist-upgrade
Normally, you wouldn't be able to update a LTS release, except to another LTS release. We'll change that to upgrade to maverick, and start upgrading
$ sudo sed -i.bak -e 's@lts$@normal@' /etc/update-manager/release-upgrades $ do-release-upgrade Checking for a new ubuntu release Done Upgrade tool signature Done Upgrade tool Done downloading extracting 'maverick.tar.gz' authenticate 'maverick.tar.gz' against 'maverick.tar.gz.gpg' tar: Removing leading `/' from member names Reading cache Checking package manager Reading package lists... Done Building dependency tree Reading state information... Done Building data structures... Done Reading package lists... Done Building dependency tree Reading state information... Done Building data structures... Done Updating repository information WARNING: Failed to read mirror file 100% [Working] Checking package manager Reading package lists... Done Building dependency tree Reading state information... Done Building data structures... Done Calculating the changes Calculating the changes Do you want to start the upgrade? 2 installed packages are no longer supported by Canonical. You can still get support from the community. 3 packages are going to be removed. 29 new packages are going to be installed. 274 packages are going to be upgraded. You have to download a total of 124M. This download will take about 15 minutes with a 1Mbit DSL connection and about 4 hours with a 56k modem. Fetching and installing the upgrade can take several hours. Once the download has finished, the process cannot be cancelled. Continue [yN] Details [d]
Agree to any prompts while upgrading, till it actually finishes. Let's not reboot the server, instead we power it off
System upgrade is complete. Restart required To finish the upgrade, a restart is required. If you select 'y' the system will be restarted. Continue [yN]n $ sudo poweroff
Now what happened is the server has actually been updated from lucid to maverick. However, Amazon would still boot the server using a lucid kernel. That's because for ec2 the kernel is stored outside of the ebs image itself. However, recently amazon added the ability to use pv-grub for booting, that's basically a way to chainload the kernel from inside the ebs image and boot that. That actually makes the cloud server behave just like a bare metal server, which is always a good thing :) To get the aki ID for the pv-grub kernel, we simply grep for the latest maverick images, since those already have pv-grub attached to them
$ grep '099720109477/ebs/ubuntu-images/ubuntu-maverick-10.10-i386' /tmp/ec2-images IMAGE ami-508c7839 099720109477/ebs/ubuntu-images/ubuntu-maverick-10.10-i386-server-20101007.1 099720109477 available public i386machine aki-407d9529 ebs paravirtual IMAGE ami-ccf405a5 099720109477/ebs/ubuntu-images/ubuntu-maverick-10.10-i386-server-20101225 099720109477 available public i386machine aki-407d9529 ebs paravirtual
Now let's switch the upgraded image to use the pv-grub kernel
ec2-modify-instance-attribute i-05cd0169 --kernel aki-407d9529 kernel i-05cd0169 aki-407d9529 $ ec2-start-instances i-05cd0169 INSTANCE i-05cd0169 stopped pending $ ec2-describe-instances RESERVATION r-33271c59 553172479171 default INSTANCE i-05cd0169 ami-a2f405cb ec2-50-16-133-253.compute-1.amazonaws.com ip-10-112-53-225.ec2.internal running default 0 t1.micro 2011-01-12T21:27:51+0000 us-east-1d aki-407d9529 monitoring-disabled 50.16.133.253 10.112.53.225 ebs paravirtual BLOCKDEVICE /dev/sda1 vol-dc7bc9b4 2011-01-12T20:42:22.000Z
We're done, let's ssh into the new instance, and make sure it's running maverick kernel
ssh ubuntu@ec2-50-16-133-253.compute-1.amazonaws.com $ uname -r 2.6.35-24-virtual
voila, mission accomplished. Don't forget to terminate your instance
$ ec2-terminate-instances i-05cd0169 INSTANCE i-05cd0169 running shutting-down
No comments:
Post a Comment