|
|
||
Inderjeet Singh's BlogProgramming ArchivesInstalling a Ubuntu Hardy Heron Java Development Environment on a USB flash drivePosted by inder on July 06, 2008 at 12:16 PM | Permalink | Comments (5)USB flash drives are really cheap these days, so I decided to create a portable environment that contains all my favorite applications, as well as Java IDEs and utilities. This is attractive since I can boot up any computer with this thumb drive, and have the same environment to work with. Besides, it is kind of cool. You would think that this would be as easy as booting from the install disk of Ubuntu, and choosing USB disk as the target drive. Alas, it is not so. Ubuntu will try to install Grub which will be unable to boot from your USB disk. Moreover, I started running into problems with using the same USB disk at different computers. So, I searched around and found some excellent articles at debuntu.org and by Ryan Cloke. Both were written for the prior version 8.04 of Hardy Heron but are still largely appropriate. There were a few typos in the instructions, so I decided to reproduce instructions here with my edits, as well as add instructions related to setting up the Java development environment. Prepare the USB DiskGet a USB disk, at least 1 GB in size. I got an 8GB one since then I dont have to worry about conserving disk space for a while.These instructions assume that you already have a Linux installation to use to prepare the USB linux installation. If you know how to do this with Windows, please share instructions as comments to this blog. The first step is to partition the USB disk using
Scan output for entries similar to this. Disk /dev/sdc: 8017 MB, 8017412096 bytes 255 heads, 63 sectors/track, 974 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0xcb527ec4 Device Boot Start End Blocks Id System /dev/sdc1 * 1 95 763056 83 Linux /dev/sdc2 96 974 7060567+ 83 Linux As you can notice, the disk In my case above, I already have the USB disk properly partitioned. But you will need to do the same if you haven't already done so (Note that this will erase ALL the data on the disk, so back up anything important before executing these instructions):
Now we need to format these partitions: sudo mkfs.vfat -F 16 -n UbuntuLive /dev/sdc1 sudo mkfs.ext2 -b 4096 -L casper-rw /dev/sdc2 Prepare the Ubuntu InstallationDownload the Hardy Heron 8.04.1 ISO image from Ubuntu website. I chose the 32-bit i386 image (ubuntu-8.04.1-desktop-i386.iso) because it is going to run on almost all CPUs. The first step is to mount the downloaded iso image. sudo mkdir -p /media/iso sudo mount -o loop ubuntu-8.04.1-desktop-i386.iso /media/isoCopy the contents of this image to a temporary directory (/home/inder/hardy-usb in my case): mkdir -p /home/inder/hardy-usb sudo cp -rf casper dists install pics pool preseed .disk isolinux/* md5sum.txt README.diskdefines casper/vmlinuz casper/initrd.gz install/mt86plus /home/inder/hardy-usb/ Next, we will modify this installation to fix some bugs specific to USB disk installation.
cd /home/inder/hardy-usb/ mv isolinux.cfg syslinux.cfg sudo vi syslinux.cfg You should replace the contents of this file with the following: DEFAULT usblive GFXBOOT bootlogo APPEND file=/preseed/ubuntu.seed boot=casper initrd=initrd.gz quiet splash -- LABEL usblive menu label ^Start Ubuntu and save changes to USB kernel vmlinuz append file=/preseed/ubuntu.seed boot=casper persistent initrd=initrd.gz quiet splash -- LABEL live menu label ^Try Ubuntu without any change to your computer kernel vmlinuz append file=/preseed/ubuntu.seed boot=casper initrd=initrd.gz quiet splash -- LABEL live-install menu label ^Install Ubuntu kernel vmlinuz append file=/preseed/ubuntu.seed boot=casper only-ubiquity initrd=initrd.gz quiet splash -- LABEL memtest menu label Test ^memory kernel mt86plus append - LABEL hd menu label ^Boot from first hard disk localboot 0x80 append - DISPLAY isolinux.txt TIMEOUT 300 PROMPT 1 F1 f1.txt F2 f2.txt F3 f3.txt F4 f4.txt F5 f5.txt F6 f6.txt F7 f7.txt F8 f8.txt F9 f9.txt F0 f10.txt Save the file, and move on to the next step of fixing another bug in initrd.gz: cd /home/inder/hardy-usb/ mkdir initrd_old cd initrd_old gunzip < ../initrd.gz | cpio -i --make-directories cd scripts sudo vi casper Now, search for "mount ${cowdevice} -t ${cow_fstype} -o rw,noatime,mode=755 /cow". Remove "mode=755". So the line should look like this:
mount ${cowdevice} -t ${cow_fstype} -o rw,noatime /cow || panic "Can not mount $cowdevice on /cow"
After your have modified and saved the casper script, we need to repack the initrd file system. cd .. find ./ | cpio -H newc -o > ../initrdnew cd .. sudo rm initrd.gz sudo mv initrdnew initrd sudo gzip initrd sudo rm -rf initrd_old Copying Ubuntu to the USB disksudo mount /dev/sdc1 /media/usb cd /home/inder/hardy-usb/ sudo cp -rf .disk * /media/usb sudo umount /media/usb Make the disk bootable sudo syslinux -f /dev/sdc1 If you had made the mistake of trying to install Ubuntu directly from the CDROM, you will need to get rid of Grub. You can do so by installing Lilo to overwrite MBR: sudo lilo -M /dev/sdc Yay, you have the USB disk with Ubuntu. Now reboot the PC with the USB disk plugged in. You may have to select the bios setting to boot from the USB. On my laptop, I have to press F12, and on my home desktop, I have to press F11. You can also make the USB disk as a higher priority boot device. Configuring the Ubuntu InstallationBoot up your PC from the USB disk. The system will boot into the default Ubuntu account. Open a terminal and run Create a user account for yourself by using the System|Administration|Users and Groups menu. Ensure that in the create account screen, you have given this user the permissions to administer the system. Disable the automatic login to the ubuntu user. Select System|Administration|Login Window menu. Select the Security tab, and unselect "Enable Automatic Login" and "Enable Timed Login". Note that you can still go to the ubuntu user by typing Ctrl-Alt-F1. I could not figure out a simple way to prevent the system from automatically logging in ubuntu user. If you know how to do this, please share that as comments to this blog. Prevent Ubunutu from hibernating. Launch Configure Ubuntu to allow software from multiple repositories. Go to System|Administration|Software Sources Menu. Under the Ubuntu tab, choose "Community-maintained Open Source Software (universe)". Also, choose "Software restricted by copyright and legal issues (multiverse)". I also unselected the "Source code" option hoping that it may save me precious space on my USB disk by avoiding source-code for programs. At this time, you may want to update your system with the latest versions of the various packages from the System | Administration | Update Manager menu. However, be selective in updating especially if you have a USB disk less than 2GB in size. The reason being that all the new packages that you install will be installed on your second partition, while the original packages will remain on the first partition. You may still want to upgrade commonly-used packages such as firefox. Also, dont bother trying to remove any of the unused packages since, again, they are on the first partition, and will not really free up any space on the second partition. Install flash player for firefox. This is useful if you want to play YouTube videos.
You may also want Firefox configured such that it does not use the USB disk for storing caches. For that, start firefox, and type Installing JavaUbuntu does not come pre-installed with Java. Unfortunately, there are some bugs in Java packaqes, so just using apt-get will give you some weird errors regarding libjli.so. Here are steps to fix this problem (instructions adapated from swik.net): sudo su // switch to administrator role apt-get install sun-java6-jdk ln -s / /cow export LD_LIBRARY_PATH=/usr/lib/jvm/java-6-sun/jre/lib/i386/jli dpkg --configure -a Run javac --version to ensure that the JDK installed correctly. You can also install openjdk-6-jdk package instead. In that case, make sure that you adjust LD_LIBRARY_PATH accordingly before running dpkg. Install other useful tools such as subversion and maven: sudo apt-get install maven2 sudo apt-get install subversion Installing Eclipse GanymedeDownload Eclipse from eclipse.org or issue the following command from command-line: wget http://ganymede-mirror1.eclipse.org/technology/epp/downloads/release/ganymede/R/eclipse-jee-ganymede-linux-gtk.tar.gz tar xvfz eclipse-jee-ganymede-linux-gtk.tar.gz sudo mv eclipse /opt/ You can now run eclipse from /opt/eclipse/eclipse. I also installed a short-cut for Eclipse on my menu-bar. You can choose the icon images for Eclipse from Once you have a configuration you are pleased with, you may want to create a backup so that you can restore it in case anything goes wrong. I did this by plugging-in the USB disk in my other linux desktop, and then using the sudo dd if=/dev/sdc1 of=/home/inder/hardy-working-disk1.iso sudo dd if=/dev/sdc2 of=/home/inder/hardy-working-disk2.iso You can restore this by issuing the dd commands in reverse: sudo dd if=/home/inder/hardy-working-disk1.iso of=/dev/sdc1 sudo dd if=/home/inder/hardy-working-disk2.iso of=/dev/sdc2 That concludes this rather long blog. It took me several installs and reinstalls to get it right, but the results are worth it. I am enjoying my USB linux installation and using it to write this blog. Have you installed linux on USB disks as well? If so, share your experiences as comments to this blog. Thanks for reading.
Using command-line Ant-based build structure that is Netbeans-friendlyPosted by inder on January 30, 2006 at 11:42 AM | Permalink | Comments (0)Do you use Netbeans to write your Java EE applications? If so, did you ever want to run the build files through command-line only to discover that they can only be run through Netbeans? In this blog, I will describe how you can use the Java BluePrints build system to make your Netbeans generated Java EE projects command-line friendly. The Java BluePrints Build System is essentially a set of Ant files that provide targets for compiling, deploying, undeploying, and running, Java EE projects with GlassFish. These ant files detect whether they were invoked from with-in Netbeans or from command-line and automatically either use Netbeans native build system, or the command-line targets. The result is that the project behaves like a native Netbeans project when loaded in Netbeans, while still completely usable from command-line. You can download and use the early access release of the Java BluePrints build system from the Java BluePrints Conventions project. Start with reading the detailed (by my standards, at least) guide available in README.html after installation. Please be aware that this is really early access code, with likely obviously broken things. Having said that, we have been using it in all of the applications in Java BluePrints Solutions Catalog quite successfully for a while..
| ||
|
|