跳到主要內容

發表文章

目前顯示的是有「EC2」標籤的文章

Access previous(old) version Amazon Linux AMI repository

Since Amazon Linux AMI will update about every 6 month. If you need to keep repository in some specific version. i.e. if the latest is 2013.09,  and you want to stay in 2013.03, you can change the repository file to some specific version. #vi /etc/yum.d/amzn-main.repo mirrorlist=http://repo.us-east-1.amazonaws.com/ $releasever 2013.03 /main/mirror.list #vi /etc/yum.d/amzn-updates.repo mirrorlist=http://repo.us-east-1.amazonaws.com/ $releasever 2013.03 /updates/mirror.list #yum clean metadata #yum search kernel-devel --showduplicates Another tips regarding Amazon Linux is: if you use python platform.dist() to check distribution information. You will get empty string. However, I think you can use os.path.exists("/etc/image") to check if it is a AmazonLinux. That file contains detail information and it should only exists in AmazonLinux.

the wrong way to create image from sanpshot

If you create a EC2 image from the the sanshot which is a wrong way, you will end up with below error message: EXT3-fs: sda1: couldn't mount because of unsupported optional features (240). EXT2-fs: sda1: couldn't mount because of unsupported optional features (244). Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(8,1)     The wrong way is: 1. Create sanpshot from the running instance volume 2. Click the created snapshot and create image from the snapshot 3. Launch instance with the created image   The correct way is: 1. Create image from the running instance 2. Launch instance with the created image   That's it!  

Tips for bundling EC2 RHEL image with ephemeral storage

如果在 EC2 選了一個 ebs block device 是 6G 的 image, 要怎麼重新 bundle 成自己要的  image 呢? 首先是要下載 ec2-ami-tools, 裝完後, 如果你的系統有被 ruby rvm 搞爛了...導致一執行 ec2-bundle-vol 就出現 require error, 那先暫時把 path 設回系統的預設值吧! export PATH=/usr/bin:$PATH, 這時候下 ec2-bundle-vol -c /mnt/cert-XXXX.pem -k /mnt/pk-XXXX.pem -u {userid} -e /mnt -d /mnt 理論上會因為 /mnt 空間太小或者 loop device 在做轉存 image 的過程中耗光了可用空間,導致 bundle 失敗..其實 EC2 所有的 instance 都有 local 的 ephermal storage, 只是有的 instance 預設不會幫你 mount 起來, 而且 EC2 也不保證放在ephermal storage 上資料的安全性。這時候我們可以去手動把這個空間 mount 來, 做成 bundle image 時的暫存空間。以 RHEL 6.0 來說, ephermal storage 的 device id 可能為 /dev/xvd{X}, 可以先用 fdisk 看一下大小, 然後再用 mkfs /dev/xvd{X} 將其格式化在手動 mount 起來! 假設我將 ephermal storage 掛在 /emp 下,那最後用 ec2-bundle-vol 的指令就會變成 ec2-bundle-vol -c /mnt/cert-XXXX.pem -k /mnt/pk-XXXX.pem -u {userid} -e /mnt,/emp -d /emp 有時候倒霉的話還會遇到說 rsync 版本太舊,建議 upgrade後再重新 bundle 一次....不過應該可以不理它, 因為 bundle 還是會繼續....