Thursday, January 31, 2013

Make Full Ubuntu Bootable in NTFS' Thumbdrive


Right now the thumbdrive's capacity is already so big and fast with USB 3.0 at the speed of 5 gbps.

I have 32GB thumbdrive and never fully occupy it on my daily work (yeah, except only when I have HD video files :-)).

So, instead of just using it for storing data files, I want to also make use of it to boot full Ubuntu linux.

This full Ubuntu (together with persistent file system) should not take the space for more than 2GB.

In my previous write up, I provided steps to make bootable thumbdrive with FAT16/32 using syslinux.

FAT32 is a generic filesystem that is commonly supported by both Windows and Linux.

However, sometimes we may find limitation with FAT32 when trying to copy big file that has size more than 4GB.

FAT32 cannot hold for more than 4GB size in 1 single file:
- http://stackoverflow.com/questions/4662412/why-are-fat32-disks-limited-to-4gb-files
- http://en.wikipedia.org/wiki/File_Allocation_Table#FAT32

We want to use ext2/3/4, but unfortunately, Windows like XP, Vista, 7, or even the latest 8, have so many limitations and do not support this file system.

At the same time, we don't want to be too "techy" to install 3rd party's tool on Windows to read the ext2/3/4 when we'd like to share our files to our colleagues or friends in their PC.

So, let's use NTFS and the latest syslinux 5.01 for it :)

1) Format your thumbdrive with NTFS
2) Download the latest syslinux 5.01
3) Extract it to let say C:\utils\syslinux-5.01
4) Mark the thumbdrive bootable by executing syslinux.exe located at win32 folder (for 64-bit Windows, it will be the syslinux64.exe at win64 folder)
5) Download the latest Ubuntu ISO
6) Create a folder in your thumbdrive (e.g. F:\ubuntu-12.10) and extract the ISO files into it
7) Create/edit syslinux.cfg at main directory of your thumbdrive (e.g. F:\syslinux.cfg)

Example syslinux.cfg:

default ubuntu
prompt 1
label ubuntu
   kernel /ubuntu-1210/casper/vmlinuz
   append file=/cdrom/ubuntu-1210/preseed/ubuntu.seed boot=casper ignore_uuid noeject noprompt initrd=/ubuntu-1210/casper/initrd.lz live-media-path=/ubuntu-1210/casper splash --
timeout 50


8) Afterwards, boot your Ubuntu from the thumbdrive
9) Once you have entered into the Ubuntu, you may want to create persistent file system to allow you to save any changes you have done on your Ubuntu into your thumbdrive

$ sudo su -
# cd /cdrom/ubuntu-1210
# dd if=/dev/zero of=./casper-rw bs=1M count=1024

  
(pay attention to the dot slash "./" and be extra careful when invoking something like "dd of=/[path]" command since it can wipe out all of your data on your disk if you are pointing to the wrong path.)
 
# mkfs.ext4 ./casper-rw
./casper-rw is not a block special device.
Proceed anyway? (y,n) y
# tune2fs -i 0 -c 0
./casper-rw
# cd .. ; vi ./SYSLINUX.CFG
  
Add persistent parameters to the syslinux.cfg of the thumbdrive:
 
default ubuntu
prompt 1
label ubuntu
   kernel /ubuntu-1210/casper/vmlinuz
   append file=/cdrom/ubuntu-1210/preseed/ubuntu.seed boot=casper ignore_uuid noeject noprompt initrd=/ubuntu-1210/casper/initrd.lz persistent persistent-path=/ubuntu-1210 live-media-path=/ubuntu-1210/casper splash --
timeout 50


Reboot and see it rocked!