Share Pastebin
Guest
Public paste!

Gentoo Install

By: a guest | Mar 19th, 2010 | Syntax: Bash | Size: 7.75 KB | Hits: 68 | Expires: Never
Copy text to clipboard
  1. ### 0. Boot the LiveCD
  2.  
  3. # No FB doesn't load any graphics
  4. gentoo-nofb # [enter]
  5.  
  6. ## ------------------------------------------------------------------ ##
  7.  
  8. ### 1. Start the Network and SSH
  9.  
  10. # - check the eth you're going to set up (usually eth0)
  11. ifconfig -a
  12. net-setup eth0
  13.  
  14. # - using Google Public DNS (you can use others)
  15. echo "nameserver 8.8.8.8" > /etc/resolv.conf
  16. echo "nameserver 8.8.4.4" >> /etc/resolv.conf
  17.  
  18. # - start SSH Server
  19. /etc/init.d/sshd start
  20. passwd root
  21.  
  22. ## ------------------------------------------------------------------ ##
  23.  
  24. ### 2. Login via SSH (just to make it more confortable)
  25.  
  26. ## ------------------------------------------------------------------ ##
  27.  
  28. ### 3. Hard Disk Partitioning
  29.  
  30.  
  31. ## 3A. Normal Partitioning
  32. # This may vary depending on the setup wanted or the number of disks
  33. # In this example it's a 500G HD
  34.  
  35. fdisk /dev/sda
  36. # n -> p -> 1 -> [enter] -> +100M     # /boot
  37. # n -> p -> 2 -> [enter] -> +8G       # swap
  38. # n -> p -> 2 -> [enter] -> +4G       # /tmp
  39. # n -> p -> 3 -> [enter] -> [enter]   # /
  40. # w
  41.  
  42.  
  43. ## 3B. Preparing the disk for Software RAID (just if needed)
  44.  
  45. fdisk /dev/sda
  46. # t -> 1 -> fd
  47. # t -> 2 -> fd
  48. # t -> 3 -> fd
  49. # t -> 4 -> fd
  50.  
  51.  
  52. ## 3C. Software RAID 1 set-up (optional)
  53.  
  54. # Set partitioning on sdb as on sda
  55. emerge -Nu sfdisk
  56. sfdisk -d /dev/sda | sfdisk /dev/sdb
  57.  
  58. modprobe raid1
  59. mdadm --create --verbose /dev/md1 --level=1 --raid-devices=2 /dev/sda1 /dev/sdb1
  60. mdadm --create --verbose /dev/md2 --level=1 --raid-devices=2 /dev/sda2 /dev/sdb2
  61. mdadm --create --verbose /dev/md3 --level=1 --raid-devices=2 /dev/sda3 /dev/sdb3
  62. mdadm --create --verbose /dev/md4 --level=1 --raid-devices=2 /dev/sda4 /dev/sdb4
  63.  
  64. # Wait until it finishes...
  65. watch -n 1 "cat /proc/mdstat"
  66.  
  67.  
  68. ## 3D. Software RAID 5 set-up (optional)
  69.  
  70. # Set partitioning on sdb and sdc as on sda
  71. emerge -Nu sfdisk
  72. sfdisk -d /dev/sda | sfdisk /dev/sdb
  73. sfdisk -d /dev/sda | sfdisk /dev/sdc
  74.  
  75. modprobe raid1
  76. modprobe raid5
  77. mdadm --create --verbose /dev/md1 --level=1 --raid-devices=3 /dev/sda1 /dev/sdb1 /dev/sdc1
  78. mdadm --create --verbose /dev/md2 --level=5 --raid-devices=3 /dev/sda2 /dev/sdb2 /dev/sdc2
  79. mdadm --create --verbose /dev/md3 --level=5 --raid-devices=3 /dev/sda3 /dev/sdb3 /dev/sdc3
  80. mdadm --create --verbose /dev/md4 --level=5 --raid-devices=3 /dev/sda4 /dev/sdb4 /dev/sdc4
  81.  
  82. # Wait until it finishes...
  83. watch -n 1 "cat /proc/mdstat"
  84.  
  85. ## ------------------------------------------------------------------ ##
  86.  
  87. ### 4. Hard Disk formatting
  88.  
  89. # In case of RAID, you might need to use MD instead of SD
  90. mkfs.reiserfs /dev/sda1 # [y]
  91. mkfs.reiserfs /dev/sda3 # [y]
  92. mkfs.reiserfs /dev/sda4 # [y]
  93. mkswap /dev/sda2
  94.  
  95. ## ------------------------------------------------------------------ ##
  96.  
  97. ### 5. Mounting the Disks
  98.  
  99. # In case of RAID, you might need to use MD instead of SD
  100. mkdir -p /mnt/gentoo
  101. mount /dev/sda4 /mnt/gentoo
  102. mkdir -p /mnt/gentoo/boot
  103. mount /dev/sda1 /mnt/gentoo/boot
  104. mkdir -p /mnt/gentoo/tmp
  105. mount /dev/sda3 /mnt/gentoo/tmp
  106. swapon /dev/sda2
  107.  
  108. ## ------------------------------------------------------------------ ##
  109.  
  110. ### 6. Downloading the latest stage and portage:
  111.  
  112. # CRITICAL: First check that the date is correctly set (with the date command)
  113. date --utc # check if the time is ok (otherwise, update it with date MMDDhhmmYYYY), remember it's UTC / GMT
  114.  
  115. # The URL may vary depending on the server type (i686, amd64, etc) and the date
  116. wget http://gentoo.mirrors.tds.net/gentoo/releases/x86/current-stage3/stage3-i686-20100216.tar.bz2
  117. tar xvjpf stage3-*.tar.bz2 -C /mnt/gentoo
  118. rm -f stage3-*.tar.bz2
  119.  
  120. wget http://gentoo.mirrors.tds.net/gentoo/snapshots/portage-latest.tar.bz2
  121. tar xvjpf portage-*.tar.bz2 -C /mnt/gentoo/usr
  122. rm -f portage-*.tar.bz2
  123.  
  124. ## ------------------------------------------------------------------ ##
  125.  
  126. ### 7. Make setup
  127.  
  128. # The make setup is really important, it may give you extra performance to have it tunned up or less if you have it by default
  129. # Proper setup configurations can be found here: http://en.gentoo-wiki.com/wiki/Safe_Cflags
  130. # You can change the current Make setup here:
  131.  
  132. nano /mnt/gentoo/etc/make.conf
  133.  
  134. ## ------------------------------------------------------------------ ##
  135.  
  136. ### 8. Chroot enviroment
  137.  
  138. cd /
  139. cp -L /etc/resolv.conf /mnt/gentoo/etc/
  140. mount -t proc none /mnt/gentoo/proc
  141. mount -o bind /dev /mnt/gentoo/dev
  142. chroot /mnt/gentoo /bin/bash
  143. env-update
  144. source /etc/profile
  145. export PS1="(chroot) $PS1"
  146.  
  147. ## ------------------------------------------------------------------ ##
  148.  
  149. ### 9. System Upgrade
  150.  
  151. # Update the repositories data
  152. emerge --sync # you can add --quiet to avoid all output
  153.  
  154. # Select the Profile wanted
  155. eselect profile list
  156. eselect profile set 1 # you can choose another one if you want to
  157.  
  158. # Update portage (if needed)
  159. emerge -Nu --oneshot portage
  160.  
  161. # Update Python (if needed)
  162. emerge -Nu cracklib libxml2 # dependences needed
  163. /usr/sbin/python-updater # repeat until it tells that no more packages are needed
  164.  
  165. # Update / upgrade everything
  166. emerge -DNuv world system # check the final output, it might tell you to do some stuff
  167.  
  168. # Update Python (if needed, again)
  169. /usr/sbin/python-updater # repeat until it tells that no more packages are needed
  170.  
  171. ## ------------------------------------------------------------------ ##
  172.  
  173. ### 10. New packages setup
  174.  
  175. etc-update # type -5
  176.  
  177. hash -r
  178. source /etc/profile
  179. export PS1="(chroot) $PS1"
  180. grpck # type [y]
  181.  
  182. grpconv
  183. rc-update add sshd default
  184.  
  185. nano /etc/locale.gen # uncomment the en_US locales
  186. locale-gen
  187.  
  188. ln -sf /usr/share/zoneinfo/Etc/GMT+3 /etc/localtime # change the timezone as needed
  189. date # check if the time is ok (otherwise, update it with date MMDDhhmmYYYY)
  190.  
  191. ## ------------------------------------------------------------------ ##
  192.  
  193. ### 11. Kernel Setup
  194.  
  195. # Get the latest kernel (remember the version you're installing)
  196. USE="symlink" emerge gentoo-sources
  197. cd /usr/src/linux
  198.  
  199. # Load the actual settings
  200. zcat /proc/config.gz > .config
  201. make menuconfig # you can improve it by removing stuff you don't want/need or just type [esc][esc][y][enter]
  202.  
  203. # Make...
  204. make && make modules_install
  205.  
  206. # CRITICAL: check the version and arch installed because it may be different!
  207. cp -L arch/x86/boot/bzImage /boot/kernel-2.6.31-gentoo-r10
  208.  
  209. ## ------------------------------------------------------------------ ##
  210.  
  211. ### 12. GRUB setup
  212.  
  213. emerge grub # en no-multilib utilizar "grub-static"
  214. nano -w /boot/grub/grub.conf
  215.  
  216. # Edit the grub settings depending on the kernel version.
  217. # grub.conf example (remove commentary #'s):
  218.  
  219. #default 0
  220. #timeout 10
  221. #title Gentoo Linux 2.6.31
  222. #root (hd0,0)
  223. #kernel /boot/kernel-2.6.31-gentoo-r10 root=/dev/sda4 panic=30
  224.  
  225.  
  226. # if it's NOT a RAID install
  227. grep -v rootfs /proc/mounts > /etc/mtab
  228. grub-install --no-floppy /dev/sda
  229.  
  230. # if it IS a RAID install (repeat this per each hd)
  231. grub
  232. root (hd0,0)
  233. setup (hd0)
  234. quit
  235.  
  236. ## ------------------------------------------------------------------ ##
  237.  
  238. ### 13. Final Setup
  239.  
  240. # This files must be setup manually:
  241.  
  242. nano -w /etc/fstab # remember to use notail on the boot partition
  243.  
  244. nano -w /etc/conf.d/hostname
  245. /etc/init.d/hostname restart
  246.  
  247. nano -w /etc/conf.d/net
  248. rc-update add net.eth0 default
  249.  
  250. # if there's more than one eth, then make this symlink (optional)
  251. ln -sf /etc/init.d/net.lo /etc/init.d/net.eth1
  252. rc-update add net.eth1 default
  253.  
  254. nano -w /etc/hosts
  255.  
  256. nano -w /etc/resolv.conf
  257.  
  258. ## ------------------------------------------------------------------ ##
  259.  
  260. ### 14. Root password
  261.  
  262. # CRITICAL: If this is not set you won't be able to login later
  263. passwd root
  264.  
  265. ## ------------------------------------------------------------------ ##
  266.  
  267. ### 15. You're done. Reboot
  268.  
  269. exit
  270. cd
  271. umount /mnt/gentoo/boot /mnt/gentoo/tmp /mnt/gentoo/dev /mnt/gentoo/proc /mnt/gentoo
  272. swapoff /dev/sda2 # md2 in case of raid
  273. reboot