Prepare to survive a computer failure for developers

Recently my MacBook refuse to start so I took it to the service center. Support guy asks me to submit the laptop and it will take 4-5 days to get it fixed. So what I do for 4-5 days then. well, I have to work and meet my deadline. Here is what I did to survive in this crisis.

So first think I did I borrowed laptop from my brother,  it was a windows based but I wanted something Unix mainly for its Terminal. I have tried Ubuntu earlier and also been working on server so I went with that, and in the process finally I manage to install it on a Thumb Drive and made it persistable so I can keep all of my work stored across reboots, by default ubuntu do not persist files when you run it as Try Without Install option.

If you have worked with servers a little you must be familiar with ubuntu (Linux) since most of the servers are running some flavor of Linux, it gives you a powerful terminal with all the awesomeness to complete your dev task right from your thumb drive. Is isn’t it pretty cool 😎 let me tell you how you can install all your development tool on USB drive.

What do you need?

First thing first, get a thumb drive, it should be minimum 8 GB, and next download the latest Ubuntu desktop release from the official website.

I am certain that you have been using version control for your project, if not! then please install Git and learn it, it’s not that hard, most of us uses only 5-10 command of git anyway, you must keep all the current project on the cloud, I use Github and Bitbucket for all my projects, if its private repo it will be on Bitbucket and for public I use GitHub. Push all the projects on bitbucket so we can work from anywhere in case of system failure or worst.

Ubuntu Recommended system requirements:

  • 2 GHz dual core processor or better
  • 2 GB system memory

Make a bootable Ubuntu USB drive

It’s time to make the USB bootable, all data on USB will be gone, so take backup of your USB drive before going ahead.

You will have 4GB persistent drive to store all the things we will installing from Git, LAMP and more development tools which is not bad for a thumb drive, also you can extend the size of it later.

Once you have downloaded the ubuntu iso, it will be around 1.6GB for 16.10 desktop 64bit version, we will be using UNetbootin since it cross-platform so you can make bootable ubuntu USB on any operating system.

If you are on Windows I prefer Universal USB Installer, I found it fast and easy.

Download Unetbootin and plug your pen drive, format it with FAT32, now launch the Unetbootin. It’s pretty simple interface, choose Disk image radio button and browse your downloaded ISO image. Now Enter 4000MB as a persistent drive.

UNetbootin Screen

Make sure you have selected right USB drive if multiple drives are plugged at the moment as target install, all data on the USB drive will be erased.

Now hit Ok, and the process will start. Be patient grab a coffee ☕, it will take time, don’t close it if feels stuck, it’s speed depends on USB drive write & your computer speed.

Ubuntu UNetbootin installation on USB

Just a side note I found the overall time making bootable USB on windows was faster than MacBook.

Boot from USB ubuntu drive

On PCs, this usually involves pressing a button such as Esc or F12 immediately after you turn on your computer, while on Macs, you should hold the Option key before OSX boots. after booting you will be prompt to use Try ubuntu, generally, its default option selected, don’t choose Install ( It will install on your hard drive and can delete data on hard disk ), choose to try without Install.

ubuntu-desktop

Setup Development Environment

Now since you have made that far you will be seeing on ubuntu desktop screen. Lets setup our development environment by installing all the tools we developer need to go through a typical work day. Ubuntu offers apt package manager for installation and managing apps on ubuntu.

Install Git

First, install the Git it’s the lifeline for any development. we will pull our project from repos using git. open the terminal and run following.

sudo apt-get update
sudo apt-get install git

This will download and install git to your system. you can check it using by running git -v it should print the installed version. Now we need to setup it.

The easiest way of doing this is through the git config command. Specifically, we need to provide our name and email address because git embeds this information into each commit we do.

git config --global user.name "Your Name"
git config --global user.email "youremail@domain.com"

Let’s confirm our setup by running git config --list command in terminal, it should list your name and email.

Install Apache, MySQL, PHP (LAMP) stack

Now lets setup the LAMP stack, if you have worked on any server setup it will be pretty familiar to you. Follow this guide to install it.

Install Node & NPM

All the frontend dependencies are managed with NPM so it’s must have for us, let’s install it.

sudo apt-get install nodejs
sudo apt-get install npm

zsh for terminal

Now you should install zsh, it gives bunch cool of tricks and shortcuts in your terminal.

apt-get install zsh
apt-get install git-core

sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

Now change shell to zsh by running chsh -s `which zsh` restart your terminal to see the zsh.

IDE and Code Editor

It’s up to you what code editor you wanted to use, you can check this post on code editor which I have used on this post with all the features. I am going to install PHPStorm and VSCode since both are cross platform.

Now you can restart your computer and boot in USB again. You should have all the installed program on your thumb drive now.

Increasing 4GB

Although 4GB is enough to keep going as it’s a temporary setup but If you wanted to increase the persistent limit here is a good read on how to do it or you can google it, but I would suggest you do this just after making USB drive bootable, if you mess up which is very likely, you will be not losing your installed apps from USB drive, offcourse you can go back and try again 😊.

Further customization

If you are a mac or windows user you can always customize the appearance of Ubuntu by using some transformer pack, checkout this post  to change the theme to mac os.

Running completed dev machine from pen drive was surprisingly fast, I have noticed very few problems, startup time is great and all the programs runs very smooth with very little lag.

You might think, nah… I don’t need it, my dev machine is working! please take it seriously, you never know when your computer stops working. it’s better to be prepared for this. I hope you will take some time out this weekend and create a bootable Ubuntu UBS drive so anytime if your main machine fails you can still work on any computer.

I know this is not directly related to web development but I found it very helpful so I just wanted to share this, I hope you liked it. Let me know in the comments hows it goes.