Ubuntu Network Installation Using PenDrive

January 25th, 2009 No comments


With the new version of Ubuntu Hardy Heron 8.04, the ms-sys package no longer exists (due to copyright violations). For that download the ms-sys package here ms-sys-2.1.3.tar.gz and also install gettext using apt-get.

Value Addition:

We can setup a linux machine in a matter of minutes without requiring some special infrastructure. Also, if we have customized an operating system (in case of say, a streaming server, or VMS slave servers), we can make an image of it and make it installable. That installation can be started via the network, so the end user would just need to plugin the USB Pen Drive, and automatically the server would be setup, configured and available for use.

The softwares that you may need to download are syslinux, mtools, ms-sys, gettext

Following are the steps:

Step 1: Make a Bootable USB Pen Drive

  • Partition the USB Drive and make the partition bootable using fdisk. Make sure the partition that you’d make bootable is a Win95Fat16 one (Mode e in fdisk)
  • Now put Win95 MBR in the drive by using ms-sys -9 /dev/sda (ms-sys is not available 8.04/Hardy Heron onwards. Use the Gutsy Deb for the same. ms-sys_2.1.0-1_i386.deb )
  • Format that partition using mkdosfs /dev/sda1
  • Make it bootable using syslinux by typing syslinux /dev/sda1
  • Mount the USB Drive’s Parition through mount /dev/sda1 /media/usbdisk. Copy the initrd.gz and linux onto the partition
  • Create a file called syslinux.cfg inside the parition and add the following values into it
DEFAULT insall

LABEL install
 menu label ^Start Ubuntu via Netboot
 kernel linux
 append initrd=initrd.gz ramdisk_size=1048576 root=/dev/ram rw quiet splash --

Make the chages to append line as below if you want to perform a kicksrtart installation.

DEFAULT insall

LABEL install
 menu label ^Start Ubuntu via Netboot
 kernel linux
 append ks=http://ipadd/ofserver/ks.cfg initrd=initrd.gz rw quiet splash --

So essentially there’d be only 4 files inside the USB Drive, viz. initrd.gz , ldlinux.sys , linux , syslinux.cfg

STEP 2: On your Web Server, mount the ISO and make it available

# cd /var/www
# mkdir ubuntu
# mount -o loop /path/to/ubuntu-8.10-alternate.iso /var/www/ubuntu

STEP3: Boot using the USB and start the installation Now there are two problems.
(a) If you start the Edgy Installation using the netboot kernel, it’ll search for archive.ubuntu.com and get the Release files from there. If the Release file that is available at archive.ubuntu.com is later than what’s available on the CD, then you’ll face problems while downloading packages. So, the network installation will fail if you use the CD as the repository.
(b) The linux-image-kernel which is available in the CD, probably does not have correct GPG key/md5sum. Due to which later in the installation it gives an error that it could not be authenticated and the installation fails. The solution to both the problems above is covered below

  • Boot using the USB. You should be able to see the installation screen where it asks for the Language. If not, try the Ubuntu Wiki where booting using the USB is explained alongwith the Netboot Kernel Image.
  • Proceed through the normal installation steps. Once the Network Configuration step comes, if you’ve a DHCP server, it’ll automatically pickup the IP Address. Don’t let that happen (Press Cancel). If the DHCP Config is done and it asks for the system’s name, click Go Back and configure the network manually.
  • If you have the details about the IP Address, well and good, else on the VT2, type ifconfig and route -n to know about the IP Address, Subnet Mask and the Gateway
  • Don’t Provide the DNS Entry as it will allow the system to go through internet and get connected to archive.ubuntu.com which we do not want.
  • While asked for mirror from which to do the installation, go to the Top and add the information manually.
  • Once the Base Installation is in progress, switch to Virtual Terminal 2, by pressing ALT+F2. Press ENTER and add the following
  • echo 'APT::Get::AllowUnauthenticated "true";' >>/target/etc/apt/apt.conf (All Credit goes to dixonp who suggested the same here -> http://ubuntuforums.org/showthread.php?t=332343)
    This will ensure that no GPG Related issues pop-up and installation happens smoothly.

That’s it. This will help you in a scenario where

  • Bandwidth is limited and you don’t want to connect to Internet everytime you need to do the installation
  • You were able to get an Alternate Install ISO (or a CD), but there are no CD Drives on the machines you wish to install Ubuntu
  • You wish to do fast Ubuntu Installations but they should be interactive (Otherwise you can look into Kickstart Installs)
  • The DHCP network is not in your control to setup a PXE Install

Note: All the credit goes to Marquivon who posts the same here http://ubuntuforums.org/showthread.php?p=2086827

Categories: Linux Tags:

Build Own deb Package

January 24th, 2009 No comments

About Deb package

Normal Debian packages get a proper source package, including a debian/rules file which automates the steps involved in creating the binary package. Here we just show how to package a simple shell script or binary executable into a small binary package.

From the dpkg-deb man page: “dpkg-deb packs, unpacks and provides information about Debian archives. .deb files can also be manipulated with ar and tar alone if necessary. Use dpkg to install and remove packages from your system.”

.deb package are just the tar archives but with a proper structural format of  files. You can see and extract any deb package with any archive manager tool.

You might find lots of example .deb files in directory ‘/var/cache/apt/archives/‘. With ‘dpkg-deb -I somepackage.deb‘ you might get a general overview of what this package offers in particular. ‘dpkg-deb -c somepackage.deb‘ lists all files which will be installed.

List content of the .deb file with ‘ar tv somepackage.deb‘. Use the ‘x’ option to extract the files.

Package Structure:

$ ar tv parted_1.4.24-4_i386.deb
rw-r--r-- 0/0      4 Mar 28 13:46 2002 debian-binary
rw-r--r-- 0/0   1386 Mar 28 13:46 2002 control.tar.gz
rw-r--r-- 0/0  39772 Mar 28 13:46 2002 data.tar.gz

Now we can start to extract all files including the content of the tar files.

Debian Binary:

The content of this file is “2.0\n”. This states the version of the deb file format. For 2.0 all other lines get ignored.


The ‘data.tar.gz’ file contains all the files that will be installed with their destination paths:

drwxr-xr-x root/root      0 2002-03-28 13:44:57 ./
drwxr-xr-x root/root      0 2002-03-28 13:44:49 ./sbin/
-rwxr-xr-x root/root  31656 2002-03-28 13:44:49 ./sbin/parted
drwxr-xr-x root/root      0 2002-03-28 13:44:38 ./usr/
drwxr-xr-x root/root      0 2002-03-28 13:44:41 ./usr/share/
drwxr-xr-x root/root      0 2002-03-28 13:44:38 ./usr/share/man/
drwxr-xr-x root/root      0 2002-03-28 13:44:52 ./usr/share/man/man8/
-rw-r--r-- root/root   1608 2002-03-28 13:44:37 ./usr/share/man/man8/parted.8.gz
drwxr-xr-x root/root      0 2002-03-28 13:44:41 ./usr/share/doc/
drwxr-xr-x root/root      0 2002-03-28 13:44:52 ./usr/share/doc/parted/
-rw-r--r-- root/root   1880 2002-03-07 14:20:08 ./usr/share/doc/parted/README
-rw-r--r-- root/root   1347 2002-02-27 01:40:50 ./usr/share/doc/parted/copyright
-rw-r--r-- root/root   6444 2002-03-28 13:37:33 ./usr/share/doc/parted/changelog
-rw-r--r-- root/root  15523 2002-03-28 02:36:43 ./usr/share/doc/parted/changelog.gz

It must be the last file in the deb archive.


This file has the contents like listed below.

-rw-r--r--    1 root     root         1336 Mar 28  2002 control
-rw-r--r--    1 root     root          388 Mar 28  2002 md5sums
-rwxr-xr-x    1 root     root          253 Mar 28  2002 postinst
-rwxr-xr-x    1 root     root          194 Mar 28  2002 prerm

‘md5sums’ contains for each file in data.tar.gz the md5sum. In our example the content looks like this:

1d15dcfb6bb23751f76a2b7b844d3c57  sbin/parted
4eb9cc2e192f1b997cf13ff0b921af74  usr/share/man/man8/parted.8.gz
2f356768104a09092e26a6abb012c95e  usr/share/doc/parted/README.Debian
a6259bd193f8f150c171c88df2158e3e  usr/share/doc/parted/copyright
7f8078127a689d647586420184fc3953  usr/share/doc/parted/changelog.Debian.gz
98f217a3bf8a7407d66fd6ac8c5589b7  usr/share/doc/parted/changelog.gz

‘prerm’ and ‘postinst’ seem to take care of removing old documentation files and adding a link from doc to share/doc.

$ cat postinst
set -e
# Automatically added by dh_installdocs
if [ "$1" = "configure" ]; then
  if [ -d /usr/doc -a ! -e /usr/doc/parted -a -d /usr/share/doc/parted ]; then
    ln -sf ../share/doc/parted /usr/doc/parted
# End automatically added section
$ cat prerm
set -e
# Automatically added by dh_installdocs
if [ \( "$1" = "upgrade" -o "$1" = "remove" \) -a -L /usr/doc/parted ]; then
  rm -f /usr/doc/parted
# End automatically added section

And finally the most interesting file:

$ cat control
Package: parted
Version: 1.4.24-4
Section: admin
Priority: optional
Architecture: i386
Depends: e2fsprogs (>= 1.27-2), libc6 (>= 2.2.4-4), libncurses5 (>= \
5.2.20020112a-1), libparted1.4 (>= 1.4.13+14pre1), libreadline4 (>= \
4.2a-4), libuuid1
Suggests: parted-doc
Conflicts: fsresize
Replaces: fsresize
Installed-Size: 76
Maintainer: Timshel Knoll <timshel@debian.org>
Description: The GNU Parted disk partition resizing program
 GNU Parted is a program that allows you to create, destroy,
 resize, move and copy hard disk partitions. This is useful
 for creating space for new operating systems, reorganizing
 disk usage, and copying data to new hard disks.
 This package contains the Parted binary and manual page.
 Parted currently supports DOS, Mac, Sun, BSD, GPT and PC98
 disklabels/partition tables, as well as a 'loop' (raw disk)
 type which allows use on RAID/LVM. Filesystems supported are
 ext2, ext3, FAT (FAT16 and FAT32) and linux-swap. Parted can
 also detect HFS (Mac OS), JFS, NTFS, ReiserFS, UFS and XFS
 filesystems, but cannot create/remove/resize/check these
 filesystems yet.
 The nature of this software means that any bugs could cause
 massive data loss. While there are no known bugs at the moment,
 they could exist, so please back up all important files before
 running it, and do so at your own risk.

Further information about the control file can be obtained via ‘man 5 deb-control’.

Below is the example script with intergrate all the above steps together. You can change the script as per your needs.

# This script should be run from within the directory with the .jpg files.
# First, create the empty tree under a new "build" directory
# (the name "build" is completely arbitrary here)
mkdir -p build/usr/share/newwallpapers/
# Put the jpg images in the newwallpapers directory
cp -v *.jpg build/usr/share/newwallpapers/
# move into the build directory, make a docs directory
cd build
mkdir -p usr/share/doc/your-package-name
# write the README file
cat > usr/share/doc/your-package-name/README <<END
This package provides latest desktop wallpapers for Ubuntu desktop.
It moves the original wallpapers aside using dpkg-divert, and
restores them upon uninstallation.
# write the control file
cat > control <<END
Package: your-package-name
Version: 0.1
Section: user/themes
Priority: optional
Architecture: all
Installed-Size: `du -ks usr|cut -f 1`
Maintainer: Your-Name-Here <someone@example.com>
Description: New desktop wallpapers, with auto-backup of the originals
 This package contains a set of jpg files. This
 version will preserve your current wallpapers using dpkg-divert and
 restore them upon uninstallation.
# write the pre-installation script
cat > preinst <<END
if [ "$1" = install ]; then
    for f in newhill.jpg get_started.jpg new_era.jpg this_world.jpg heaven.jpg weather.jpg new_lesson.jpg old_building.jpg wemm.jpg coinage.jpg genesis.jpg aslan.jpg googleworld.jpg vcustomer.jpg hacktheworld.jpg manhack.jpg warlock.jpg sicker.jpg; do
        dpkg-divert --package your-package-name --rename --add /usr/share/newwallpaperss/$f
# write the post-removal script
cat > postrm <<END
if [ "$1" = remove ]; then
    for f in newhill.jpg get_started.jpg new_era.jpg this_world.jpg heaven.jpg weather.jpg new_lesson.jpg old_building.jpg wemm.jpg coinage.jpg genesis.jpg aslan.jpg googleworld.jpg vcustomer.jpg hacktheworld.jpg manhack.jpg warlock.jpg sicker.jpg; do
        dpkg-divert --package your-package-name --rename --remove /usr/share/newwallpapers/$f
# Setting this environment variable fixes Apple's modified GNU tar so that
# it won't make dot-underscore AppleDouble files. Google it for details...
# create the data tarball
# (the tar options "czvf" mean create, zip, verbose, and filename.)
tar czvf data.tar.gz usr/share/newwallpapers/ usr/share/doc/
# create the control tarball
tar czvf control.tar.gz control preinst postrm
# create the debian-binary file
echo 2.0 > debian-binary
# create the ar (deb) archive
ar -r your-package-name.deb debian-binary control.tar.gz data.tar.gz
# move the new deb up a directory
mv your-package-name.deb ..
# remove the tarballs, and cd back up to where we started
rm data.tar.gz control.tar.gz
cd ..

After running this, should have a your-package-name.deb next to your jpg files in the current directory. You can delete the build sub-directory, and try installing your new package.

All the credit goes to http://tldp.org/HOWTO/html_single/Debian-Binary-Package-Building-HOWTO/ and http://synthesize.us/HOWTO_make_a_deb_archive_without_dpkg.

Categories: Linux Tags:

LVM (Logical Volume Manager)

January 16th, 2009 3 comments

What is LVM

LVM is a Logical Volume Manager for the Linux operating system. There are now two version of LVM for Linux:

  • LVM 2 – The latest and greatest version of LVM for Linux.LVM 2 is almost completely backward compatible with volumes created with LVM 1. The exception to this is snapshots (You must remove snapshot volumes before upgrading to LVM 2)LVM 2 uses the device mapper kernel driver. Device mapper support is in the 2.6 kernel tree and there are patches available for current 2.4 kernels.
  • LVM 1 – The version that is in the 2.4 series kernel,LVM 1 is a mature product that has been considered stable for a couple of years. The kernel driver for LVM 1 is included in the 2.4 series kernels


The LVM can:

  • Resize volume groups online by absorbing new physical volumes (PV) or ejecting exiting  ones.
  • Resize logical volumes (LV) online by concatenating extents onto them or truncatiing    extents from them.
  • Create read-only snapshots of logical volumes (LVM1).
  • Create read-write snapshots of logical volumes (LVM2).
  • Stripe whole or parts of logical volumes across multiple PVs, in a fashion similar to R AID0.
  • Mirror whole or parts of logical volumes, in a fashion similar to RAID1.
  • Move online logical volumes between PVs.
  • Split or merge volume groups in situ (as long as no logical volumes span the split).  The    can be useful when migrating whole logical volumes to or from offline storage.

 The LVM will also work in a shared-storage cluster (where disks holding the PVs are shared between multiple host computers), but requires an additional daemon to propagate state changes between cluster nodes.

LVM does not:

  • Provide parity-based redundancy across LVs, as with RAID4, RAID5 or RAID6. This functionality is instead provided by Linux metadisks, which can be used as LVM physical volumes.

LVM Terminology

Physical Volume (PV) :- A PV is nothing more than a physical medium with some administrative data added to it – once you have added this, LVM will recognise it .

A Physical Volume, containing Physical Extents:

+-----[ Physical Volume ]------+
| PE | PE | PE | PE | PE | PE  |

b. Physical Extents (PE) :- Physical Extents are like really big blocks, often with a size of megabytes.

c. Volume Group (VG) :- A VG is made up of a number of Physical Extents (which may have come from multiple Physical Volumes or hard drives). While it may be tempting to think of a VG as being made up of several hard drives (/dev/hda and /dev/sda for example), it’s more accurate to say that it contains PEs which are provided by these hard drives.

A Volume Group, containing 2 Physical Volumes (PVs) with 6 Physical Extents:

+------[ Volume Group ]-----------------+
|  +--[PV]--------+  +--[PV]---------+  |
|  | PE | PE | PE |  | PE | PE | PE  |  |
|  +--------------+  +---------------+  |
We now further expand this:

+------[ Volume Group ]-----------------+
|  +--[PV]--------+  +--[PV]---------+  |
|  | PE | PE | PE |  | PE | PE | PE  |  |
|  +--+---+---+---+  +-+----+----+---+  |
|     |   |   | +-----/     |    |      |
|     |   |   | |           |    |      |
|   +-+---+---+-+      +----+----+--+   |
|   |  Logical  |      |  Logical   |   |
|   |  Volume   |      |   Volume   |   |
|   |           |      |            |   |
|   |  /home    |      |    /var    |   |
|   +-----------+      +------------+   |

You can use pvdisplay,vgdisplay and lvdisplay commands to show the physical volume,
volume group and logical volume status respectively.

Categories: Linux Tags:

Trac Setup

January 10th, 2009 No comments

Trac is open-source solution for wiki and bugs tracking system.

Follow the following steps to install the Ttac  wiki and bug tracking system version 0.11.2

Prerequiste for Trac installation are

1.    Python version >= 2.3
2.    Setuptools version >= 0.6
3.    Genshi version >= 0.5
4.    SQLite version 3.3.4
5.    Webserver mostly  apache used

Step1: For installing the setup tool and Genshi template download the ez.setup.py script from http://svn.python.org/projects/sandbox/branches/setuptools-0.6/#egg=setuptools-dev06

Step2: Download the tar.gz of trac from the URL http://trac.edgewall.org/wiki/TracDownload

Step3: Uncompress the tar.gz file

tar -xzvf   Trac-0.11.2.tar.gz
cd   Trac-0.11.2

Step4: Now copy ez.setup.py file to Trac-0.11.2 folder and make that script executable

cp ez.setup.py /Trac-0.11.2
cd /Trac-0.11.2
chmod 755   ez.setup.py

now execute it

python ./ez.setup.py

It will automatically  download and install the setuptools.

Now run the
setup.py script

python ./setup.py install

Step5: Now initialize your project varibales by executing the following command.

trac-admin /path/to/project initenv

First give the name to your project whatever you want and then accept all the default options.

Step6: Now initialize the tracd deamon

tracd –port 8000 /path/to/project_dir/

If you want user base authetication on your wiki then setup apache style authetication by adding up user using htpasswd command

htpasswd -c /path/to/project_dir/.htpasswd username

You can add the administrator user by the following command:

trac-admin /path/to/project_dir/ permission add administrator  TRAC_ADMIN

If you are not adding any administrator user then anyone can edit your wiki text. Administrator can give different rights to different users.

Then startd the tracd deamon

 /usr/bin/tracd -p 8000 --basic-auth=Project_name,/path/to/project_dir/.htpasswd,
/path/to/Project_dir /path/to/project_dir/ -d 
Categories: Linux Tags:

Ubuntu Local Repositry Creation

January 10th, 2009 1 comment


    build-essential package

Steps For creating Local Repositry

Step1: Create two directory structures as

mkdir -p /Local_repositry/dists/hardy/main/binary-i386  and
mkdir -p /Local_repositry/pool/main

Step2: Store all  the .deb packages in /Local_repositry/pool/main

Step3: Now open the terminal and type

cd /Local_repositry

Step4: Now execute the below mentioned command

dpkg-scanpackages pool/main/ /dev/null > Packages (/dev/null  
repersents a override file which contains information about how the packeges  
fits into the distribution). 

Step5: Now execute the below mentioned command

cp Packages /Local_repositry/ dists/hardy/main/binary-i386/
gzip Packages
mv Packages.gz /Local_repositry/  dists/hardy/main/binary-i386/

Step6: Now edit your /etc/apt/sources.list file

deb file:///repositry/ hardy main
deb http://IP/ADD/of/REPO/SERVER/  hardy main
apt-get update

Now you can install any package from your local repositry.

If you want to add other packages to your repositry just copy your new .deb package in /Local_repositry/pool/main and repeat step 3,4 and 5. Then you will be able to install new package.

All the credit goes to scribd.com who provide such a good article

URL: www.scribd.com/doc/4753331/Creating-Local-Repository-In-Ubuntu

Categories: Linux Tags:

UBUNTU Network Installation

January 10th, 2009 No comments

GOAL: Install Ubuntu Dekstop from Network or without CD

Prerequiste to Install Ubuntu by network

1.    Ubuntu Alternate CD image
2.    Apache Server
3.    Netboot  Installer

We’ll copy the contents of the CD to a web-accessible share on Apache and then boot the machine-to-be-installed via the netboot installer (CD or USB based options available here).

1. Download the Ubuntu Alternate .iso image from http://ubuntu.com/download for the ubuntu version and variant that you want, saving it to disk (alternate, not desktop!).

2. Install apache

sudo aptitude install apache2

3. Netboot installer image i386 from (http://archive.ubuntu.com/ubuntu/dists/hardy/main/installer-i386/current/images/netboot/) compatible for use with any alternate install image in step #1)

For 64bit download the image from this link http://archive.ubuntu.com/ubuntu/dists/hardy/main/installer-amd64/current/images/netboot/
Now configure the basic apache server by using the following commands:

sudo mkdir /var/www/ubuntu/
sudo mount -o loop /path/to/.iso /mnt         (Mount the iso image)
sudo cp -a /mnt/* /var/www/ubuntu/   (copy the  contents of .iso image to document root directory)

We’re first creating a directory called ubuntu within our apache web-accessible directory. We’re then locally “loop” mounting the CD image to the location /mnt. Finally we’re copying the contents of the CD to our new directory.

Preparing the Installer:

We’ll now need a netboot installer created. This is a very minimal installation CD that can be used to install any other Ubuntu image. For example one copy of this netboot installer will allow you to install previous, current and (most likely) future releases of Ubuntu as long as you have access to the web-accessible CD image or public repository.
This netboot installer image is available for CD or USB image if you prefer one over the other (I prefer USB). Hopefully you’ve already followed step #3 of the Requirements section and you have either the mini.iso or the boot.img.gz file downloaded. To prepare either of those for use do follow these steps: mini.iso (CD)

  • (gnome) insert a writable disk into your machine, right-click mini.iso and select “Write to disk”.
  • (KDE) insert a writable disk into your machine, right-click mini.iso and select “Actions > Write CD image with K3B”

boot.img.gz (USB) You’ll first need to uncompress this file before you can write the image to disk:

sudo gunzip boot.img.gz

insert a USB device that you’ll use as your boot device. ALL DATA WILL BE WIPED TO MAKE IT BOOTABLE. You can use the ‘dmesg’ command to see what device your USB was detected as (sdb, sdc, etc). We’ll then write the contents of the image to the device using dd:

dd if=boot.img of=/dev/sdX

(where X is the device detected with dmesg, sdb, etc)

Starting The Installer:

You should now be ready to install your machine by booting either the CD or via the USB you’ve created. If you have trouble booting to either of those devices you might check your BIOS settings to see that one of them takes priority over the main hard drive.
If you are using the boot.img on a USB you will want to remove this device when you are prompted with the language selection menu. This will help avoid conflicts with drives-to-be-installed, where to install the Boot Loader, etc. You’ll be presented with a very basic menu when the netboot installer loads.
To install only the base system type ‘server‘, then ENTER. For the default installation, press ENTER.

The default installation is suitable for most desktop or laptop systems. Navigate through the installer as normal but watch for the step entitled:

Choose a mirror of the Ubuntu archive

At this step we will tell the installer to use a custom repository, in this case being the locally shared CD contents we set up previously. Instead of selecting your country in this step go up to the first option listed: (pg-up to the top)

enter information manually

If you are given a prompt offering us.archive.ubuntu.com or CC.archive.ubuntu.com you’ve gone too far! The next step will prompt you for the hostname or IP address of the server you will be installing from. This is the IP address of the server you copied the CD contents and installed Apache to. After the hostname or IP is entered the installer will prompt you for the path to the publicly shared contents. If you closely followed these steps the default entry of /ubuntu/ should work. If you copied your CD contents into a folder other than /ubuntu/ you’ll need to update this accordingly. At this point navigate through the installer as normal and enjoy what should be faster installation speeds as network-based is usually faster than CD-based. As usual if you have any questions feel free to leave a comment. It should be noted, again, that this tutorial is probably considered intermediate to advanced so you may not want to undertake this if you’re a n00b.

Reff. Site: http://ubuntu-tutorials.com/2007/10/08/how-to-install-ubuntu-locally-over-the-network/

Categories: Linux Tags: