Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> Linux 教學

coLinux 安裝與配置完整指南 (Windows 下運行 Linux)

編輯:Linux 教學

coLinux 讓 Linux 內核以驅動程式形式運行於 Windows 核心態,效能遠優於傳統虛擬機。本文記錄 coLinux 安裝、磁碟映像準備、基礎配置、檔案共享、網路模式 (slirp/tuntap)、SSH 安裝與中文亂碼處理的完整流程。

1. 安裝 coLinux

  • 下載:官網
  • 預設安裝路徑建議放於分區根目錄,如 G:\coLinux
  • 安裝時選擇不下載檔案系統映像

2. 下載預建系統映像

  • 官方映像:SourceForge
  • Ubuntu 12.04 精簡版:SpeedLinux
  • 首次啟動前須在客體執行:
    rm /etc/udev/rules.d/70-persistent-net.rules
    rm -rf /lib/modules/*-co-*

3. 基礎配置 (ubuntu.conf)

複製 example.conf 為 ubuntu.conf,修改關鍵項:


# 磁碟映像位置
cobd0="G:\coLinux\ubuntu\base.vdi"

# Windows 磁碟透過 cofs 共享
cofs0="C:\"
cofs1="D:\"

# slirp 網路 + 端口轉發 (VNC 5901, SSH 22, Web 8080)
eth0=slirp,,tcp:5901:5901/tcp:22:22/tcp:8080:80

4. 啟動與主控台


colinux-daemon @ubuntu.conf
  • 會彈出 NT Console 或 FLTK Console,支援 Alt+F1~F6 切換 tty。
  • Console 視窗可關閉再開啟,只要 colinux-daemon 進程存在即可。
  • 註冊為 Windows 服務:colinux-daemon --install-service ubuntu @ubuntu.conf,後用 sc start ubuntu 啟動。

預設帳號:root / root

5. 掛載 Windows 磁碟 (cofs)


mkdir /mnt/c /mnt/d
mount -t cofs cofs0 /mnt/c
mount -t cofs cofs1 /mnt/d

永久掛載嘗試編輯 /etc/fstab (但可能無效):


cofs0 /mnt/c cofs defaults 0 0
cofs1 /mnt/d cofs defaults 0 0

6. 網路模式:slirp (NAT+端口轉發)

  • 客體自動獲取 DHCP IP:dhclient eth0
  • 外部無法直接訪問客體服務,需在配置檔 eth0=slirp,,tcp:宿主端口:客體端口/... 設定端口轉發。
  • 修改配置後需重啟客體生效。

7. 網路模式:TUNTAP (橋接模式,客體如實體機)

  1. 安裝後會出現虛擬網卡「區域連線 2」,改名為 colinux。
  2. 在實體網卡「區域連線」→ 內容 → 進階 → 勾選「允許其他網路使用者透過此電腦的 Internet 連線連接」,共享給 colinux 虛擬網卡。
  3. 虛擬網卡 IP 固定為 192.168.11.1/24。
  4. 配置檔加入:eth1=tuntap,"colinux"
  5. 客體 /etc/network/interfaces 設定靜態 IP:

auto eth0 eth1
iface eth0 inet dhcp
iface eth1 inet static
    address 192.168.11.150
    netmask 255.255.255.0
    gateway 192.168.11.1

8. 安裝 SSH 服務


apt-get install ssh

Windows 端用 Xshell 或 PuTTY 連線客體 IP (slirp 模式用 127.0.0.1:22,tuntap 用實際 IP)。

9. 解決主控台中文亂碼


export LANG=zh_CN.GB18030
# 或寫入 /etc/profile
export LC_ALL="zh_CN.GB18030"
Copyright © Windows教程網 All Rights Reserved