2010年1月16日 星期六

grub rescue after re-partition by Windows

Situation:
I install Ubuntu9.10 (with grub loader) in /dev/sda10.
(My MBR bootloader is spfdisk)
Someday, I boot the system to Windows (/dev/sda2) and re-partition /dev/sda3 to NTFS.
After rebooting to Ubuntu9.10, a problem comes: some Windows program has changed the disk MBR and my Ubuntu9.10 is no more in /dev/sda10. It's in /dev/sda9 in the new MBR.

So when boot to /dev/sda9, grub can't find linux in /dev/sda10.
It is in /dev/sda9 now !



--------- in grub rescure, manually boot to /dev/sda9 -------

grub rescue>

set prefix=(hd0,9)/boot/grub

insmod (hd0,9)/boot/grub/linux.mod

----- now you can use [tab] auto-completion ---

set root=(hd0,9) linux /boot/vmlinuz26 root=/dev/sda9 initrd /boot/kernel26.img boot

----- this will boot to Ubuntu 9.10 ------

sudo update-grub
sudo grub-install /dev/sda9

(this will update your grub settings, esp. your boot menu,
so that you can boot normally into Ubuntu9.10 next time)


Reference:

2010年1月13日 星期三

generate a (pseudo) random number in sh

Print a pseudo-random byte (hex) in sh:

cat /dev/urandom | od -t x1 -A n -N 1

->89

-----------

Create a pseudo-random file of size 1 MB:
dd if=/dev/urandom of=a.log bs=1M count=1


Ref:

2010年1月1日 星期五

Install a New font in Ubuntu

For instance, I want to install a new font "Crisp" to my Ubuntu 9.10:


1. Create a new directory for your new font:

sudo mkdir /usr/share/fonts/truetype/crisp/

sudo cp ~/download/Crisp.ttf /usr/share/fonts/truetype/crisp/


2. Rebuild the font information files:

sudo fc-cache -f -v | grep -i crisp

-> /usr/share/fonts/truetype/crisp: caching, new cache contents: 1 fonts, 0 dirs


3. Restart the programs in which you want to use the new font.


--------
Ref:

2009年12月8日 星期二

Electronic circuits

Pull-up resistor

Pull-up resistors are used in electronic logic circuits to ensure that inputs to logic systems settle at expected logic levels if external devices are disconnected.

tri-state (vt)

When outputs are tri-stated (in the Hi-Z state) their influence on the rest of the circuit is removed, and the circuit node will be "floating" if no other circuit element determines its state.

連結

PLL (phase-locked loop)

A PLL is a control system that generates a signal that has a fixed relation to the phase of a "reference" signal.

vim 啟用 syntax color (eg. for bash script)

1. 先試式能否在 vim 中動態切換 color:
按:進入command mode 試試
:syntax on
:syntax off

如果沒有顏色,可能副檔名沒有比對成功,手動設定 syntax filetype:
(例如使用 shell script 的 syntax)
:set syn=sh

2. 編輯 /etc/vim/vimrc
把 syntax on 註解打開
或是只想動到個人設定,只在~/.vimrc 加入"syntax on"

2009年12月5日 星期六

LPC bus (Low Pin Count)

What's LPC ? (from LPC bus in Plug-and-Play-HOWTO)
* a type of slow bus, used for slow "legacy" devices such as serial ports, floppy devices, etc.
* replace old ISA bus: LPC needs fewer pins, and uses a faster clock speed
* its bus for data/address and control is only 4 bits wide (so "low pin count")
* all LPC devices are on-board; there are no LPC slots
* a major chip on the LPC bus is the superio chip


2009年11月23日 星期一

Moschip linux driver for EMT PCI Express to port RS232 (serial)

Driver:
Moschip download
(need to register)

Patch for 2.6.28:
starex_2.6.28.patch.gz
(source:http://forums.linuxmint.com/viewtopic.php?f=49&t=29576/MCS9901_Linux/version1.6)

Usage:
@Drivers/MCS9901_Linux/version1.6 $ gzip -d starex_2.6.28.patch.gz
@Drivers/MCS9901_Linux/version1.6 $ ls
MCS9901_Linux_UM_Ver0.4.pdf starex starex_2.6.28.patch starex.tar.gz
@Drivers/MCS9901_Linux/version1.6 $ patch -p0 <>make
->sudo make install
->ls /dev/ttyD*
->lspci -v (After install)
03:00.0 Serial controller: NetMos Technology PCIe 9901 Multi-I/O Controller (prog-if 02)
Subsystem: Device a000:1000
Flags: bus master, fast devsel, latency 0, IRQ 17
I/O ports at ec00 [size=8]
Memory at febff000 (32-bit, non-prefetchable) [size=4K]
Memory at febfe000 (32-bit, non-prefetchable) [size=4K]
Capabilities: [80] Power Management version 3
Capabilities: [88] Message Signalled Interrupts: Mask- 64bit+ Queue=0/5 Enable-
Capabilities: [c0] Express Legacy Endpoint, MSI 00
Capabilities: [100] Power Budgeting
Capabilities: [200] Device Serial Number aa-bb-cc-dd-ee-ff-99-88
Kernel driver in use: starex-serial
Kernel modules: 9900-isa


You may need to modify Makefile before calling "make install":
(My OS is Ubuntu 9.04)
#ln -s /etc/init.d/mcs9900 /etc/rc.d/rc3.d/Smcs9900 || true
#ln -s /etc/init.d/mcs9900 /etc/rc.d/rc5.d/Smcs9900 || true
ln -s /etc/init.d/mcs9900 /etc/rc2.d/Smcs9900 || true
ln -s /etc/init.d/mcs9900 /etc/rc3.d/Smcs9900 || true
ln -s /etc/init.d/mcs9900 /etc/rc5.d/Smcs9900 || true

so that the driver is loaded when OS starts.