Phylum

gentoo install 'script'

Jun 25th, 2011
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.79 KB | None | 0 0
  1. # Starting sshd
  2. /etc/init.d/sshd start
  3.  
  4. # Getting eth0 up
  5. ifconfig eth0 up
  6.  
  7. # Getting eth1 up
  8. ifconfig eth1 up
  9.  
  10. # Enabling dhcp
  11. dhcpcd
  12.  
  13. # Preparing partitions
  14. dd if=/dev/zero of=/dev/sda bs=1024 count=1024
  15. echo -e "n\np\n1\n\n+51M\np\nn\np\n2\n\n+1G\nt\n2\n82\nn\np\n3\n\n\np\nw\n" > /tmp/fdisk.partitions
  16. fdisk /dev/sda < /tmp/fdisk.partitions
  17.  
  18. # Preparing boot
  19. mke2fs /dev/sda1
  20.  
  21. # Preparing /
  22. mke2fs -j /dev/sda3
  23.  
  24. # Preparing swap
  25. mkswap /dev/sda2
  26.  
  27. # Turning on swap
  28. swapon /dev/sda2
  29.  
  30. # Mounting
  31. mount /dev/sda3 /mnt/gentoo
  32. mkdir /mnt/gentoo/boot
  33. mount /dev/sda1 /mnt/gentoo/boot
  34. # OpenRC Fixes: http://xrl.us/openrc
  35. mkdir /mnt/gentoo/dev
  36. cd /mnt/gentoo/dev
  37. rm -rf null
  38. mknod --mode=600 console c 5 1
  39. mknod --mode=666 null c 1 3
  40. mknod --mode=666 zero c 1 5
  41. cd /mnt/gentoo
  42.  
  43. # Setting date: Format is MMDDhhmmYYYY
  44. read dateinput
  45. date $dateinput
  46.  
  47. # Downloading stage3
  48. wget http://gentoo.mirrors.tds.net/gentoo/releases/amd64/autobuilds/current-stage3/stage3-amd64-20110609.tar.bz2
  49.  
  50. # Downloading Portage
  51. wget http://gentoo.mirrors.tds.net/gentoo/snapshots/portage-latest.tar.bz2
  52.  
  53. # Extracting stage3
  54. tar xvjpf stage3-*.tar.bz2
  55.  
  56. # Extracting Portage
  57. tar xvjf portage-latest.tar.bz2 -C /mnt/gentoo/usr
  58.  
  59. # Edit make.conf
  60. # Safe cflags http://en.gentoo-wiki.com/wiki/Safe_Cflags/Intel
  61. # Used this at first...
  62. #sed -i 's/CFLAGS="-O2 -pipe"/CFLAGS="-march=core2 -mtune=generic -O2 -pipe"/g' /mnt/gentoo/etc/make.conf
  63. # But warning on page above suggested using -march=native
  64. sed -i 's/CFLAGS="-O2 -pipe"/CFLAGS="-march=native -mtune=generic -O2 -pipe"/g' /mnt/gentoo/etc/make.conf
  65. echo MAKEOPTS=\"-j2\" >> /mnt/gentoo/etc/make.conf
  66.  
  67. # Installing Gentoo base System: Chrooting - Selecting Mirrors
  68. mirrorselect -i -o >> /mnt/gentoo/etc/make.conf
  69. mirrorselect -i -r -o >> /mnt/gentoo/etc/make.conf
  70.  
  71. # Copy DNS Info
  72. cp -L /etc/resolv.conf /mnt/gentoo/etc/
  73.  
  74. # Mounting the /proc and /dev Filesystems
  75. mount -t proc none /mnt/gentoo/proc
  76. mount --rbind /dev /mnt/gentoo/dev
  77.  
  78. # Entering the new Environment
  79. chroot /mnt/gentoo /bin/bash
  80.  
  81. # Entering the new Environment
  82. env-update
  83. source /etc/profile
  84. export PS1="(chroot) $PS1"
  85.  
  86. # OpenRC Fixes: http://xrl.us/openrc
  87. rc-update add udev sysinit
  88.  
  89. # Configuring Portage: Updating the Portage tree
  90. emerge --sync
  91.  
  92. # Choosing the Right Profile
  93. eselect profile list
  94.  
  95. # Which profile are we going to use?
  96. # Usually 7 default/linux/amd64/10.0/server
  97. read profileselection
  98. eselect profile set $profileselection
  99.  
  100. # Configuring the USE variable
  101. #nano -w /etc/make.conf
  102. sed -i 's/USE="mmx sse sse2"/USE="mmx sse sse2 -gtk -gnome -qt4 -kde -dvd -alsa -cdr"/g' /etc/make.conf
  103.  
  104. ## Optional glibc Locales
  105. #nano -w /etc/locale.gen
  106. #set -i 's/#en_US/en_US/g' /etc/locale.gen
  107. # no sure why that replace doesn't work...?
  108.  
  109. # Configuring the Kernel: Timezone
  110. cp /usr/share/zoneinfo/America/New_York /etc/localtime
  111.  
  112. # Installing the Sources: Choosing a Kernel
  113. emerge gentoo-sources
  114.  
  115. # Alternative: Using genkernel
  116. emerge genkernel
  117. zcat /proc/config.gz > /usr/share/genkernel/arch/x86_64/kernel-config
  118. genkernel --menuconfig all
  119. # Enabled devtmpgfs: Drivers > General > devtmpfs
  120. # This always fails the first time - running it again works...?
  121.  
  122. # Kernel Modules: Configuring the Modules
  123. #find /lib/modules/2.6.*gentoo-*/ -type f -iname '*.o' -or -iname '*.ko' | less
  124.  
  125. # Configuring fstab
  126. echo -e "/dev/sda1 /boot ext2 defaults,noatime 1 2\n"\
  127. "/dev/sda2 none swap sw 0 0\n"\
  128. "/dev/sda3 / ext3 noatime 0 1\n\n"\
  129. "#/dev/cdrom /mnt/cdrom auto noauto,user 0 0\n\n"\
  130. "proc /proc proc defaults 0 0\n"\
  131. "shm /dev/shm tmpfs nodev,nosuid,noexec 0 0\n" > /etc/fstab
  132.  
  133. # Networking Information: Host name, Domainname, etc
  134. echo -e "# Set to the hostname of this machine\nHOSTNAME=\"myhostname\"" > /etc/conf.d/hostname
  135. echo -e "dns_domain_lo=\"mydoma.in\"\n"\
  136. "config_eth0=( \"dhcp\" )\n"\
  137. "config_eth1=( \"dhcp\" )" >> /etc/conf.d/net
  138.  
  139. # Automatically Start Networking at Boot
  140. cd /etc/init.d
  141. ln -s net.lo net.eth0
  142. ln -s net.lo net.eth1
  143. rc-update add net.eth0 default
  144. rc-update add net.eth1 default
  145.  
  146. # Writing Down Network Information
  147. # real tab = ctrl-v + ctrl-i
  148. sed -i 's/127.0.0.1 localhost/127.0.0.1 myhostname.mydoma.in myhostname localhost/g' /etc/hosts
  149. sed -i 's/::1 localhost/::1 myhostname.mydoma.in myhostname localhost/g' /etc/hosts
  150.  
  151. # System Information: root Password
  152. passwd
  153.  
  154. # System Information: System Information
  155. # This file doesn't exist, but it should...right?
  156. #nano -w /etc/conf.d/clock
  157.  
  158. # Installing Necessary System Tools
  159. for apps in syslog-ng vixie-cron mlocate dhcpcd wgetpaste gpm
  160. do
  161. echo Installing $apps
  162. emerge -v $apps
  163.  
  164. case $apps in
  165. syslog-ng|vixie-cron)
  166. echo Adding $apps to rc-update default
  167. rc-update add $apps default
  168. ;;
  169. esac
  170. done
  171.  
  172. # Configuring the Bootloader: GRUB
  173. emerge -v grub
  174. echo -e "default 0\n"\
  175. "timeout 30\n"\
  176. "splashimage=(hd0,0)/boot/grub/splash.xpm.gz\n\n"\
  177. "title Gentoo Linux 2.6.38-gentoo-r6 for x86_64\n"\
  178. "root (hd0,0)\n"\
  179. "kernel /boot/kernel-genkernel-x86_64-2.6.38-gentoo-r6 real_root=/dev/sda3\n"\
  180. "#kernel /boot/kernel-genkernel-x86_64-2.6.38-gentoo-r6 real_root=/dev/sda3 video=uvesafb:mtrr:3,ywrap,1024x768-32@85\n"\
  181. "initrd /boot/initramfs-genkernel-x86_64-2.6.38-gentoo-r6\n" > /boot/grub/grub.conf
  182.  
  183. # Setting up GRUB using grub-install
  184. grep -v rootfs /proc/mounts > /etc/mtab
  185. grub-install --no-floppy /dev/sda
  186.  
  187. # Exiting Chrooted environment
  188. exit
  189.  
  190.  
  191. # Rebooting the System
  192. cd
  193. umount -l /mnt/gentoo/dev{/shm,/pts,}
  194. # I always get an error that shm isn't mounted - that normal?
  195. umount -l /mnt/gentoo{/boot,/proc,}
  196. reboot
Advertisement
Add Comment
Please, Sign In to add comment