Quickly build your own CentOS 6 & 7 AMI

Following on from my previous post Roll your own CentOS 6.5 HVM AMI in less than 15 minutes here's the snippet to for booting into an automated kickstart install for building your new AMI.

This also works for other VM providers such as Azure.

Don't forget to replace the version and appropriate snippets with your own.

version=<%= @osver %>  

# Detect primary root drive
if [ -e /dev/xvda ]; then  
elif [ -e /dev/vda ]; then  
elif [ -e /dev/sda ]; then  

yum -y install wget  
mkdir /boot/centos  
cd /boot/centos  
wget ${mirror}/${version}/os/x86_64/isolinux/vmlinuz  
wget ${mirror}/${version}/os/x86_64/isolinux/initrd.img

cat > /boot/centos/kickstart.ks << EOL  
<%= snippet 'centos_kickstart' %>

<%= snippet 'centos_post' %>  
<%= snippet 'centos_post_finish' %>  

if [ ${version} == 6 ]; then  
  echo "
  default         0
  timeout         0

  title CentOS 6 Installation
          root (hd0,0)
          kernel /boot/centos/vmlinuz ip=dhcp ksdevice=eth0 ks=hd:${drive}1:/boot/centos/kickstart.ks method=${mirror}/${version}/os/x86_64/ lang=en_US keymap=us
  initrd /boot/centos/initrd.img " > /boot/grub/grub.conf
  echo "menuentry 'centosinstall' {
          set root='hd0,msdos1'
      linux /boot/centos/vmlinuz ip=dhcp ksdevice=eth0 ks=hd:${drive}1:/boot/centos/kickstart.ks method=${mirror}/${version}/os/x86_64/ lang=en_US keymap=us
          initrd /boot/centos/initrd.img
  }" >> /etc/grub.d/40_custom

  echo 'GRUB_DEFAULT=saved
  GRUB_CMDLINE_LINUX_DEFAULT="quiet nosplash vga=771 nomodeset"
  GRUB_DISABLE_LINUX_UUID=true' > /etc/default/grub

  grub2-set-default 'centosinstall'
  grub2-mkconfig -o /boot/grub2/grub.cfg

My Huawei Seeds for the Future 2015 Experience

As an Australian born Chinese (ABC), I've often taken for granted the culture and heritage of my ancestors. From 6 months old I've had the opportunity to travel to almost every major places in the world, including America, Europe, South-east Asia and China many times, but I've never fully been able to fully appreciate and experience the culture which this Huawei Seeds for the Future opportunity has opened my eyes to.

Within the first week of being in China, the simple things like ordering food at the university dining hall in Chinese without assistance, really hit me hard. Being spoken to and treated like a Chinese local but returning the gesture with a stumped expression, praying they would speak English made me feel very uncomfortable; I felt ashamed. In Australia I studied Chinese for many years in primary school. I took for granted I would always have someone to translate or that technology would replace language, not taking the opportunity seriously. The end result - not being able to hold a simple conversation.

The short 3 day Mandarin course at BLCU (BeiJing Language and Culture University), I feel I've learned a lot more in the three days compared to the many years I studied in Australia. It's made me feel comfortable with holding simple conversations which before I would not have been able to do. Initially, I lacked the confidence to put this into practice with the locals. In my past trip to China, I've was told at the ShenZhen train station by a ticket officer "You look Chinese, but can not speak Chinese". Yet when I tried to practice and start casual slow conversations in Chinese, I was always returned with a rapid elaborate responses I did not understand. This discouraged me to persevere. However during this trip; being apart of such an energetic group, my peers indirectly encouraged me to persevere. At every opportunity, 60 minute bus trips, 5 minute walks to class, we were all practicing with each other, encouraging and not putting anyone down. This atmosphere has really helped me to develop the courage to overcome this poor excuse which I've been hiding behind. Upon returning to Australia I plan to continue learning the language and hope to be able to return to China in a few years - fluent with the language.

Checking into the BeiJing hotel at 4am - 3 hours of sleep was all we got before we were off to trek the Great Wall of China. Assuming it would be flat stone like surface, we originally planned to complete the entire section. None of us were ready to see the steep, uneven, 1 meter high steps we had to climb. Although tired from lack of sleep, the thrilling experience had our adrenaline pumping as we marched up, sweating like pigs under the hot summer sun; we made it to the top tower impressed with our efforts. To keep up with this busy schedule, for most of us, sleeping on the bus was the only way to keep up with the first busy day, as we shot through BeiJing over to the Forbidden City and finally Tian An Men Square in the same day. What felt like a never ending day, ended with a nice evening at a popular hot pot restaurant where I got to see up close the Chinese mask changing performance. The food was great and the performance was spectacular.

Huawei made a big deal over the opening ceremony, as we arrived at their BeiJing Business Center. Words can not describe the awe on everyone's faces as we walked in the large glass doors, necks craned up at the amazing chandelier and the sheer size of the ceiling. Walking up the red carpet stairs and further into the building, a collection of photos with jaws dropped was definitely accumulated. I wouldn't be embarrassed to say, the bathrooms was an also an attraction of the building with dedicated rooms - not cubicles. The night was filled with motivational speeches and thrilling performances, ending with another delicious buffet this was a night worth remembering.

In what felt like only a day, we finished our first week in BeiJing. Now in our second week of the trip, we found ourselves in ShenZhen. There was an amazing difference in the environment. The blue sky, air quality and traffic levels were immediately noticeable. As we drove closer to Huawei's facility, I was blown away on sheer size alone. We were told to expect a "city within a city" - and it exceeded my expectations. We stayed at the Elite Garden Hotel in Baicao Garden, alongside local Huawei employees and guests. Each day we tucked into a buffet breakfast with a wide range of foods from stir-fried noodles to chicken nuggets and deep fried durian. On the odd days we had lunch or dinner at the cafeteria, the food was great but the desserts were worth racing for as supplies often diminished rapidly. During our stay, it was interesting to experience the Chinese working lifestyle, of a 9-6 day. This is done to accommodate for the 2 hour lunch break which is taken. This translated to power naps after meals and it certainty wasn't uncommon to see rooms pitch black with people sleeping heads down on their desk. The everyday culture within Baicao gardens was evident, as grandparents taking their grandchildren out to play during the day showed how much the Huawei's HQ had transformed into a small city within ShenZhen.

Scattered throughout the large accommodation blocks were small convenience stores and in the center was a large sports complex. On our limited nights off, we headed down to the sports complex to try our best at Basketball or Table Tennis in unforgiving heat and humidity levels. Through team based sports, our friendship deepened as we start building unspoken connections only forged while bathing in sweat after a long day.

During the working hours, we attended the Huawei Training Facility, joined by 3 other delegations also on the Seeds for the Future program with students from Denmark, Hungary and Belarus. By the first day, there was an unspoken air conditioner warfare as countries tried to fight to control desired temperature levels. Past the petty inconveniences the learning cultures were quite similar and for the most part as a larger group we got along quite well. At the training facility we were shown the direction in which the ICT networks are headed and how Huawei is leading the efforts in the area. We had the opportunity to get hands on experience with the equipment which is deployed and used around the world to provide the basic services we rely on everyday. In the lab session we were able to see first hand, the complexity of the network while also allowing us to build and get hands on experience with both a mobile (4G communication) and fibre network (FTTP). Being able place calls over the network which we built was rewarding in it's own right.

Later in the week, we had the opportunity to explore the F1 and G1 exhibition halls, as we saw the wide range of innovative products and solutions Huawei has to offer. It was surprising to see the lesser known products with revenue share still among the top 5 competitors of the industry. My original assumptions of Huawei being simply a telecommunications king was changed. The Australian group was fortunate enough to get to see the confidential Songshan Lake; something normally reserved for high end business customers. Songshan Lake, despite the name, is Huawei's high class manufacturing facility. We witnessed the full life cycle from material to end product, and the automation involved building and testing the products Huawei provides. The logistics in keeping the quality and speed of the facility shows how dedicated and committed they are in pushing forward.

To wrap it up the amazing trip, the Closing Ceremony was no slouch. We were privileged to have Vice President Madam Chen Lifang and MP Paul Fletcher at the event, as well as numerous lecturers from the Australian Technology Network (ATN). The closing ceremony marked an amazing end to the program which I'm sure everyone enjoyed. The group performed Little Apple by Chopstick Brothers, a popular Chinese song, with our limited Chinese I'm quite impressed at how well we pulled it off. It truly marked the occasion, showing how far we had progressed in the 2 weeks.

With the closing ceremony over, we ended the trip with a relaxing night at the 5 star InterContinental hotel where we enjoyed the large outdoor pool, luxurious baths and lovely food and drinks. The morning before we had to leave, some of our friends had to leave earlier than others due to flight arrangements. To accommodate for this, we all decided to run around Windows of the World, hot and sweaty we covered the whole park in an hour. The commitment some made - waking up hungover to join together as friends - to enjoy the last few hours together as we went to see the wonders of what ShenZhen had to offer was touching.

The Huawei Seeds for the Future program has provided me with an amazing opportunity for which I am truly grateful for. The little things such as the free Huawei P7 smartphone and the short term luxuries like our last day at 5 star InterContinental hotel, made it felt like Huawei was treating us with the same level of hospitality they would show their high paying customers. However, this trip shouldn't revolve around materialization and luxuries; emphasized when we were surprised to hear it was Mr Ren Zhengfei policy to only fly economy. Instead, from this trip, I take away 13 new friends and a larger network of connected people around the world. The experience I gained from this program far outweighs the knowledge gained through any class available through current university programs. I'm truly grateful towards Huawei for providing this opportunity.

Moving forward, this program has motivated me to continue learning the Chinese language and even has me contemplating the idea of spending 3-4 months in ShenZhen during my summer break to further explore what both China and Huawei have to offer.

Cleaning Up Docker Host

Sometimes testing docker images consumes a lot of diskspace depending on what you're using, if you're like me and don't have a brand new 1TB SSD then we can't afford to have diskspace wasted.

Here's a quick 3 line command to:
1. Stop all docker contaienrs
2. Remove all docker containers
3. Remove all docker images

docker stop $(docker ps -a -q)  
docker rm $(docker ps -a -q)  
docker rmi $(docker images -q)  

Now we can start fresh and try or build new docker containers. Also note, if you created external volume mount folders these commands won't remove them.

Error response from daemon: Cannot start container (....) (exit status 1)

This is a fairly generic error message, but it may help some that their iptable rules may be conflicting.

Stop using lokkit!

If you use lokkit for your iptable rules, you'll overwrite the docker rules so you'll have to service docker restart and try again.

Now the docker firewall rules should be loaded and you can start your docker container!

FATA[0000] Error response from daemon: Cannot start container a788e23879a4257918008b62bd6bfdaceb69cb6364180d1259c1348df0a4bd91: failed to find the cgroup root

Today after a reboot on a fresh CentOS 6.6 docker host, the containers were failing to startup with the error message:

FATA[0000] Error response from daemon: Cannot start container xxxxxxx: failed to find the cgroup root

Fix seems simple enough, the cgroup services aren't running:

[[email protected] ~]# /etc/init.d/cgred status
cgred is stopped  
[[email protected] ~]# /etc/init.d/cgred start
Starting CGroup Rules Engine Daemon:                       [  OK  ]  
[[email protected] ~]# /etc/init.d/cgconfig status
[[email protected] ~]# /etc/init.d/cgconfig start
Starting cgconfig service:                                 [  OK  ]

[[email protected] ~]# /etc/init.d/docker restart
Stopping docker:                                           [  OK  ]  
Starting docker:                                       [  OK  ]

[[email protected] ~]# docker run ....

Now run your containers and you should be all good to go :)

Hope this may help someone who stumbles across this. Remember to enable the services so it doesn't happen on next reboot!

chkconfig cgconfig on  
chkconfig cgred on  

Docker is fun :)

Installing Google Music Manager on Fedora 21

If you're wondering why Google Music Manager isn't starting after you installed it from their website, here's the problem:

$ google-musicmanager 
/usr/bin/google-musicmanager: error while loading shared libraries: libQtWebKit.so.4: cannot open shared object file: No such file or directory

How to resolve it,

yum provides '*/libQtWebKit.so.4'  
Repo        : fedora  
Matched from:  
Filename    : /usr/lib/libQtWebKit.so.4  
Filename    : /usr/lib/sse2/libQtWebKit.so.4

qtwebkit-2.3.4-1.fc21.x86_64 : Qt WebKit bindings  
Repo        : fedora  
Matched from:  
Filename    : /usr/lib64/libQtWebKit.so.4

qtwebkit-2.3.4-1.fc21.i686 : Qt WebKit bindings  
Repo        : @fedora  
Matched from:  
Filename    : /usr/lib/libQtWebKit.so.4  
Filename    : /usr/lib/sse2/libQtWebKit.so.4


sudo yum install qtwebkit qtwebkit-devel  

Now it should load for you :) Would be damn helpful if Google just included it as a dependency with the rpm..

However once it's loaded, the problems aren't gone yet. There seems to be ANOTHER bug, with actually getting it to load, the current workaround seems to be, empty your Music directory first (or choose an EMPTY directory) to first upload your files. Don't worry if it says it failed to upload or there are less than 10 songs in the directory. Follow through and then reopen it again, and finally it'll load what we wanted to see.

If you don't follow these steps, you'll find you can't open it again..

Finally, if it goes missing again, check your message icon tray as it's probably just minimized itself. Windows Key + M, and you'll see that tiny headphone icon tucked away in the bottom right corner.

Enjoy the music