Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Gentoo 硬盤安裝法
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index 中文 (Chinese)
View previous topic :: View next topic  
Author Message
Hauser
l33t
l33t


Joined: 27 Dec 2003
Posts: 650
Location: 4-dimensional hyperplane

PostPosted: Mon Dec 13, 2004 7:31 pm    Post subject: Gentoo 硬盤安裝法 Reply with quote

註:2005.1和2006.0的LiveCD現已經可以引導,無需再使用1.2的minimal LiveCD或Knoppix了。詳情請見英文版。
為慶祝中文版面的開辦,我寫了個簡便的安裝法,給那些〝心急〞的新手做個參考。我的靈感來自:https://forums.gentoo.org/viewtopic.php?t=265226http://www.linuxsir.org/bbs/showthread.php?s=&threadid=133814,所以在這裡先向kohno和Fleta表示感謝。 另外有個英文版在此處

假設:您只有windows,沒有軟碟,光碟機,沒裝vmware,但卻裝了Grub for DOS
首先找個mirror下載一個1.2的minimal映像檔,如:http://ftp.isu.edu.tw/pub/Linux/Gentoo/releases/historical/x86/1.2/livecd/gentoo-ix86-1.2.iso
約16MB左右吧;然後下個2004.3 LiveCD 的映像檔:http://ftp.isu.edu.tw/pub/Linux/Gentoo/releases/x86/2004.3/livecd/install-x86-universal-2004.3-r1.iso
找一個vfat的分區,將1.2的minimal映像檔裡的isolinux拷貝過去,然後建一個gentoo的目錄,把2004.3 LiveCD 裡distfiles,snapshots,stages這幾個目錄拷貝過去。

設置grub:
Code:
title From HD
root (hd0,6) (按自己的情況改分區號)
kernel /isolinux/kernel devfs=nomount vga=normal load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=22000 root=/dev/ram0 rw
initrd /isolinux/rescue.gz

將以下幾個scripts也拷至那個gentoo的目錄裡:
step1:
Code:
#mke2fs -j /dev/hda10   #(initialize the boot partition)
#mkswap /dev/hda8   #(initialize the swap partition)
swapon /dev/hda8   #(Activate the swap partition)
#mke2fs -j /dev/hda12   #(if you want to use ext3 for your root partition)
mkreiserfs -f /dev/hda12    #(if you want to use reiserfs)
#mkfs.xfs -f /dev/hda12   #(if you want to use xfs)
mount /dev/hda12 /mnt/linux   #(Mount the root partition)
mkdir /mnt/linux/boot   #(Create the boot mountpoint)
mount /dev/hda10 /mnt/linux/boot   #(Mount the boot partition)
echo "Now set your system time!  For instance, to set the date to October 29th, 16:21 in the year 2004, type: date 102916212004"

step2:
Code:
cd /mnt/linux   #(Go to the mountpoint where the root partition has been mounted)
tar xjvpf /mnt/win/gentoo/stages/stage3-x86-2004.3.tar.bz2   #(Extract a stage3 tarball...)
tar -xvjf /mnt/win/gentoo/snapshots/portage-20041022.tar.bz2 -C /mnt/linux/usr   #(unpack a portage tree)
mkdir /mnt/linux/usr/portage/distfiles   #(Create a directory for distfiles)
cp /mnt/win/gentoo/distfiles/* /mnt/linux/usr/portage/distfiles/   #(copy over distfiles)
cp -L /etc/resolv.conf /mnt/linux/etc/resolv.conf   #(Copy over nameserver information)
mount -t proc none /mnt/linux/proc   #(Mount the proc filesystem)
cp /mnt/win/gentoo/step3 /mnt/linux    #(Copy over the step3 script)
echo "
Now you can run step3!"
chroot /mnt/linux /bin/bash   #(Chroot into the new environment)

step3:
Code:
env-update && source /etc/profile   #(Load the necessary variables)
ln -sf /usr/share/zoneinfo/Hongkong /etc/localtime   #(Set timezone information)
#nano -w /etc/make.conf   #(Optional: edit make.conf)
nano -w /etc/fstab    #(edit fstab)
echo tux > /etc/hostname   #(Set the system hostname)
echo home.net > /etc/dnsdomainname   #(Set the system domainname)
echo nis.home.net > /etc/nisdomainname   #(Set the system nisdomainname)
echo "192.168.1.1     tux.home.net       tux" >> /etc/hosts   #(Set the hostsfile)
echo "Have fun with Gentoo!
" >> /etc/issue   #(Set the greeting message)
rc-update add domainname default   #(Domain name init script)
rc-update add numlock default   #(Switch on numlock)
nano -w /etc/conf.d/net    #(Setup networking; dhcp-users should set iface_eth0="dhcp")
rc-update add net.eth0 default   #(Start networking automatically at boot)
nano -w /etc/rc.conf    #(Further system configurations)
echo "
Now you need to set your root password!"
passwd
echo "tts/0" >> /etc/securetty   #(Let root to be able to log on through the serial console)
emerge metalog   #(install a system logger)
rc-update add metalog default   #(add it to the default runlevel)
#emerge xfsprogs    #(if you've chosen to use xfs)
emerge reiserfsprogs    #(if you've chosen to use reiserfs)
emerge dhcpcd   #(if you need to use dhcp)
emerge genkernel   #(prepare to compile a kernel)
emerge gentoo-dev-sources   #(install a kernel source)
genkernel --menuconfig all   #(save your config when exit)
emerge hotplug   #(install hotplug)

rc-update add hotplug default   #(Add it to the default runlevel)
cd /boot   #(Optional: it's just a precautionary step)
ln -s . boot
#emerge grub   #(If you want to keep your Grub-for-Dos,skip the following)
#echo "default 0
#timeout 15
#color cyan/blue white/blue

#title=Gentoo Linux 2.6.9-r1
#root (hd0,0)
#kernel (hd0,9)/boot/kernel-2.6.9-gentoo-r1 root=/dev/hda12 video=vesafb:ywrap,mtrr,1024x768-16@85
#initrd (hd0,9)/boot/initrd-2.6.9-gentoo-r1" >> /boot/grub/grub.conf
#nano -w /boot/grub/grub.conf #just to check
#grub
echo "OK, your system is ready, now you may exit and reboot!"

注意要根據自己的具體情況改一改這幾個scripts,真是用的話先要做好資料備份。雖然在我的機器上試過沒問題,但不保證在閣下的機子上不出事呦! :wink:

首先你得準備好linux分區,你可以在windows裡用Partition Magic或進了安裝介面用fdisk。fdisk的用法手冊裡說得很清楚,我就不寫了。

從Grub裡用"From HD"那項開機,按了幾次Enter後你會看到個提示符。掛載好那個vfat分區,然後執行step1:
Code:
# mount -t vfat /dev/hda7 /mnt/win
# /mnt/win/gentoo/step1

設置好系統時間後,執行step2:
Code:
# /mnt/win/gentoo/step2

當你看到'Now you can run step3!'的語句,你已經進入chroot的環境了,然後執行step3:
Code:
# ls           (你會看到確實進入了chroot的環境了)
#./step3

首先會提示你修改fstab,然後是/etc/conf.d/net, /etc/rc.conf等。設定好root密碼後大約十幾二十分你會看到menuconfig的畫面,配置好kernel後差不多就可以了。如果你想繼續用Grub-for-DOS,Gentoo的grub可以不裝,但是Grub-for-DOS別忘了為Gentoo加個選項呦。 :)

整個安裝過程應不會超過一個小時,由於基本上是自動的,也免去了敲打指令之苦。不過輕鬆之餘還希望新手仔細看看手冊,搞清楚每個步驟的含意,以進一步瞭解Gentoo。
_________________
AMD Athlon XP 2600+; 512M RAM;
nVidia FX5700LE; Hitachi 120Gb
2.6.9-nitro4, reiser4, linux26-headers+nptl

Do I like to compile everything?
Positive definite!


Last edited by Hauser on Tue Feb 28, 2006 7:54 pm; edited 2 times in total
Back to top
View user's profile Send private message
EricHsu
Bodhisattva
Bodhisattva


Joined: 03 May 2004
Posts: 591
Location: Aragon Consulting Group, Beijing, China

PostPosted: Tue Dec 14, 2004 1:13 am    Post subject: Reply with quote

"心急" 的新手们有福了 ;)
受用了的大伙儿记得回来给 Hauser 一个吻 :twisted:
_________________
- http://nkbit.com
- http://twitter.com/xuyihua
Back to top
View user's profile Send private message
kohno
Tux's lil' helper
Tux's lil' helper


Joined: 28 Aug 2004
Posts: 112

PostPosted: Tue Dec 14, 2004 4:38 am    Post subject: Reply with quote

哎呀,你快我一步了,我也正在实验类似的安装法呢,气死我了! :oops:
Back to top
View user's profile Send private message
dengwangxi
n00b
n00b


Joined: 31 Mar 2004
Posts: 10

PostPosted: Tue Dec 14, 2004 4:53 pm    Post subject: Reply with quote

应该不支持stage1吧?
我用gentoo早期的livecd装gentoo 2004.3的时候就出现过
内核版本过低有些东西不能编译的事。
Back to top
View user's profile Send private message
Hauser
l33t
l33t


Joined: 27 Dec 2003
Posts: 650
Location: 4-dimensional hyperplane

PostPosted: Tue Dec 14, 2004 7:09 pm    Post subject: Reply with quote

如果你願意從stage1開始,就不能算“心急”的新手了。 :)
基本上整個安裝程序只須編譯xfsprogs,reiserfsprogs,dhcpcd genkernel,gentoo-dev-sources,及hotplug這幾個包,用的是liveCD裡的源碼包(即無需網路),我自己試的時候非常順利,沒出過任何問題。
不過如果你想從stage1開始定製系統,同時又確實沒有光軟碟的話,可以考慮先用這個方法裝好基本系統,然後等重啟進入新系統後再重建toolchain和system。
_________________
AMD Athlon XP 2600+; 512M RAM;
nVidia FX5700LE; Hitachi 120Gb
2.6.9-nitro4, reiser4, linux26-headers+nptl

Do I like to compile everything?
Positive definite!
Back to top
View user's profile Send private message
kohno
Tux's lil' helper
Tux's lil' helper


Joined: 28 Aug 2004
Posts: 112

PostPosted: Wed Dec 15, 2004 9:47 am    Post subject: Reply with quote

Hauser wrote:
不過如果你想從stage1開始定製系統,同時又確實沒有光軟碟的話,可以考慮先用這個方法裝好基本系統,然後等重啟進入新系統後再重建toolchain和system。

你是说进入新系统后再bootstrap,然后emerge -e system?
Back to top
View user's profile Send private message
Hauser
l33t
l33t


Joined: 27 Dec 2003
Posts: 650
Location: 4-dimensional hyperplane

PostPosted: Wed Dec 15, 2004 5:51 pm    Post subject: Reply with quote

沒錯!這樣裝出來的系統和直接從stage1安裝是差不多的(甚至更加徹底,請看此貼),不過由於之前已經裝了幾個包(stage3+reiserfsprogs+dhcpcd+hotplug等),你得emerge -e world才能編完所有的包。

具體地說,你得首先修改make.conf,尤其是CFLAGS和USE。比如你可能想用NPTL而不是linuxthreads,你可以在USE裡加入"nptl nptlonly"。Bootstrap之前還得替換linuxheaders(如果是直接從2004.3的stage1包做,應該可以省略這一步了):
Code:
# emerge -C linux-headers
# emerge --oneshot --nodeps linux26-headers

另外還有個步驟是值得一做的,即精簡glibc的locales;glibc支持的300多個locales我們可能會用到或嘗試的頂多也就10幾個,清除掉那些不用的locales起碼可以省下幾十MB的空間呢。首先安裝localepurge工具:
Code:
# emerge localepurge

在清除多餘的locales之前你得將/etc/locale.nopurge裡"NEEDSCONFIGFIRST"那行註釋掉,最後那段的那些locales也註釋掉或刪掉,然後執行:
Code:
# localepurge

接著為重新編譯glibc(Bootstrap程序中會做的)做準備。啟動"userlocales"的USE:
Code:
# echo 'sys-libs/glibc userlocales' >> /etc/portage/package.use

編輯/etc/locales.build並加入想要用的locales,像這樣:
Code:
en_US.UTF-8/UTF-8
en_US/ISO-8859-1
zh_CN.GB18030/GB18030
zh_CN.GBK/GBK
zh_CN.UTF-8/UTF-8
zh_CN/GB2312
zh_HK.UTF-8/UTF-8
zh_HK/BIG5-HKSCS
zh_TW.EUC-TW/EUC-TW
zh_TW.UTF-8/UTF-8
zh_TW/BIG5

然後就可以Bootstrap了:
Code:
# /usr/portage/scripts/bootstrap.sh

完了之後你可以檢查一下之前做過的工夫是否有效:
Code:
# /lib/libc.so.6                       (應顯示有“Native POSIX Threads Library”的字樣)
# cd /usr/share/locale ; du -h         (Bootstrap之前做一次,現在再做一次以比較大小)
# locale -a                            (檢查一下是否編譯出了你設置的那些locales)

如果你發現那些locales不對,那是因為bootstrap的時候glibc編譯了2次,第一次按你的設定編,但完了之後你的/etc/locales.build可能給覆蓋了,取而待之的是英法德的一些locales (從stage1開始安裝很有可能發生這種事,這是個Bug);不過不要緊,只要再次編輯/etc/locales.build,重編系統即可。Bootstrap的程序令到你的toolchain得以優化,現在是時候用它來重編整個系統了:
Code:
# emerge -e world

這個相當於從stage2到stage3的過程。
_________________
AMD Athlon XP 2600+; 512M RAM;
nVidia FX5700LE; Hitachi 120Gb
2.6.9-nitro4, reiser4, linux26-headers+nptl

Do I like to compile everything?
Positive definite!


Last edited by Hauser on Wed Dec 22, 2004 11:48 am; edited 5 times in total
Back to top
View user's profile Send private message
Fleta
n00b
n00b


Joined: 12 Dec 2004
Posts: 68

PostPosted: Thu Dec 16, 2004 12:03 pm    Post subject: Reply with quote

Hauser wrote:
沒錯!這樣裝出來的系統和直接從stage1安裝是差不多的(甚至更加徹底,請看此貼),不過由於之前已經裝了幾個包(stage3+reiserfsprogs+dhcpcd+hotplug等),你得emerge -e world才能編完所有的包。

呵呵,stage3+bootstrap+rebuild tree,这可能会成为以后玩家的preferred的安装方法啊。
Back to top
View user's profile Send private message
lit40
n00b
n00b


Joined: 29 Nov 2004
Posts: 8
Location: china

PostPosted: Fri Dec 17, 2004 11:55 am    Post subject: Reply with quote

我用 livecd 2004.3 的isolinux的gentoo 和gentoo.igz试验就不行,不知道为什么.
我的做法是:把gentoo和gentoo.igz拷到/boot,grub修改如下:
Code:
title gentoo Setup
root (hd0,0)
kernel /gentoo devfs=nomount vga=normal load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=22000 root=/dev/ram0 rw
initrd /gentoo.igz

出错为
Code:

Kernel panic - not syncing:VFS: Unable to mount root fs on unknown-block(3.2)

ps:我的分区是reiserfsr的,/boot在sda1上
Back to top
View user's profile Send private message
Hauser
l33t
l33t


Joined: 27 Dec 2003
Posts: 650
Location: 4-dimensional hyperplane

PostPosted: Fri Dec 17, 2004 7:48 pm    Post subject: Reply with quote

1.4以後的LiveCD都不可以這樣用,要不然我不會建議大家去下1.2的LiveCD。從kohno那貼你可以看到他還因此而發牢騷呢! :wink:
當然有些其他的LiveCD是可以從硬碟啟動的,比如Knoppix便可以 https://forums.gentoo.org/viewtopic.php?p=1889771#1889771,不過Gentoo自己的LiveCD搞到不能這樣啟動實在是有點遺憾啊! :?
_________________
AMD Athlon XP 2600+; 512M RAM;
nVidia FX5700LE; Hitachi 120Gb
2.6.9-nitro4, reiser4, linux26-headers+nptl

Do I like to compile everything?
Positive definite!
Back to top
View user's profile Send private message
kohno
Tux's lil' helper
Tux's lil' helper


Joined: 28 Aug 2004
Posts: 112

PostPosted: Sat Dec 18, 2004 8:51 am    Post subject: Reply with quote

补充一下,对于那些想装GRP包的人,可以下载packages-x86-2004.3-r1.iso,然后挂到/usr/portage/package下(没有package目录的自己建一个):
Code:
# mount -o loop /path/to/packages-x86-2004.3-r1.iso /usr/portage/package

然后
Code:
# emerge -k packagename

就可以了。不过得用LiveCD里的snapshot,所以先别emerge sync呀!
Back to top
View user's profile Send private message
Hauser
l33t
l33t


Joined: 27 Dec 2003
Posts: 650
Location: 4-dimensional hyperplane

PostPosted: Sun Dec 19, 2004 5:50 pm    Post subject: Reply with quote

To whom it may concern: here's a description of how I installed a new Gentoo within an existing Gentoo, an experiment that was no hassle! :)
_________________
AMD Athlon XP 2600+; 512M RAM;
nVidia FX5700LE; Hitachi 120Gb
2.6.9-nitro4, reiser4, linux26-headers+nptl

Do I like to compile everything?
Positive definite!
Back to top
View user's profile Send private message
kohno
Tux's lil' helper
Tux's lil' helper


Joined: 28 Aug 2004
Posts: 112

PostPosted: Tue Dec 21, 2004 4:21 pm    Post subject: Reply with quote

请问如果我把gcc换成3.4.x要重编整个系统吗?
是不是emerge -e world就可以啦?
Back to top
View user's profile Send private message
Hauser
l33t
l33t


Joined: 27 Dec 2003
Posts: 650
Location: 4-dimensional hyperplane

PostPosted: Wed Dec 22, 2004 6:12 am    Post subject: Reply with quote

To get the benefits that gcc-3.4.x provides (I guess that's what you really want :wink: ), you do need to rebuild world, but 'emerge -e world' may not be enough because you need to rebuild your toolchain first, so it's better to 'emerge -e system && emerge -e world'. Here's a guide: HOWTO Migrating to GCC 3.4
_________________
AMD Athlon XP 2600+; 512M RAM;
nVidia FX5700LE; Hitachi 120Gb
2.6.9-nitro4, reiser4, linux26-headers+nptl

Do I like to compile everything?
Positive definite!
Back to top
View user's profile Send private message
Fleta
n00b
n00b


Joined: 12 Dec 2004
Posts: 68

PostPosted: Thu Dec 23, 2004 6:57 am    Post subject: Reply with quote

Hauser wrote:
To get the benefits that gcc-3.4.x provides (I guess that's what you really want :wink: ), you do need to rebuild world, but 'emerge -e world' may not be enough because you need to rebuild your toolchain first, so it's better to 'emerge -e system && emerge -e world'. Here's a guide: HOWTO Migrating to GCC 3.4

呵呵,那个guide推荐的方法是:
Code:
# emerge -e system && emerge -e system && emerge -e world && emerge -e world

kohno兄要三思啊! :lol:
Back to top
View user's profile Send private message
punkid
Apprentice
Apprentice


Joined: 18 Dec 2004
Posts: 215
Location: offline

PostPosted: Sat Jan 15, 2005 9:23 am    Post subject: Reply with quote

为什么我按照这个方法安装gentoo后,进入字符界面
#ls /boot
#ls /root
# ls ......
里面什么东西都没有啊?望高手指教。

P.S:我是菜鸟。
_________________
My Blog | Latest Screenshot
Back to top
View user's profile Send private message
Hauser
l33t
l33t


Joined: 27 Dec 2003
Posts: 650
Location: 4-dimensional hyperplane

PostPosted: Sat Jan 15, 2005 9:53 am    Post subject: Reply with quote

By default, the /boot partition is not mounted on boot in Gentoo for security reasons; if you would like it automatically mounted on boot, you may switch on the "auto" option for the /boot partition in /etc/fstab, like this:
Code:
/dev/hda9               /boot           ext2            auto,noatime          1 2

If you do
Code:
# cd
# ls -a

you should see some config files in /root. If there isn't any ordinary files in /root, it just means the root user hasn't put anything in it yet.

BTW have you created a normal user? In case you didn't, issue the following command to add a user:
Code:
# useradd -m -G users,wheel,audio,games,portage -s /bin/bash punkid
# passwd punkid

After you login as user punkid, if you do
Code:
$ cd && ls

you'll see your home directory is also empty, but there's nothing wrong with that, since you haven't put anything in it yet, so it'll be a good idea to creat some directories for future usage:
Code:
$ mkdir documents tmp music

_________________
AMD Athlon XP 2600+; 512M RAM;
nVidia FX5700LE; Hitachi 120Gb
2.6.9-nitro4, reiser4, linux26-headers+nptl

Do I like to compile everything?
Positive definite!
Back to top
View user's profile Send private message
kohno
Tux's lil' helper
Tux's lil' helper


Joined: 28 Aug 2004
Posts: 112

PostPosted: Fri Jan 21, 2005 5:09 pm    Post subject: Reply with quote

Fleta wrote:
Hauser wrote:
沒錯!這樣裝出來的系統和直接從stage1安裝是差不多的(甚至更加徹底,請看此貼),不過由於之前已經裝了幾個包(stage3+reiserfsprogs+dhcpcd+hotplug等),你得emerge -e world才能編完所有的包。

呵呵,stage3+bootstrap+rebuild tree,这可能会成为以后玩家的preferred的安装方法啊。

没想到真给你说中了,这种安装方法似乎开始流行起来了! :)
Installing Gentoo: Stage 1 NPTL on a Stage 3 Tarball
Back to top
View user's profile Send private message
punkid
Apprentice
Apprentice


Joined: 18 Dec 2004
Posts: 215
Location: offline

PostPosted: Sun Jan 23, 2005 8:20 am    Post subject: I got another problem Reply with quote

sorry i got another problem.
我把 USE="-X" emerge rp-pppoe 加入了step3,但是事实上我无法使用adsl-setup进行adsl的配置。what's wrong with that?
_________________
My Blog | Latest Screenshot
Back to top
View user's profile Send private message
cee1
n00b
n00b


Joined: 11 Dec 2004
Posts: 33
Location: china

PostPosted: Tue Jan 25, 2005 12:28 am    Post subject: U盘启动安装? Reply with quote

现在的U盘的主流容量可以放下一个mini光盘了吧,不知道可不可以考入U盘代光盘启动
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index 中文 (Chinese) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum