Friday, July 24, 2009

Mount external hard drive in Ubuntu server

Insert external hard drive usb connector into the Ubuntu server usb port. Ubuntu server automatically detect the external hard drive as a usb device.the external hard drive will be detected as sdb. That is the name of the external hard drive to use when we are going to mount the device. We can check the device in /proc/scsi/scsi file. To do that, issue the command as in the example below:

luzar@ubuntu:~$ cat /proc/scsi/scsi
Attached devices:
Host: scsi1 Channel: 00 Id: 00 Lun: 00
Vendor: NECVMWar Model: VMware IDE CDR10 Rev: 1.00
Type: CD-ROM ANSI SCSI revision: 05
Host: scsi2 Channel: 00 Id: 00 Lun: 00
Vendor: VMware, Model: VMware Virtual S Rev: 1.0
Type: Direct-Access ANSI SCSI revision: 02
Host: scsi3 Channel: 00 Id: 00 Lun: 00
Vendor: Generic Model: USB Disk Rev: 9.02
Type: Direct-Access ANSI SCSI revision: 02
luzar@ubuntu:~$

Create a proper directory in Ubuntu server to mount the external hard drive. In this example, we create a directory named extdisk in /mnt directory:

luzar@ubuntu:~$ sudo mkdir /mnt/extdisk
[sudo] password for luzar:
luzar@ubuntu:~$ ls /mnt/
dvd extdisk usb win

Now we can mount the external hard drive with Linux mount command:

luzar@ubuntu:~$ sudo mount /dev/sdb /mnt/extdisk/
mount: you must specify the filesystem type

The external hard drive cannot be mounted. This happened when we mount a windows formatted external hard drive. We must specify the filesystem. Windows filesystem format is known as nsfs-3g in Linux. So we mount the external hard drive again with the complete command:

luzar@ubuntu:~$ sudo mount -t ntfs-3g /dev/sdb /mnt/extdisk/
NTFS signature is missing.
Failed to mount '/dev/sdb': Invalid argument
The device '/dev/sdb' doesn't have a valid NTFS.
Maybe you selected the wrong device? Or the whole disk instead of a
partition (e.g. /dev/hda, not /dev/hda1)? Or the other way around?

We still cannot mount the external hard drive. Again, we mount the external hard drive but this we change the device name from /dev/sdb to /dev/sdb1 as suggested by Ubuntu message above.

alok@ubuntu:~$ sudo mount -t ntfs-3g /dev/sdb1 /mnt/extdisk/
alok@ubuntu:~$ ls /mnt/extdisk/
ghost dell170l ghost mimos RECYCLER System Volume Information
alok@ubuntu:~$

We successfully mounted the external hard drive this time. Now that the external drive has been mounted, we can use it as other directory in Ubuntu.

To unmount the external hard drive, we can use the Linux umount command like in the example below:

alok@ubuntu:~$ sudo umount /mnt/extdisk/
[sudo] password for alok
alok@ubuntu:~$

That's all.

Sunday, July 5, 2009

how to Install NS2 2.33 in ubuntu

1. Download ns-allinone-2.33.tar from
2. Place it in somewhere, e.g. /home/programmer, then extract it.
$ cd /home/programmer
$ tar -xvf ns-allinone-2.33.tar
3. Download & install some packages from repository
$ sudo apt-get install build-essential autoconf automake libxmu-dev
4. Install the ns2
$ cd ns-allinone-2.33
$ ./install
5. Edit some paths
$ gedit ~/.bashrc
Put these lines on that file. Off course, you might change /home/programmer for it depends on where you extract ns-allinone-2.33.tar.
# LD_LIBRARY_PATH
OTCL_LIB=/home/programmer/ns-allinone-2.33/otcl-1.13
NS2_LIB=/home/programmer/ns-allinone-2.33/lib
X11_LIB=/usr/X11R6/lib
USR_LOCAL_LIB=/usr/local/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$OTCL_LIB:$NS2_LIB
:$X11_LIB:$USR_LOCAL_LIB


# TCL_LIBRARY
TCL_LIB=/home/programmer/ns-allinone-2.33/tcl8.4.18/library
USR_LIB=/usr/lib
export TCL_LIBRARY=$TCL_LIB:$USR_LIB

# PATH
XGRAPH=/home/programmer/ns-allinone-2.33/bin:/home/programmer/ns-allinone-2.33/tcl8.4.18/unix:/home/programmer/ns-allinone-2.33/tk8.4.18/unix:/home/programmer/ns-allinone-2.33/xgraph-12.1/
NS=/home/programmer/ns-allinone-2.33/ns-2.33/
NAM=/home/programmer/ns-allinone-2.33/nam-1.13/
export PATH=$PATH:$XGRAPH:$NS:$NAM

6. Validate it (take very long time compare to install process)
$ cd ns-2.33
$ ./validate
7. (Optionally) Create a symlink, so that ns can be called from everywhere
$ sudo ln -s /home/programmer/ns-allinone-2.33/ns-2.33/ns /usr/bin/ns
8. Let it take effect immediately
$ source ~/.bashrc
9. Try to run it (and pray :)
$ ns
10. If the installation success, you will see % at the command prompt. Type following command to exit
% exit