Posts

Showing posts with the label Administration

Add new hard drive in Debian

Its unfortunely that my disk array (RAID 5 with 4 hard drive) degraded because of a hard drive failed. For data safty issue, I have to back up all data and rebuild it again! After rebuilt, I have to re-mount it again as new hard drive into my system. Here is the procedure for notes. At first, make sure the disk is the one I want to re-mount. $ sudo fdisk -l /dev/sdc Disk /dev/sdc: 1500.0 GB, 1499999502336 bytes 64 heads, 32 sectors/track, 1430511 cylinders, total 2929686528 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000  Disk /dev/sdc doesn't contain a valid partition table Its lucky I found it! And I'll create a new partition on it. $sudo cfdisk /dev/sdc Just follow those steps below... New -> Primary -> specify size in MB Write Quit After that, I can see following message when success! Disk has been changed.  WARNING: If you have created o...

How to mount LVM partition in Debian/Ubuntu

How to mount LVM partition that just appended into system? Just follow below steps and get it! Install package:lvm2 if you did not enable it. $ sudo apt-get install lvm2 Load the necessary module: dm-mod. $ sudo modprobe dm-mod Scan LVM volumes in your system. $ sudo vgscan or $ sudo pvs Activate the LVM volume. $ sudo vgchange -a y [LVM Group] Find the logical volume. $ sudo lvs or $ sudo lvdisplay /dev/[LVM_group_name] Mount the logical volume you want access it. $ sudo mount /dev/mapper/[LVM_group_name]-[LVM-logical-volume-name] /mnt -o ro,user You can access the LVM partition now in /mnt. Enjoy it. :-)

PHP: Unable to load dynamic library suhosin.so in Debian sid

When you install php5 in Debian sid, you'll get following warning after updating. PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20100525/ suhosin.so' - /usr/lib/php5/20100525/ suhosin.so: cannot open shared object file: No such file or directory in Unknown on line 0 And you will get a punch of   annoying  system mail. Orz After searching on google, I got the answer from Debian bug mailing list. http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=668739 The problem is the suhosin was obsoleted in Debian sid and it will be remove after system upgrading. But its configuration still exist in /etc/php5/conf.d. shawn:/usr/lib/php5$ dpkg --list | grep php5 | more ii  libapache2-mod-php5                5.4.4-14                  amd64        server-side, HTML-embedded scripting language (Apache 2 module) ii  php5         ...

Apache X-Forward-For settings for behinding reverse proxy

Add following settings into your httpd.conf or the configuration file in sites-available that linked to sites-enabled. LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" proxy  SetEnvIf X-Forwarded-For "^.*\..*\..*\..*" forwarded  CustomLog "logs/access_log" combined env=!forwarded CustomLog "logs/access_log" proxy env=forwarded After saving the settings, restart your httpd and you should see the real client IP in access log.

Convert Debian amd64 to multi-arch

Do following steps... sudo dpkg --add-architecture i386 sudo sed -i 's/deb\ /deb\ [arch=amd64,i386]\ /g' /etc/apt/sources.list sudo apt-get clean; sudo apt-get autoclean; sudo apt-get update After that you can install the packages that only support i386 such like skype. Enjoy it!

Restart networking service on Debian

Most Debian user should run into this problem before they find out a good way to restart networking service. Debian deprecated the restart option of /etc/init.d/networking script for security issue. Users will get following warning when they do restart: Running /etc/init.d/networking restart is deprecated because it may not enable again some interfaces ... (warning). And their network won't be restart finally. How to restart the networking service? There are several ways to achieve that. (Login as root or sudo it) /etc/init.d/networking stop && /etc/init.d/networking start (You'd better run the command on console than remote it) inovke-rc.d networking restart Hope those helpful for you and me. :-)

Resolution change manually on Ubuntu 10.04

Show current setting $ xrandr -q Screen 0: minimum 320 x 200, current 1024 x 768, maximum 8192 x 8192 VGA1 connected 1024x768+0+0 (normal left inverted right x axis y axis) 338mm x 270mm 1024x768 60.0* 800x600 60.3 56.2 848x480 60.0 640x480 59.9 Get new mode line with new resolution $ cvt 1280 1024 60 # 1280x1024 59.89 Hz (CVT 1.31M4) hsync: 63.67 kHz; pclk: 109.00 MHz Modeline "1280x1024_60.00" 109.00 1280 1368 1496 1712 1024 1027 1034 1063 -hsync +vsync Create a new mode for new resolution $ sudo xrandr --newmode "1280x1024_60.00" 109.00 1280 1368 1496 1712 1024 1027 1034 1063 -hsync +vsync Add the new mode $ sudo xrandr --addmode VGA1 "1280x1024_60.00" Check if new mode exist? $ xrandr -q Screen 0: minimum 320 x 200, current 1024 x 768, maximum 8192 x 8192 VGA1 connected 1024x768+0+0 (normal left inverted right x axis y axis) 338mm x 270mm 1024x768 60.0* 800x600 60.3 56.2 848x480 ...

equinox-theme installation on Ubuntu/Debian

Please follow steps below: Find equinox project on launchpad.net, then you can see the ppa path in the page. Install Ubuntu sudo add-apt-repository ppa:tiheum/equinox Debian sudo vim /etc/apt/sources.list Add a line: deb http://ppa.launchpad.net/tiheum/equinox/ubuntu lucid main sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4631BBEA sudo apt-get update sudo apt-get install equinox-theme faenza-icon-theme Open preference/appearence and change theme to Equinox Evolution Then, you can enjoy it!

UNetbootin installation on Ubuntu 9.10 (Karmic) and later

$ sudo add-apt-respository ppa:gezakovacs/ppa $ sudo apt-get update $ apt-cache search unetbootin --> To check if we can find unetbootin $ sudo apt-get install unetbootin

LaTeX installation with beamer class on Ubuntu

$ sudo apt-get install latex-cjk-chinese latex-beamer Then, you can create slide with LaTeX beamer class.

Rename folders from Chinese to English in Ubuntu/Debian

$ export LANG=en_US $ xdg-user-dirs-gtk-update A dialog will popup and change it. Non-empty folders will be keep. Move all files to new folders named in English from original folders. $ export LANG=zh_TW.UTF-8

Latex installation on Archlinux

Nowadays, if we want to use LaTeX, we have to install the texlive package for it. And it is very easy to install all of those needed packages on Archlinux. $ sudo pacman -S texlive-core texlive-langcjk texlive-latexextra texlive-pictures Then, you can enjoy it now!

Homebrew - Another package manager for Mac OS X

前陣子在 plurk 上看到 Rex 大提到 Homebrew,一開始也不曉得那是什麼? 慢慢才知道原來是另一種套件管理工具。 今天在看到 ihower 大大的 blog 文章後,索性就動起來手來,先把 MacPorts uninstall 掉,然後再依照 ihower 大大提供的步驟把 homebrew 裝了起來。(作法請參考 ihower 大大的 原文 ) Homebrew 是一套 ruby based 的套件管理程式,它的特性如下﹕ 不佔用系統空間 不重覆安裝 mac 系統中已內建的工具 ruby based 的 portfile,易於修改、自訂 使用者可很快的建立自己想要的套件 個人用了之後,覺得 MacPorts 更新較快、內容較多,但,Homebrew 則是標榜不重覆,簡易使用。 果真簡易!

MacPorts uninstall

Following the steps below: Uninstall ALL installed packages $ sudo port -f uninstall installed Remove related directories $ sudo rm -rf \ /opt/local \ /Applications/DarwinPorts \ /Applications/MacPorts \ /Library/LaunchDaemons/org.macports.* \ /Library/Receipts/DarwinPorts*.pkg \ /Library/Receipts/MacPorts*.pkg \ /Library/StartupItems/DarwinPortsStartup \ /Library/Tcl/darwinports1.0 \ /Library/Tcl/macports1.0 \ ~/.macports Now, its clear and all installed packages from MacPorts was disappeared.

MacPorts update & upgrade

To update MacPorts $ sudo ports selfupdate To upgrade outdated installed applications $ sudo ports upgrade outdated

How to downgrade FreeBSD's Ports

su as root cd /usr/ports/ports-mgmt/portdowngrade; make install clean; rehash setenv CVSROOT :pserver:anoncvs@anoncvs.tw.FreeBSD.org:/home/ncvs cvs login portdowngrade www/p5-FastCGI portsdb -Uu portupgrade -f p5-FastCGI

The power of Intel Quad core * 2 + FreeBSD 8 amd64

Image
因工作上的需求,我必須處理 Subversion 因為 svn blame 造成的高系統負載問題。 作業環境如下: FreeBSD 7.2 Apache 2.x Subversion 1.x viewvc 1.x 在原來的硬體環境: CPU: Intel Xeon 3.06 GHz with HT RAM: 2GB HDD: SCSI FreeBSD/SMP: Multiprocessor System Detected: 4 CPUs cpu0 (BSP): APIC ID: 0 cpu1 (AP/HT): APIC ID: 1 cpu2 (AP): APIC ID: 6 cpu3 (AP/HT): APIC ID: 7 一旦使用者透過 viewvc 執行 annotate 的工作,只要一個! 且單一檔案內容超過萬行的情況下,就會造成系統高負載 (average load 破百) 的情況,最嚴重的狀況是連 console 操作都會 hang 住! 而且 httpd 和 svn 的 process 數量也 fork 很多出來! 深究其因,應該是 viewvc 造成的! 其次,CPU 僅是透過 HT 虛擬成 4 個 cpu,而並非真正 multiple core,因此運算能力也相對較弱! 以提供服務的角度來看,這個功能是使用者經常用到的! 因此,除了去 trace viewvc 外,唯一可解的就是硬體升級了! 新的硬體環境: CPU: Intel Xeon E5420 2.5 GHz RAM: 48 GB HDD: SAS FreeBSD/SMP: Multiprocessor System Detected: 8 CPUs FreeBSD/SMP: 2 package(s) x 4 core(s) cpu0 (BSP): APIC ID: 0 cpu1 (AP): APIC ID: 1 cpu2 (AP): APIC ID: 2 cpu3 (AP): APIC ID: 3 cpu4 (AP): APIC ID: 4 cpu5 (AP): APIC ID: 5 cpu6 (AP): APIC ID: 6 cpu7 (AP): APIC ID: 7 OS 改用 FreeBSD 8 amd64 的版本,將 /tmp 透過 md 掛載大小為 18G ...

Memory based file system (ramdisk) on FreeBSD

To create a ramdisk for /tmp and detach it on FreeBSD 8 # /sbin/mdmfs -M -S -o async -s size md0 /tmp Don't forget to chmod +w for read/write # chmod +w /tmp Detach it and delete from /dev/md0 # /sbin/mdconfig -d -u 0 There is a shell script for the operation %cat ramdisk.sh #!/bin/sh case "$1" in create) /sbin/mdmfs -M -S -o async -s 18432m md0 /tmp /bin/chmod 777 /tmp echo "18G ramdisk created on md0 and mounted on /tmp" exit 0 ;; destory) /sbin/umount /tmp /sbin/mdconfig -d -u 0 echo "ramdisk umounted from /tmp and destory from md0" ;; *) echo "Usage: `basename $0` {create|destory}" >&2 exit 64 ;; esac Caution ! This is for specificed purpose only! You have to modify the parameters if you want to use it.

Queue full event with LSI Logic SAS/SATA Adapter on FreeBSD 7.2

I ran into this trouble while installing FreeBSD 7.2 to IBM IntelliStation Z Pro that within LSI SAS/SATA adapter (mpt0)... mpt0: port 0x2000-0x20ff mem 0xfd210000-0xfd213fff,0xfd200000-0xfd20ffff irq 16 at device 0.0 on pci1 mpt0: [ITHREAD] mpt0: MPI Version=1.5.13.0 mpt0: Capabilities: ( RAID-0 RAID-1E RAID-1 ) mpt0: 0 Active Volumes (2 Max) mpt0: 0 Hidden Drive Members (10 Max) It will show following message repeat many times while disk accessing... mpt0: QUEUE FULL EVENT: Bus 0x00 Target 0x00 Depth 128 It might not crash your system but still annoying though! The reason is the hard drive do not accept too much access in queue (That means it depends on hard drive factory setting)! Okay, you can check its default setting with following commands... # camcontrol tag da0 (pass0:mpt0:0:0:0): device openings: 255 You should set its tags lower than the error shows. # camcontrol tag da0 -N 127 (pass0:mpt0:0:0:0): device openings: 127 After that, you can test it with find... # cd / # find ....

Format in cron table

minute hour day month day-of-week [command]