2010年5月26日 星期三

因為windows安裝使得 RHEL的grub設定失效

經常有一個經驗是當我安裝好Linux(RHEL)後
想在同一台機器再安裝另外一個OS(Windows)
結果裝好時,開機選單卻沒有Linux
原因很簡單,當然是開機選單不再走MBR了
所以這時候,在MBR還存在下
1.用linux rescue mode進入後,讓file system自動mount在/mnt/sysimage
2.chroot /mnt/sysimage,可以發現硬碟裡的linux資料都出現且位置都對
先別高興,這只是chroot後的假象
3.grub-install --recheck /dev/sda ,這裡/dev/sda是/boot所在的 partition磁碟代號
這個動作很掃很久,耐心等完後就完成啦

如果MBR不小心清掉了,例如
dd if=/dev/zeor of=/dev/sda bs=512 count=1
那就只能grub再灌一次了
shell> grub 用root進grub
grub> find /boot/grub/stage1
(hd0,0)
grub>root {hd0,0)
grub>setup (hd0)
grub>quit
如此再寫入MBR後再試看看開機狀況

2010年5月7日 星期五

linux block device uuid and major-minor number


1. uuid

1) vol_id
# sudo vol_id /dev/sda1

2) ls
# ls -l /dev/disk/by-uuid/

3) blkid
# blkid /dev/sda1

software raid
#mdadm -d /dev/md0

refer to: http://www.cyberciti.biz/faq/linux-finding-using-uuids-to-update-fstab/

2.major-minor number
1)
# cat /proc/partitions
major minor #blocks name

8 0 286513152 sda
8 1 104391 sda1
8 2 286390755 sda2
8 16 488243200 sdb
8 17 488239416 sdb1
8 32 976588800 sdc
8 33 976583286 sdc1
253 0 284327936 dm-0
253 1 2031616 dm-1

2)
# cat /sys/block/sda/sda1/dev
8:1
# cat /sys/block/sda/sda2/dev
8:2

2010年5月6日 星期四

Installing grub in ubuntu

When you just finished you ubuntu installation proccess,
you might forget grub.
Now you could install it by following steps:

root@sean-ubuntu:/boot/grub# fdisk -l

Disk /dev/sda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x2d73085e

Device Boot Start End Blocks Id System
/dev/sda1 1 243 1951866 82 Linux swap / Solaris
/dev/sda2 5905 9728 30716280 f W95 Ext'd (LBA)
/dev/sda3 * 244 5904 45471982+ 83 Linux
/dev/sda5 5905 9728 30716248+ 7 HPFS/NTFS

Partition table entries are not in disk order
root@sean-ubuntu:/boot/grub# grub-install /dev/sda3
Searching for GRUB installation directory ... found: /boot/grub
Installing GRUB to /dev/sda3 as (hd0,2)...
Installation finished. No error reported.
This is the contents of the device map /boot/grub/device.map.
Check if this is correct or not. If any of the lines is incorrect,
fix it and re-run the script `grub-install'.

(hd0) /dev/sda

root@sean-ubuntu:/boot/grub# update-grub
Searching for GRUB installation directory ... found: /boot/grub
Searching for default file ... found: /boot/grub/default
Testing for an existing GRUB menu.lst file ...

Could not find /boot/grub/menu.lst file. Would you like /boot/grub/menu.lst generated for you? (y/N) y
Searching for splash image ... none found, skipping ...
Found GRUB 2: /boot/grub/core.img
Found kernel: /boot/memtest86+.bin
Found kernel: /boot/vmlinuz-2.6.31-14-generic
Found GRUB 2: /boot/grub/core.img
Found kernel: /boot/memtest86+.bin
Updating /boot/grub/menu.lst ... done
root@sean-ubuntu:/boot/grub# vi menu.lst


Now , we should considerate about 2nd Operation System(like Windows XP).
root@sean-ubuntu:/boot/grub# vi menu.lst
#insert to the end of menu.lst
title windows partition
rootnoverify (hd0,4)
chainloader +1
makeactive


Finially, you should to make MBR available for the Grub multi-boot function.
in linux(ubuntu)
#grub
grub> find /boot/grub/stage1
(hd0,2)
grub> root (hd0,2)
grub> setup(hd0)
grub> quit
and the reboot the linux, you will see a grub menu( /boot/grub/menu.lst)

PS.
1.if you want to make Windows and Ubuntu in the same PC
see: wubi for windows
or
install ubuntu in windows by wubi
2.grub reference: Grub basic

ubuntu使用tightvncserver


在ubuntu要安裝vnc,可以用tightvncserver
原文請參考:http://usagiblog.wordpress.com/
以root的身份安裝:
$ apt-get install tightvncserver
接下來以一般的使用者的身份啟動:
$ vncserver
第一次啟動時會要求設定密碼, 按照螢幕上的指示輸入即可, 接著會出現「New ‘X’ desktop is 主機名稱:1」之類的訊息, 後面的1就是desktop的號碼.
之後就可以用vncviewer或其他vnc client連進去看, client這邊要指定連接埠或desktop的號碼, 若desktop是1的話, 連接埠就是5901, 2就是5902, 餘類推.
關閉vncserver的指令是:
$ vncserver -kill :1
1就是desktop的號碼.
可以修改~/.vnc/xstartup這個檔, 讓vncserver可以啟動GNOME或KDE
$ vim ~/.vnc/xstartup
把#!/bin/sh以外的文字都註解掉, 若想啟動GNOME, 加上
exec gnome-session
即可, KDE則是
exec startkde

安裝如果發現遠端桌面鍵盤有亂掉的狀況,那可以見下解法
原文請參考:
https://bugs.launchpad.net/ubuntu/+source/vnc/+bug/112309
The problem was solved for me with this tip:
http://www.tips5.com/how-to-fix-keyboard-mapping-issue-of-gnome-vnc-in-ubuntu
The workaround is to include the line "export XKL_XMODMAP_DISABLE=1" in ~/.vnc/xstartup as in
#!/bin/sh
xrdb $HOME/.Xresources
xsetroot -solid grey
#x-terminal-emulator -geometry 80×24+10+10 -ls -title “$VNCDESKTOP Desktop” &
#x-window-manager &
export XKL_XMODMAP_DISABLE=1

/etc/X11/Xsession
apparently it has to be before the "/etc/X11/Xsession" line

文章分類