2008年12月22日 星期一

How To Copy Master Boot Record (MBR) Between Hard Disks

In Linux you can use the dd command to copy MBR from one hard disk to another. You can also use dd to backup your master boot record to a different (or same) media. One of the common use of MBR copying is to ensure transparent fail-over in RAID-1 hard-disk array, should one hard-disks fail. Read more for examples.

How to copy master boot record from hda to hdb
dd if=/dev/hda of=/dev/hdb bs=512 count=1

BTW: Today I used this command to create identical MBR on my RAID-1 array. So when I removed the first hard-disk from the RAID-1 array, the second hard-disk continued to function without any issue. It is as if nothing has happened at all. Only when you look at /proc/mdstat you can see that only one hard-disk of the array is available.

How to backup master boot record of hda
dd if=/dev/hda bs=512 count=1 > hda_backup

hda_backup now contains the backup of MBR of hda.

How to restore master boot record of hda from hda_backup backup file
dd if=hda_backup of=/dev/hda bs=512 count=1

Note: Replace hda and hdb with the respective identifier for your drives. Hard disks have identifiers like hda, hdb… or sda, sdb… etc. on Linux machines.


2008年12月17日 星期三

rpm vs. dpkg 常用參數對照

dpkg 是 Debian Linux 的套件管理程式, 對於習慣 rpm 的人來說, 一開始接觸 dpkg 時還真有點不太能適應, dpkg --help 查了又忘、忘了又查...

於是整理了一下兩種指令的對照表, 這樣就比較好上手了 :)

安裝

目的 rpm 用法 dpkg 用法
安裝指定套件 rpm -i pkgfile.rpm dpkg -i pkgfile.deb

查詢

目的 rpm 用法 dpkg 用法
顯示所有已安裝的套件名稱 rpm -qa dpkg -l (小寫 L)
顯示套件包含的所有檔案 rpm -ql pkgname (小寫 L) dpkg -L pkgname
顯示特定檔案所屬套件名稱 rpm -qf /path/to/file dpkg -S /path/to/file
查詢套件檔案資訊 rpm -qip pkgfile.rpm (顯示套件資訊)
rpm -qlp pkgfile.rpm (小寫 L, 顯示套件內所有檔案)
dpkg -I pkgfile.deb (大寫 I )
dpkg -c pkgfile.deb
顯示指定套件是否安裝 rpm -q pkgname (只顯示套件名稱)
rpm -qi pkgname (顯示套件資訊)
dpkg -l pkgname (小寫 L, 只列出簡潔資訊)
dpkg -s pkgname (顯示詳細資訊)
dpkg -p pkgname (顯示詳細資訊)

移除

目的 rpm 用法 dpkg 用法
移除指定套件 rpm -e pkgname dpkg -r pkgname (會留下套件設定檔)
dpkg -P pkgname (完全移除)

在 Debian 使用 alien 處理 RPM 套件

alien 可處理 .deb、.rpm、.slp、.tgz 等檔案格式, 進行轉檔或安裝.
於 Debian 安裝非 Debian 套件時, 可使用 alien 進行安裝.
安裝 alien 套件: apt-get install alien

  • 在 Debian 安裝 RPM 套件: alien -i quota-3.12-7.i386.rpm
  • 製作成 deb 的套件格式: alien -d quota-3.12-7.i386.rpm
  • 製作成 rpm 的套件格式: alien -r quota_3.12-6_i386.deb

2008年12月14日 星期日

Slax 就是帥!



Slax 觀念
在 Slax 5 的時代, modules 的副檔名是 .mo,而到了 Slax 6, modules 的副檔名是 .lzm。

Slax 是根基於 Slackware 發展出來的,Slackware 的套件副檔名都是 .tgz,要將 .tgz 轉換成 .mo 或 .lzm,可以進入 Slax 後使用 tgz2lzm 這個工具來轉換,或是到 http://myslax.bonsonno.org/ 下載 MySlax Creator (for Windows) 這個工具將 .tgz 轉換成 .mo。

為了讓 Slax 6 能使用 Slax 5 這些套件,可將 ftp://ftp.slax.org/SLAX-5-modules/ 下載的套件 .mo 副檔名直接改為 .lzm。或將 http://slackware.cs.utah.edu/pub/slackware/slackware-current/slackware/ 下載的套件 .tgz 以 tgz2lzm 來轉換成 .lzm。

SLAX Cheatcodes

Cheatcodes for SLAX Booting parameters or cheatcodes, are used to manipulate the booting process of Linux. Some of them are common for all Linux versions, others are specific to SLAX only. You can use cheatcodes to enable or disable specific hardware detection, to start SLAX from a harddisk or other media, to skip the login prompt and start GUI, etc.

The Process:

With SLAX installed, start to boot your computer. Within a few seconds a graphical SLAX logo should appear. (it's usually there for less then 5 seconds). You will see a "boot: " prompt at that time, under the graphical logo (at the bottom of the screen). Start typing one of the following boot options immediately to be faster than the timeout, or press F1 for a brief help menu.

SLAX Cheatcodes and their functions:

slax acpi=off

slax nohotplug

slax nopcmcia

slax noagp

disables specified hardware autodetection in the case of hangups. Your hardware won't be detected at all, you'll have to use the "pcimodules" command after logging into SLAX and you'll have to try to modprobe all needed modules from the list manually

slax nodma

disable DMA for all CD-ROMs and disks

slax nohd

don't mount any harddisks at all.

slax nocd

don't mount any cdroms at all.

slax nosound

mute sound instead of raising volume to 77%

slax from=/dev/hda1/slax.iso

slax from=path/to/slax.iso

slax from=/dev/hda1

slax from=path/to/slax/

To load SLAX data from different place instead of the boot device. First example will search for slax.iso, only on hda1. Second example will search for 'path/to/slax.iso' on all devices. The first device containing the path/file is used. Third example expects that the ISO is unpacked to hda1. Fourth example searches through all disks for a directory 'path/to/slax' and expects the contents of unpacked ISO in there.

slax passwd=somepass

slax passwd=ask

set root's password to "somepass", or ask (with =ask) for a new password during the boot, before starting slax (don't worry, the new password won't be shown at the login screen)

slax webconfig=passphrase

slax webconfig=ask

manage SLAX webconfig automatically, restore last session from SLAX web during boot and save all modifications when you shutdown slax.

slax noguest

disable guest user so he can't log in.

slax changes=/dev/device

all changes you made in SLAX are kept in memory until you reboot. But with this boot parameter, you tell SLAX to use different device then memory for storing changes. You can, for example, format your disk partition /dev/hda1 with some Linux filesystem (eg. ext2) and then use changes=/dev/hda1 to store all changes to that disk. This way you won't loose your changes after reboot.

slax toram

slax copy2ram

copy all files (all required and optional modules) to RAM. You'll need at least 320MB of RAM to do this and boot SLAX properly. This will slow down the boot phase but it will speed up SLAX!

slax floppy

enable floppy automounting during startup. This option also causes that settings saved by "configsave" command will be restored from the floppy diskette too.

slax load=module

load optional modules from /optional/ directory on the CD. You can use full module name (module.mo) or you can skip the extension.

slax noload=module

slax noload=module[1];module[n]

disable loading of any modules specified. This affects all the modules on SLAX CD, including /base and /modules, so using noload=kde will disable loading of all modules with 'kde' in the name. It is useful with copy2ram cheatcode, because any un-used module is not copied to ram.

slax debug

enable debug mode (start bash several times during the boot) hit Ctrl+D to continue booting.

boot: slax autoexec=…

boot: slax autoexec=startx

boot: slax autoexec=xconf;startx

Execute specified command(s) instead of SLAX login. In this example, skip slax login prompt and automatically start XWindow system. Use semicolon (;) as command separator.

memtest

test RAM with memtest (instead of starting SLAX).

2008年12月10日 星期三

取代Unionfs的好東西 - Aufs

Aufs 的全意是 Another Unionfs,它是為了取代Unionfs而產生的檔案系統。有鑑於Unionfs的極度不穩定,且許久不見改進,作者Junjiro Okajima便建立新的專案取代Unionfs,現在已被Slackware的LiveCD所採用。

LiveCD的資料保存和模組化,是 各家開發者急欲解決的問題。自從Unionfs出現之後,提供了一個良好的解決方案,可惜的是,Unionfs一直未能穩定執行,常常導致Kernel Crash。各LiveCD的開發者們,因此紛紛停用或是選擇性的使用Unionfs。一切又回到原點,LiveCD依然無法模組化或是自由的保存資料。

Aufs的出現讓這瓶頸又出現解決的曙光,它良好的穩定性,去除了Unionfs的致命缺點,非常令人期待!

以下是Aufs的原文簡介:
Aufs was entirely re-designed and re-implemented Unionfs. After many original ideas, approaches, improvements and implementations, it becomes totally different from Unionfs while keeping the basic features.
Unionfs is being developed by Professor Erez Zadok at Stony Brook University and his team.

2008年12月7日 星期日

Wii 網路連線設定

Wii 破解相關

今天你磚了沒有?-新玩家請務必小心
Wiikey相容性測試(2007/08/26之前舊版) 備份區
Wiikey相容度列表(Wii Region Patcher Compatibility List 較新遊戲)



一,首先最重要的:

1.玩不同區的遊戲時請謹慎,尤其是新遊戲.原因是當遊戲內含版本更新時,可能會刷入不同版本的更新程序而變磚.

2.玩同區遊戲可放心玩,基於第1條理論,不會有什麼風險.(截止目前,將來老任會有什麼陰招難講)

3.基於第1條理論,變磚同直讀無關.任何直讀都有可能造成主機變磚.

4.截止目前,對於變磚的主機尚無任何辦法恢復!!!

5.對於支持NGC遊戲的直讀,玩NGC遊戲無變磚風險.



二,那麼為什麼會造成美版機無礙,日版機卻得小心謹慎呢?

1.較早的日版機在設置裡無法看到版本號(其實就是1.x版),而日版機目前還沒有內含能直升到2.0j及以上版本的遊戲(火紋,包括最新的柯南之類更新之後也不是2.0j).所以此類主機玩遊戲必須小心謹慎.美版遊戲,沒確認前最好別玩.

2.較新的日版機(不是最新)一出廠便是2.0j版本,因版本較高故可玩的遊戲較多.但是,玩美版最新的遊戲前請務必來論壇確認!!

3.美版主機目前有內含升級2.x版本的遊戲,所以美版的主機玩家版本較新.相反的,玩日版遊戲就問題不大(因為現在已出的日版遊戲不含高版本的更新,新遊戲的話請先來論壇諮詢確認).但是,玩歐版等不同區的遊戲還是得小心



三,解決方案?

1.日版主機請通過網絡升級到2.2j後再玩其他區的遊戲.如果無網絡條件,那麼請耐心耐心再耐心,等待有其他的更新方法.(美版主機除網絡更新外,目前可通過遊戲來升級)

2.無論任何版本的主機,當玩其他區的遊戲發生更新提示時,請退盤!!!!!不要抱僥倖心理!!!

最後,請重新閱讀一下紅色字並且牢記.

最近重要信息,改機的傢伙們要注意以下遊戲了
Wiikey IC相關
遊戲殺機過程慘劇
[特別關注]WARNING!!日版 2.2J使用口袋妖怪競技場美版升級半磚主機啟動後無法進入設置程序
[特別關注]美版紙片馬里奧:殺日版/歐版主機主機啟動後無法正常運行
[特別關注]日版Wii でやからかあたま塾 腦輕鬆:殺美版主機主機運行後無法進入設置界面
[特別關注]歐版MARIO足球:殺日版主機主機運行後無法進入設置界面
[特別關注]美版頭腦學院:殺日版主機(即使升級到2.2J也殺)主機運行後無法進入設置界面