Archive for System

How to attach a new hard disk to ubuntu linux

Posted in System with tags , , , on May 8, 2008 by wsjoung

root@server-tribeca:/etc# fdisk -l

Disk /dev/sda: 40.0 GB, 40020664320 bytes
255 heads, 63 sectors/track, 4865 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x9dc96e9e

Device Boot Start End Blocks Id System
/dev/sda1 * 1 4689 37664361 83 Linux
/dev/sda2 4690 4865 1413720 5 Extended
/dev/sda5 4690 4865 1413688+ 82 Linux swap / Solaris

Disk /dev/sdb: 120.0 GB, 120034123776 bytes
255 heads, 63 sectors/track, 14593 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00a080f4

Device Boot Start End Blocks Id System
/dev/sdb1 * 1 13 104391 83 Linux
/dev/sdb2 14 14471 116133885 83 Linux
/dev/sdb3 14472 14593 979965 82 Linux swap / Solaris

root@server-tribeca:/etc# fdisk /dev/sdb

The number of cylinders for this disk is set to 14593.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): d
Partition number (1-4): 1

Command (m for help): d
Partition number (1-4): 2

Command (m for help): d
Selected partition 3

Command (m for help): d
No partition is defined yet!

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-14593, default 1): 1
Last cylinder or +size or +sizeM or +sizeK (1-14593, default 14593):
Using default value 14593

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

root@server-tribeca:/etc# mkfs.ext3 /dev/sdb1
mke2fs 1.40.8 (13-Mar-2008)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
7331840 inodes, 29304560 blocks
1465228 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
895 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872

Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 22 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.

root@server-tribeca:/etc# ls /dev/disk/by-uuid -alh
lrwxrwxrwx 1 root root 10 2008-05-07 17:58 753a86d9-6228-4725-a9ae-6f457c2b1824 -> ../../sdb1
lrwxrwxrwx 1 root root 10 2008-05-07 17:58 dbd44197-c1c5-427d-9a34-40f652b92f42 -> ../../sda1
lrwxrwxrwx 1 root root 10 2008-05-07 17:58 e15f5c2c-fc1f-414d-8c67-99c567f44d6a -> ../../sda5

root@server-tribeca:/etc# mkdir /disk1

root@server-tribeca:/etc# vi /etc/fstab
# /etc/fstab: static file system information.
#
# <file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc defaults 0 0
# /dev/sda1
UUID=dbd44197-c1c5-427d-9a34-40f652b92f42 / ext3 relatime,errors=remount-ro 0 1
# /dev/sda5
UUID=e15f5c2c-fc1f-414d-8c67-99c567f44d6a none swap sw 0 0
/dev/scd0 /media/cdrom0 udf,iso9660 user,noauto,exec,utf8 0 0
/dev/fd0 /media/floppy0 auto rw,user,noauto,exec,utf8 0 0
UUID=753a86d9-6228-4725-a9ae-6f457c2b1824 /disk1 ext3 defaults,errors=remount-ro 0 1

Advertisements

Changing Timezon and NTP On Ubuntu server

Posted in System with tags , , , on May 5, 2008 by wsjoung

Timezon Config

dpkg-reconfigure tzdata

Time Synchronisation with NTP

as root, create a file /etc/cron.daily/ntpdate containing:
ntpdate ntp.ubuntu.com
The file /etc/cron.daily/ntpdate must also be executable
sudo chmod 755 /etc/cron.daily/ntpdate

Linux signal

Posted in System with tags , , , on November 17, 2006 by wsjoung

I was writing a shell scripts to manage my process. basically I have some jobs need to be run for long time at least 2 weeks, but the problem is that the system manager will kill all my processes during the night because it takes too much cpu resource and it increases the temperature.

So, I wanted to write a small scripts which can make all my processes stop during the night and resume next day.

There is SIGNALs

`HUP’ : 1. Hangup.

`INT’ : 2. Terminal interrupt.

`QUIT’ : 3. Terminal quit.

`ABRT’ : 6. Process abort.

`KILL’ : 9. Kill (cannot be caught or ignored).

`ALRM’ : 14. Alarm Clock.

`TERM’ : 15. Termination.

`BUS’ : Access to an undefined portion of a memory object.

`CHLD’ : Child process terminated, stopped, or continued.

`CONT’ : Continue executing, if stopped.

`FPE’ : Erroneous arithmetic operation.

`ILL’ : Illegal Instruction.

`PIPE’ : Write on a pipe with no one to read it.

`SEGV’ : Invalid memory reference.

`STOP’ : Stop executing (cannot be caught or ignored).

`TSTP’ : Terminal stop.

`TTIN’ : Background process attempting read.

`TTOU’ : Background process attempting write.

`URG’ : High bandwidth data is available at a socket.

Especially TSTP and CONT was useful for my job.
for example,

for line in $(cat $hosts)
do
pid=$(rsh $line ps aux|grep “rosetta.gcc”|awk ‘{print $2}’);
if [ $pid ] ; then
rsh $line kill -TSTP $pid
fi
done

Tomasulo’s Algorithm

Posted in Algorithm with tags , , on November 17, 2006 by wsjoung

An Efficient Algorithm for Exploiting Multiple Arithmetic Units, R. M. Tomasulo, IBM Journal, January 1967

instructions and it’s execution plan would be like this.

div Rg, Rb, Rc
add Rh, Rg, Rd (data hazard)
mul Rg, Re, Rf
add Ra, Rh, Rg (data hazard)

106670243_bb27bd269b.jpg

then, we should maintain RS(Reservation Station) for 2nd and 4th instructions because those instruction need to wait for previous result. and, RS may look like this. source operands of the 1st instruction are ready and the result would be tagged T1 for register Rg and then put this tag T1 and mark busy bit into register till the result comes out. but the first operand of 2nd instruction is not ready when this instruction decode. it need to wait for Rg which is tagged for T1 by previous instruction. by looking up the register, we can figure out. if busy bit is set, the register is not available. so, we should wait for this tagged result.

Ready Tag Contents Ready Tag Contents Register
Y Rb Y Rc T1
N T1 Y Rd T2
Y Re Y Rf T3
N T2 N T3 T4

RS and register will watch the result bus to get tagged result. for this example, we will get T1 first then 2nd instruction will be ready to go. when we got 2nd tagged result(T3), left operand of 4th instruction will be ready and the busy bit of the register Rg will be marked free(N).

busy Tab register
Y T4 Ra
Y T2 Rh
N T3 Rg