Gentoo Linux安裝詳解

來源:互聯網
上載者:User

1. 前期準備遠程登入:

  • 開啟ssh服務:
/etc/init.d/sshd start
  • 設定密碼:
passwd

以便使用putty、ssh client遠程登入上傳stage等(有時線上下載很慢,而區域網路上傳很快)

準備磁碟:
  • 分區:
fdisk /dev/sda

/dev/sda1 : /boot 100M(32-100M) 設啟動筆記-a
/dev/sda2 : / 20G
/dev/sda3 : /home 20G
/dev/sda5 : /swap 1G (記憶體< 512 MB,分區分配2倍記憶體大小的空間;> 1024 MB,可以分配較少的空間甚至不需要swap 分區。)-t 82

  • 建立檔案系統:
mkfs.ext4 /dev/sda1mkfs.ext4 /dev/sda2mkfs.ext4 /dev/sda3mkswap /dev/sda5
  • 掛載分區:
mount /dev/sda2 /mnt/gentoomkdir /mnt/gentoo/bootmount /dev/sda1 /mnt/gentoo/bootmkdir /mnt/gentoo/homemount /dev/sda3 /mnt/gentoo/homeswapon /dev/sda5
2. 安裝系統安裝stage及portage:
  • 正確設定日期/時間:
date

如果顯示的日期/時間不正確,可以使用date MMDDhhmmYYYY命令

  • 下載Stage3 Tarbll:
cd /mnt/gentoolinks http://www.gentoo.org/main/en/mirrors.xml

選擇國內速度較快的鏡像,進入releases/x86/autobuilds/目錄裡。你將會看到所有適合你的電腦體繫結構的stage檔案(它們也可能放在各個獨立的子體系名稱的子目錄裡)。選擇一個,然後按D來下載。下載完以後,再按Q退出瀏覽器。

或使用SSH Secure Shell登入上傳stage3檔案

  • 解開Stage3 Tarball:
tar xvjpf stage3-*.tar.bz2
  • 下載Portage:
    links http://www.gentoo.org/main/en/mirrors.xml

    或使用SSH Secure Shell登入上傳portage檔案

    • 解壓Portage:
    tar -xvjf /mnt/gentoo/portage-latest.tar.bz2 -C /mnt/gentoo/usr (install a Portage snapshot)
    編譯前準備:
    • 配置編譯選項:
     nano -w /mnt/gentoo/etc/portage/make.conf

    CFLAGS="-march=native -O2 -pipe"
    CXXFLAGS="${CFLAGS}" # 兩個變數使用相同的設定
    MAKEOPTS="-j3" #MAKEOPTS定義在安裝軟體的時候同時可以產生並行編譯的數目,CPU數目加一是個不錯的選擇

    查看cpu資訊:

    cat proc/cpuinfo
    • 選擇鏡像網站:
    mirrorselect -i -o >> /mnt/gentoo/etc/portage/make.confmirrorselect -i -r -o >> /mnt/gentoo/etc/portage/make.conf 
    • 拷貝DNS資訊:
    cp -L /etc/resolv.conf /mnt/gentoo/etc/
    3. Chroot進入新系統內容:Chroot:
    • 掛載 /proc, /dev, /sys檔案系統:
    mount -t proc none /mnt/gentoo/procmount --rbind /dev /mnt/gentoo/devmount --rbind /sys /mnt/gentoo/sys
    • 進入新的系統內容:
    chroot /mnt/gentoo /bin/bashsource /etc/profileexport PS1="(chroot) $PS1"
    新環境配置:
    • 更新portage樹:
    emerge --sync (Updating the Portage tree)或emerge-webrsync(fetch the latest portage snapshot)
    • 選擇Profile:
    eselect profile listeselect profile set ×
    • 設定時區:
    ls /usr/share/zoneinfoecho "Europe/Brussels" > /etc/timezoneemerge --config sys-libs/timezone-data
    • 設定locale:
     nano -w /etc/locale.genlocale-gen
    • 更新環境變數:
    env-update && source /etc/profile
    4. 編譯核心:
    • 安裝核心源碼:
      emerge gentoo-sourcesls -l /usr/src/linux手動編譯核心:
      cd /usr/src/linuxmake menuconfig
      • 必須啟用的選項:

        其他選項根據需要添加,不瞭解保持預設即可:

      • 編譯核心與模組:
      make && make modules_install
      • 拷貝核心到開機磁碟分割:
      cp arch/x86_64/boot/bzImage /boot/kernel-3.10.10-gentoo
      使用genkernel編譯核心:
      emerge genkernel
      • 可選:複製安裝光碟片上的核心設定檔:
      zcat /proc/config.gz > /usr/share/genkernel/arch/x86_64/kernel-config
      • 編譯:
      genkernel --menuconfig all 

      一旦genkernel運行完成,一個包括全部模組和initrd的核心將被建立。在後面配置引導程式時我們將會用到這個核心和initrd。請記下核心和initrd的名字,因為您將在配置引導程式的時候用到他們。initrd將會在啟動真正的系統前自動識別硬體(如同安裝光碟片一樣)。

      ls /boot/kernel* /boot/initramfs*
      5. 配置系統系統資訊:
      • 檔案系統資訊:
        nano -w /etc/fstab
        • 網路資訊:

        Host name, Domainname, etc

        nano -w /etc/conf.d/hostname

        Configuring Network

        nano -w /etc/conf.d/net
        • 系統資訊:

        Gentoo uses /etc/rc.conf to configure the services, startup, and shutdown of your system.

        nano -w /etc/rc.conf

        Root Password

         passwd

        Gentoo uses /etc/conf.d/hwclock to set clock options.

        nano -w /etc/conf.d/hwclock
        安裝系統工具軟體:
        • 可選:PCMCIA使用lspci查看硬體資訊:
        emerge pcmciautils
        • System Logger:
        emerge syslog-ngrc-update add syslog-ng default
        • 可選:File Indexing:
        emerge mlocate
        • 可選:Remote Access:
        rc-update add sshd default
        • 可選:DHCP Client:
        emerge dhcpcd
        配置啟動項:
        • Using GRUB2:
        emerge sys-boot/grubgrub2-install /dev/sda

        Generating GRUB2 configuration:

        grub2-mkconfig -o /boot/grub/grub.cfg
        • 可選:Using GRUB Legacy:
        emerge sys-boot/grub:0

        編輯設定檔:

        nano -w /boot/grub/grub.conf

        Example grub.conf:

        # 預設選擇哪個列表來引導。0表示第一個, 1表示第二個,以此類推。default 0# 引導預設列表前等待多少秒timeout 30# 使用漂亮、“臃腫”的spalsh映像來增加一點趣味:)# 如果您沒有安裝顯卡,請將這行注釋掉splashimage=(hd0,0)/boot/grub/splash.xpm.gztitle Gentoo Linux 3.10.10# 核心鏡像(或者作業系統)所在分區root (hd0,0)kernel /boot/kernel-3.10.10-gentoo root=/dev/sda2title Gentoo Linux 3.10.10 (rescue)# 核心鏡像(或者作業系統)所在分區root (hd0,0)kernel /boot/kernel-3.10.10-gentoo root=/dev/sda2 init=/bin/bb# 接下來的四行只有在您與Windows系統進行雙啟動的情況下才需要。# 本例中,windows系統位於/dev/sda6。title Windows XProotnoverify (hd0,5)makeactivechainloader +1#win7下注釋掉makeactive

        Setting up GRUB using grub-install:
        Creating /etc/mtab:

        grep -v rootfs /proc/mounts > /etc/mtab

        Install GRUB:

        grub-install --no-floppy /dev/sda
        重啟系統:
        exitcdumount -l /mnt/gentoo/dev{/shm,/pts,}umount -l /mnt/gentoo{/boot,/proc,}reboot
        6. 安裝X案頭環境:安裝Xorg:
        • 檢測顯卡資訊:
        dmesg | grep videolspci  | grep -i VGA
        • 配置INPUT_DEVICE、VIDEO_CARDS變數:
          (For mouse, keyboard, and Synaptics touchpad support)INPUT_DEVICE="evdev synaptics" (對nVidia顯卡)VIDEO_CARDS="nvidia"(或,對ATI Radeon顯卡)VIDEO_CARDS="radeon"(VMware虛擬機器)VIDEO_CARDS="vmware"(VirtualBox虛擬機器)VIDEO_CARDS="virtualbox"
          • 安裝xorg-server“
          emerge -pv xorg-drivers

          First of all, make sure udev is in your USE flags:

          echo "x11-base/xorg-server udev" >> /etc/portage/package.use

          註:現在比較新的版本的Xorg(大概是 1.5 以後的吧) 使用 evdev 替換了 keyboard 和 mouse ,確保 udev 標記在安裝 xorg-server 時被啟用。

          Next, install Xorg:

          emerge -av xorg-server
          • 更新環境變數:
          env-update source /etc/profile
          • 使用startx:
            emerge -v twm xtermstartx安裝案頭環境:
            • lxde:

            • awesome:

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.