2011年1月29日 星期六

圖解:三種方式,在Acer桌機上安裝Ubuntu – Windows雙系統
Illustration: how I install Ubuntu-Windows dual boot system on my Acer desktop

-- 2011-01-31 更新:增加為 9張圖片
-- 2011-03-08 更正錯誤:「真.雙系統」的 Ubuntu 是可以直接存取 C 槽(sda2)的!

在 Windows 桌機上,安裝 Ubuntu - Windows 雙系統的方式,有三種可以選擇:
  1. 虛擬雙系統:
    在 Windows 裡面安裝虛擬軟體 Virtualbox,然後在 Virtualbox 所設定的虛擬機器中,安裝 Ubuntu。
    每次開機時,要先開 Windows,再開 Virtualbox,最後才是虛擬的 Ubuntu。
  2. 偽.雙系統:
    在 Windows 裡面安裝雙開機軟體 Wubi,將 Ubuntu 當作 Windows 中的一個程式來執行。
    每次開機時,可以選擇要進入 Windows 或是 Ubuntu。(Windows 開機選單)
  3. 真.雙系統:
    在 Windows 裡面將 C 槽切割,撥出兩個分割區域,獨立安裝 Ubuntu。
    每次開機時,也是可以選擇要進入 Windows 或是 Ubuntu。(GRUB 開機選單)

第一種方式,適合「沒有碰過 Linux,想要先嘗試看看合不合用」的人。它完全不會影響到原本的 Windows 作業系統,只是多安裝了一個虛擬器軟體而已。

實際上的作法,請參考重灌狂人的這篇文章:「[下載] VirtualBox v4.0.2(繁體中文版)虛擬電腦,練重灌、測軟體、玩病毒,不怕搞壞電腦!」跟這篇台中市教師線上學習網中的yunol的文章:「Windows下安裝VirtualBox(Ubuntu 10.10)


第二種方式,適合「很常用 Ubuntu,覺得用 Virtualbox 的話,每次都要多一道步驟才能開機很麻煩」的人。它也是完全不會影響到原本的 Windows 系統,只是開機的時候多了一個選單可以選,預設是 Windows,十秒內不做選擇的話,就進入預設系統。

實際上的作法,請參考 Ubuntu 官方網站 http://www.ubuntu.com/desktop/get-ubuntu/windows-installer 或者我之前寫的步驟紀錄:「-步驟-安裝 Ubuntu Lucid 桌機版,使用 Acer M7720 桌上型電腦與 D-Link DWA-140 無線網路卡


第三種方式,適合「e04,Windows 又暈倒要重灌了,害我的 Wubi Ubuntu 也他馬的要跟著重灌」的人。它會把硬碟 C 槽切成三塊,第一塊是原本的 Windows 系統,第二和第三塊是給 Ubuntu 的獨立磁區。有了獨立磁區,不管 Windows 重灌幾次,都不會拖累到 Ubuntu。

實際上的作法,有點複雜,會再另外撰文詳述。今天,則是先把我嘗試過的這三種安裝方式的原理,做成圖解筆記。


最早開始碰 open source的東西,是在 Windows 底下安裝文書軟體 OpenOffice ,那時候僅僅使用文書軟體,就戰戰兢兢的,現在回想起來真是好笑。後來,對開源碼的世界愈來越熟悉,就發現 Ubuntu 這套 Linux 作業系統,有越來越火紅的趨勢,讓我不禁好奇了起來。至於,讓我開始在桌機上裝 Ubuntu 的契機,則是 Windows 本身 ---- 我新買的桌機,擁有 Core i7 處理器 + 9G 記憶體 + 最新穎的 Windows 7 作業系統,如此完美的規格之下,電腦卻三不五時當機,開機超過一個小時左右,就會開始秀斗,然後在關機的時候當在關機畫面... 囧。為了確認到底是硬體問題還是作業系統問題,試著用 Virtualbox  裝 Ubuntu 跑跑看,沒想到,就這樣不知不覺的就用上癮了。

至於 Windows 7 當機的問題,尤其是開機一段時間後當機,據說通常是常駐程式衝突所造成的,而最常衝突的常駐程式,大概就是防毒軟體了。一般會建議用安全模式開機,再把 Windows 服務一項一項打開,看看開到誰的時候會出問題。最後,我還是沒有仔細去找到底是誰跟誰相衝,不過問題還是暫時解決了,解決方式是,我把 Windows 7 當成繪圖專用系統,只裝 Adobe 、輸入法、Wacom 數位板驅動程式、WD MyBook 備份軟體,至於防毒軟體,則是統統不裝,安全性的話,就是上網時不做搜尋,只連到少數幾個 Google 網站這樣。

不過,要做到目前這樣,把 Windows 7 和平時使用的 Ubuntu 完全隔離開來,就不能使用「虛擬雙系統」或是「偽.雙系統」的安裝方式,而必須採用「真.雙系統」的作法,徹底的把兩個作業系統安裝在獨立的磁碟分割區才行。

至於,這三種安裝方式之間,究竟有什麼不同呢?


圖解:我如何在Acer桌機上安裝Ubuntu – Windows雙系統

Illustration: how I install Ubuntu-Windows dual boot system on my Acer desktop



雙系統原理之「主開機紀錄」

The Master Boot Record

在每顆硬碟的最~最最開頭區段,固定會存放著「主開機紀錄 (MBR)」。

MBR 有兩個部份,一是「主分割表 (master partition table)」,二是「主開機程式碼 (master boot code)」。

master partition table 紀錄著這顆硬碟目前被分割成幾個磁碟區。主分割表只有四個格子,所以,一顆硬碟的主要分割區(primary partitions),最多只能有切成四塊。

在 primary partitions 之中,一定有一塊分割區,會標記為 active,電腦會用這個分割區來開機。

master boot code 是一小段給 BIOS 執行的開機程式,它會將實際的開機任務,交給標記為 active 的 primary partition 來執行。
reference (and english version of this description) :
http://www.pcguide.com/ref/hdd/file/structMBR-c.html


雙系統原理之「隱藏磁區」

The Hidden Partition

預裝 Windows 的品牌電腦,通常會將硬碟的前端,切出一小塊分割區,並設定成隱藏,做為系統還原之用。

對 Linux 來說,這是所有的 sata device 裝置中,第 a 個裝置的第 1 個磁碟分割區,所以名字叫做 sda1 。
most brand name computers with pre-installed Windows operation system have a small hidden partition at the beginning of hard disk. it is for system recovery.

in Linux, this partition is the “1”st partition of “a” device among all “sata devices”, so it is called “sda1”.


雙系統原理之「虛擬雙系統」

Virtual Ubuntu Installation


一般的 Windows 品牌電腦,如我的 Acer 桌機,預先將硬碟切割成 C 槽和 D 槽。

C 是標記為 active 的 primary partition,用來放 Windows 作業系統,它的「磁碟啟動區 volume boot sector」裡面,包含了 Windows 的開機程式。至於 D 裡面則是空白的,用來放我的個人資料,D 也有 volume boot sector ,不過,裡面只有 D 槽的尺寸位置等資料,而沒有開機程式。

用「虛擬雙系統」的方式安裝 Ubuntu 的話,是在 C 的 Windows 中,多裝一個虛擬軟體(最常用的是 Virtualbox),虛擬軟體可以在硬碟上撥出一塊區域,當作虛擬硬碟,然後在虛擬硬碟上安裝 Ubuntu。

虛擬硬碟可以放在 C 也可以放在 D,我習慣放在 D 槽。放在 D 有額外的好處,稍後會提到。
brand name computers like my Acer desktop usually have their hard disks split into two partitions, C drive and D drive. C drive is a primary partition that is marked as active. there is Windows loader in its volume boot sector. D drive is empty and you can save your data here.

when doing a virtual Ubuntu installation, you will install a virtual machine software (usually Virtualbox) in Windows on your C drive. Virtualbox will set up a virtual disk for Ubuntu. You can put the virtual disk on C drive or D drive. for me, I would like the virtual disk on D drive. I will explain for it later.


雙系統原理之「偽.雙系統」

Windows-based Ubuntu Installation

使用 Ubuntu 官方提供的 Wubi 程式,會在 C 槽撥出一塊區域,安裝 Ubuntu 。而 C 槽原本 volume boot sector 中的 Windows 開機程式,會被稍微修改,讓它在開機時顯示一個開機選單。選單的預設是 Windows,如果 10 秒內(秒數其實可以修改)沒有選擇,就會進入 Windows。

如果選擇了開機選單的 Ubuntu 選項,開機程式會指向 Wubi 所創造的 Ubuntu 磁區,而啟動 Ubuntu 磁區的 volume boot sector 內的 GRUB 開機程式,此時,我們會看到 GRUB 的開機選單。在 GRUB 選單內,10 秒內不做選擇,就會進入 Ubuntu。
Wubi will create a space in C drive for Ubuntu, and also, it will modify the Window loader in volume boot sector of C drive. Windows loader will display a boot menu with Windows as the default option, and Ubuntu as the second option. if Ubuntu is selected, the boot task will be transferred to GRUB in the volume boot sector of Ubuntu section, and we will see a GRUB boot menu with Ubuntu as the default option.


雙系統原理之「真.雙系統」

Formal Ubuntu Installation

用 DIY 方式,壓縮 C 槽、切出ext4分割區以及swap分割區、並在上面安裝 Ubuntu 後,原本的 C 槽會變成 sda2 , sda5, sda6 三塊。其中,sda2 和 sda5 各自是 Windows 以及 Ubuntu 的作業系統分割區。實際作法在下面連結中。
split the original C drive into sda2 (Windows), sda5 (Ubuntu), and sda6 (Linux swap) according to the following link.

reference: http://members.iinet.net.au/~herman546/p23.html

sda2 和 sda5 都可以單獨重灌,不過,每次重灌,都會重新改寫 MBR 中的 active 標記,將 active primary partition 指向最新安裝作業系統的分割區。

如果最新灌的是 Ubuntu,開機時 MBR 會指向 Ubuntu 的 sda5 分割區,啟動 sda5 的 volume boot sector 中的 GRUB 開機選單,GRUB 會列出所有可開機的磁碟區,包括 sda2 的 Windows loader,於是我們可以自由選擇要進入哪一套作業系統。這就是完美的真.雙系統效果。

如果最新灌的是 Windows,開機時 MBR 會指向 sda2 的 Windows loader。但是,Windows loader 無法辨認 sda5 的 Ubuntu 開機磁區,因此無法顯示開機選單,如此一來,我們就無法進入 Ubuntu。此時,必須利用 Ubuntu Live CD 將 MBR 的內容改回來。修改方式在下面連結中。
the latest installed operating system will override MBR and set the partition of newest system to active. however, the Windows loader cannot recognize Ubuntu boot partition. if you install Windows later, you are not able to access Ubuntu because Windows loader will not show a boot menu with Ubuntu option. in this case, you can fix MBR according to the following link.

reference: https://help.ubuntu.com/community/RecoveringUbuntuAfterInstallingWindows


雙系統原理之 D 槽磁碟分割區存取 - 「虛擬雙系統」

Access D Drive in Virtual Ubuntu

使用虛擬雙系統時,D 槽的資料,無法直接在虛擬機器的 Ubuntu 中存取,必須先到 Virtualbox 中,將整個 D 槽(或某幾個資料夾)設定共享,然後在虛擬 Ubuntu 內,用終端機執行 mount 指令,將共享資料夾掛載進來。

實際的作法請參考重灌狂人的這篇文章:讓Windows與「VirtualBox裡的Ubuntu系統」共用「分享資料夾」http://briian.com/?p=6241

Ubuntu in virtualbox cannot access the data in D drive directly. you have to set up shared folders in virtualbox settings (set the whole D drive or several folders) and then boot Ubuntu, and then use terminal to mount shared folders. reference for mounting shared folder: http://briian.com/?p=6241 (written in traditional chinese)


雙系統原理之 D 槽磁碟分割區存取 - 「偽.雙系統」「真.雙系統」

Access D Drive (or sda4) in Wubi and Formally Installed Ubuntu

使用「偽.雙系統」或「真.雙系統」時,Ubuntu 系統的位階就跟原本的Windows 一樣,可以直接存取D 槽(或 sda4 )的資料,不需任何額外的設定。

有趣的是,如果你曾經使用 Virtualbox 建立虛擬硬碟,而且把虛擬硬碟放在 D 槽的話,即使 C 槽整個重灌,只要在重新裝上 Virtualbox,就可以重新打開之前放在 D 槽上的虛擬 Ubuntu。( Virtualbox 是跨平台軟體,在 Windows 和 Ubuntu 中都可以安裝)

Ubuntu in Wubi or formally installed Ubuntu plays the same role as Windows. data in D drive (or sda4) can be accessed directly, there is no need to setup anything.

If you have created a virtual disk on D drive before, no matter what you do to C drive, you can run the virtual system again as long as you get Virtualbox in the new operating systems. (Virtualbox can be installed in both Windows and Ubuntu)


雙系統原理之 C 槽(sda2)磁碟分割區存取

Access C Drive (or sda2) in Wubi and Formally Installed Ubuntu

使用「偽.雙系統」時,一旦進入 Ubuntu 中,存放 Windows 的 C 槽(或sda2)就無法存取,在 Ubuntu 的檔案系統中也看不見。
不過,如果是「真.雙系統」,即使進入位於 sda5 的 Ubuntu 作業系統中,仍然可以存取 sda2 也就是 C 槽的檔案和資料夾。

Ubuntu in Wubi cannot access C drive anymore, while formally installed Ubuntu can access sda2 (C:) directly.


雙系統原理之硬碟分割狀態比較

Hard Disk Conditions Comparison


以上是本菜鳥多次安裝 Ubuntu 與重灌 Windows 7 的心得,若有錯誤請高手指正 XD

1 則留言:

  1. 其實在真.雙系統模式下,系統切換必須重新開機還挺麻煩的,我個人目標曾經是,看能否找到虛擬程式,把另外一個磁碟分割叫進來,這樣就不用重新開機。有時後極需另一個OS的功能,但又不想重新開機,不想中斷目前工作狀態。當時僅僅查到一個網頁有討論這樣的概念與方法,但似乎有點複雜,就放棄了.....

    回覆刪除