Ubuntu on a stick – Installation

This is the first in a series of blog posts that talk about running Ubuntu from a USB flash drive.

Ubuntu (/u:’bu:ntu:/ oo-BOON-too) is a Debian-based Linux operating system. For more information about the operating system itself, please check Ubuntu (operating system) on Wikipedia.

Now that you know what Ubuntu is you may still wonder why anyone would like to run it from a USB flash drive. How about having a free full feature GUI operating system that comes with tons of free tools and applications that you can carry with you and run on any computer that has a USB port without the need to install anything? And it will even run on this 10-year old computer in your basement and will recognize all your devices and will install all the necessary drivers automatically. Not convinced yet? Well, I respect your right to do whatever you want with your time – go check what your friends are doing on Facebook or waste couple of hours on Minecraft. If on the other hand you are curious or stubborn enough to keep reading I will show you how to install Ubuntu on USB flash drive in few easy steps.

I will be doing this from Windows. I have 8GB USB flash drive and part of it will be used to host Ubuntu and the rest will be used for sharing files. In order to achieve this I need to partition the USB drive first. In Windows I use EaseUS Partition Master. Download it from here.

Install and run EaseUS Partition Master with the USB plugged in. We are going to create 3 partitions.

Partition 1
Type: Logical
File System: FAT32
Size: 2GB
Label: STORAGE
Partition 2
Type: Primary
File System: FAT32
Size: 1GB
Label: UBUNTULIVE
Partition 3
Type: Primary
File System: EXT2
Size: 4.22GB (The rest of the space)
Label: casper-rw

Press the “Apply” button to re-partition the USB drive. You should see something similar:

p01

The first partition will be used for file sharing. It is FAT32 because this is the file system that most of the operating systems can read. You can use it under Windows and Linux. If you need more space you can make it bigger at the expense of the last partition (casper-rw).

The second partition is where we are going to install UBUNTU. 1GB is a perfect size. It has to be FAT32 and Primary. Make sure it is set to Active. Since Windows will only show one partition for a removable USB flash drive we need this partition setup as described in order to be accessible in Windows.

The third partition will be used to store any changes we make to Ubuntu – installing new applications, changing the desktop image, etc. EXT2 is a good choice for a file system when it comes to USB flash drive. EXT3 and EXT4 are newer and have some advantages but also come with excessive disk operations which is not desirable for a USB flash.

Now you need to download the Ubuntu ISO file. We want the desktop version. I am using the 64-bit but you should make sure your computer is 64-bit. Otherwise get the 32-bit version. At the time of writing this the latest available version is Ubuntu 14.04.1 LTS.

The next step is to install UBUNTU on the USB. There are several tools to do that and I had different results in the past. One that work well for me is Universal USB Installer. Download it.

Run the installer and on the selections page select Ubuntu from the drop-down, browse to the location you saved the ISO file and select the USB Flash Drive from the drop-down. Also use the slider to specify the Persistent file size. Do not slide it all the way to the right because it will complain there is no enough space. Just put the slider in the middle – the size of the file is not important since we are not going to use it at all. We are doing it just to make the installer to update some configuration files that tell the system to persist the changes. We will be using the third partition we created to persist all the changes we are making to our system:

p02

Leave the installer to run and be patient. When it is ready you should see a message like this:

p03

Click the “Close” button to finish. Go to the USB in file explorer and delete a file called casper-rw. This is the file that would keep all the changes normally. Since we have a dedicated partition we do not need it and have to delete it.

The last step will be to hide the UBUNTU partition and instead make the STORAGE partition the active one. Run the EaseUS Partition Master and make the STORAGE partition Primary and set it to Active:

p04

As a result you will see a new drive labeled STORAGE in windows explorer which you can use to for storing files – music, pictures, etc.

Now it is time to boot from the USB. Depending on the computer you have you might have to change the boot order in your BIOS or if it supports a boot menu you can select the USB drive directly from there. Once the GUI loads try to change the desktop background and reboot again. You should see the new background you selected which confirms that the changes we make to the system are persisted between restarting the computer.

This is it! Hopefully it works for you. If you have any problems, please go back and make sure you followed all the steps. If you still have questions, please do not hesitate to ask.

Keep in mind that in general Ubuntu will run much slower from a USB flash drive than from a regular hard-drive. What the USB gives us is a system we can take with us and run on another computer. If you have a dedicated computer on which you would like to run Ubuntu it is much better to install it on your hard-drive. A good information on how to run Ubuntu alongside Windows can be found here:

WindowsDualBoot

Herd Protection for your PC

What is herdProtect?

herdProtect is a second line of defense malware scanning platform powered by 68 anti-malware engines in the cloud. Since no single anti-malware program is perfect 100% of the time, herdProtect utilizes a ‘herd’ of multiple engines to guarantee the widest coverage and the earliest possible detection. As a second line of defense anti-malware solution, herdProtect is designed to run with any existing anti-virus program already installed on a user’s PC. herdProtect is a free service to help user’s find and remove malicious software.

herdProtect

 

backup of VMWare using ghettoVCB.sh

You can back up VMware VM for free using ghettoVCB.sh script. Everything you need is here:

https://github.com/lamw/ghettoVCB

I was unable to download it directly to the the VMware server because wget v1.19 refused to download form https:// url.

Instead I downloaded the file to my Windows machine and used WinSCPPortable to upload the file to the server.

To extract the files do:

unzip ghettoVCB-master.zip

Go to ghettoVCB-master folder and make the scripts executable:

chmod +x ghettoVCB.sh
chmod +x ghettoVCB-restore.sh

Add a new NFS share as a datastore “backup”. This is where we are going to store the backup files.

Create some folders and configuration files. A typical way to execute the script is:

./ghettoVCB.sh -f vms_to_backup -g global_config/vm_global.conf

To schedule a cron job add the following line to /var/spool/cron/crontabs/root

0 0 * * 1-5 /scratch/ghettoVCB-master/ghettoVCB.sh -f /scratch/ghettoVCB-master/vms_to_backup -g /scratch/ghettoVCB-master/global_config/vm_global.conf > /vmfs/volumes/backup/ghettoVCB-backup-$(date +\%s).log

Then add the following to /etc/rc.local.d/local.sh

/bin/kill $(cat /var/run/crond.pid)
/bin/echo “0 0 * * 1-5 /scratch/ghettoVCB-master/ghettoVCB.sh -f /scratch/ghettoVCB-master/vms_to_backup -g /scratch/ghettoVCB-master/global_config/vm_global.conf > /vmfs/volumes/backup/ghettoVCB-backup-\$(date +\\%s).log” >> /var/spool/cron/crontabs/root
crond

In order to allow the script to send emails you need to:

Step 1 – Create a file called /etc/vmware/firewall/email.xml with contains the following:


  
    email
    
      outbound
      tcp
      dst
      25
    
    true
    false
  

Step 2 – Reload the ESXi firewall by running the following ESXCLI command:

~ # esxcli network firewall refresh

Step 3 – Confirm that your email rule has been loaded by running the following ESXCLI command:

~ # esxcli network firewall ruleset list | grep email
email                  true

Step 4 – Connect to your email server by using nc (netcat) by running the following command and specifying the IP Address/Port of your email server:

~ # nc 172.30.0.107 25
220 mail.primp-industries.com ESMTP Postfix

To perform a dry run restore do:

./ghettoVCB-restore.sh -c vms_to_restore -d 1

To perform a real restore do:

./ghettoVCB-restore.sh -c vms_to_restore

Useful Linux Commands

Delete all files with given extension recursively:

find . -name "*.dll" -print0 | xargs -0 rm -rf

Find the number of .jpg file in the current folder and all sub-folder recursively:

find . -name "*.jpg" -print | wc -l

Move all .m2ts files to /mnt/backup/m2ts folder:

find . -iname "*.m2ts" -type f | xargs -I '{}' mv {} /mnt/backup/m2ts

Install GUI on Ubuntu Server

sudo apt-get upgrade
sudo apt-get install ubuntu-desktop

Find out the disk usage

df -h

You can free up some space in /boot by removing old kernel with:

sudo apt-get purge $(dpkg -l linux-{image,headers}-"[0-9]*" | awk '/ii/{print $2}' | grep -ve "$(uname -r | sed -r 's/-[a-z]+//')")

according this post

Search for a string in all text files:

find folder_name -name '*.txt' -exec grep -i 'text-to-search-for' {} \; -print

Search for all .jpg files modified (taken) in the last year and move them to another folder:

find . -iname "*.jpg" -mtime -365 -print -type f | xargs -I '{}' mv {} /mnt/backup/jpg_last_year

Delete .jpg files older than 1 year:

find . -iname "*.jpg" -mtime +365 -print -type f | xargs -I '{}' rm {}

Delete .jpg images smaller than 500KB

find /mnt/backup/_wd3 -iname "*.jpg" -size -500k -delete

Move all .jpg files modified in 2013 to a separate folder:

find . -iname "*.jpg" -newermt "2013-01-01" ! -newermt "2013-12-31" | xargs -I '{}' mv {} /mnt/tank/common/multimedia/pictures/jpg_3/2013