顯示具有 Linux相關 標籤的文章。 顯示所有文章
顯示具有 Linux相關 標籤的文章。 顯示所有文章

2016年10月12日 星期三

2016年10月11日 星期二

Install 遠端桌面 for ubuntu.

sudo apt-get install xrdp
sudo apt-get install vnc4server
sudo apt-get install xubuntu-desktop
echo "xfce4-session" >~/.xsession
sudo service xrdp restart

2015年10月14日 星期三

kermit note

In the /root/.kermrc, add the below lines

set line /dev/ttyS0
set speed 38400
set carrier-watch off
set handshake none
set flow-control none

2015年10月1日 星期四

2015年9月21日 星期一

Syslog under Ubuntu

vi /etc/rsyslog.conf

#
# Include all config files in /etc/rsyslog.d/
#
$IncludeConfig /etc/rsyslog.d/*.conf

2015年6月2日 星期二

[Linux]HZ, jiffies and tick

HZ: total timer interrupts per second.
tick: 1/HZ, the time for each timer interrupt.
jiffies: total ticks from Linux boot.

Do something after 1 second, e.g. kernel timer
jiffies + (1 second)/ticks = jiffies + HZ


2015年5月25日 星期一

2015年5月13日 星期三

The note for Linux shell

1. Iterate the member in the array
declare -a array

for i in "${arrar[@]}"
do
    echo $i
done

2015年5月12日 星期二

簡易DHCP server架設

In Ubuntu,

1. Configure the server IP as 192.168.1.254

2. Configure the default inteface
vi /etc/sysconfig/dhcpd
INTERFACES="eth3"


2015年4月15日 星期三

[Linux]Custom ioctl command for sockets

於network interface可定義下面的 operations

dev->open = henbin_open;
dev->stop = henbin_close;

如有需要透過sockets呼叫custom ioctl,可增加一個如下的ioctl function

2015年3月16日 星期一

[Linux]Change the baudrate while uncompressing Linux.

Edit the below source file  and change the BAUD_RATE.

linux/arch/arm/include/asm/soc-ast2400/lowlevel_serial.h


2014年12月25日 星期四

[Linux]mount the jffs2 image.

modprobe jffs2;modprobe mtdram;modprobe mtdchar;modprobe mtdblock

dd if=conf.bin of=/dev/mtd0
mount -t jffs2 /dev/mtdblock0 /media

2014年10月7日 星期二

[Linux]使用dd清除raid config

 RAID的config通常是放在最後一個cylinder上的

dd if=/dev/zero of=/dev/sdb bs=100MB seek=4990

資訊來源: http://www.pczone.com.tw/vbb3/archive/t-151980.html

2014年9月2日 星期二

2014年4月24日 星期四

[Linux]How to execute reboot in the Linux driver module

 void rebootBMC(void) {
    int ret;
    char *cmd[2], *path[4];

    cmd[0] = "/sbin/reboot";
    cmd[1] = NULL;
    path[0] = "HOME=/";
    path[1] = "PWD=/";
    path[2] = "PATH=/sbin";
    path[3] = NULL;
    ret = call_usermodehelper(cnd[0], cnd, path, 0);
    printk(KERN_INFO "reboot to enable SMBus Sideband LAN (ret = %d).\n",  ret);
}


You can fill the parameter into cmd[1] and the cmd and path arrays should end with "NULL.


2014年4月10日 星期四

[Linux]Redirect stderr into stdout

Add 2>&1 in the command line.

e.g. ipmitool -H 10.99.6.8 -U USERID -P PASSW0RD sel 2>&1 | awk 'NR==1{print $2}'



2014年4月8日 星期二

[Linux]Read/Write config file in the driver module

#include linux/string.h

static int WriteBondConfToNCSI(void){
struct file *fp;
char buf[128],  *substring;
int indexofsubstring = 0;
mm_segment_t fs;

fp=filp_open("/conf/bond.conf",O_RDONLY,0);

fs = get_fs();
// Set segment descriptor associated to kernel space
set_fs(get_ds());

memset(buf, 0, sizeof(buf));

// Read the file
fp->f_op->read(fp, buf, 128, &fp->f_pos);
set_fs(fs);
filp_close(fp,NULL);

fp=filp_open("/conf/bond.conf",O_WRONLY | O_TRUNC,0);

substring = strstr(buf, "eth");
indexofsubstring = substring - buf;
buf[indexofsubstring+3] = '0';

fs = get_fs();
// Set segment descriptor associated to kernel space
set_fs(get_ds());

fp->f_op->write(fp, (char *)buf, strlen(buf), &fp->f_pos);

set_fs(fs);
filp_close(fp,NULL);

return 0;
}

如果想判斷某檔案是否存在,可利用下列方式:
filep=filp_open("/tmp/aa",O_RDONLY,0);
if(IS_ERR(filep)){
//Not exist
}
else{
//Exist
}

不可使用if(filep == NULL){}

2013年9月5日 星期四

[LINUX]Something for ipmi driver and ipmitool

1. ipmi driver的source code放置於/usr/src/kernels/3.10.4-19_00032_g982b172/driver/char/ipmi下。

2.於/usr/src/kernels/3.10.4-19_00032_g982b172/使用下面command可以complie ipmi driver
make M=driver/char/ipmi

3. ipmi driver不允許user直接送下列的raw commnd,
   raw 0x06 0x33 - Get Message
   raw 0x06 0x34 - Send Message
   raw 0x06 0x35 - Read Event Message Buffer - 可使用ipmiutil getevent取得event

4. 如果要使用ipmitool -t 0x2c -b 6 raw 0x06 0x01,則必須建立nmchannel.i,因為ipmi driver在啟動時,會送Get Channel Info command去scan all channel,如果沒有nm channel的info,ipmi driver即不會傳送bridge command to BMC。

2013年7月17日 星期三

Build SPX in ubuntu

1. Change bash
unlink /bin/sh
ln ‐sf bash /bin/sh

2. install the necessary packages.
apt‐get install libtool
apt‐get install zlib1g
apt‐get install zlib1g‐dev
apt‐get install libcurl4‐gnutls‐dev