Last active
August 6, 2021 15:57
-
-
Save jinleileiking/2717362 to your computer and use it in GitHub Desktop.
Gentoo Install Script with Rescue CD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fdisk /dev/sda | |
# n | |
# 1 | |
# +32M | |
# n | |
# 2 | |
# +512M | |
# n | |
# 3 | |
# t | |
# 2 | |
echo -e "\e[1;91mMaking File systems..." | |
mkfs.ext2 /dev/sda1 | |
mkfs.ext4 /dev/sda3 | |
mkswap /dev/sda2 | |
swapon /dev/sda2 | |
echo -e "\e[1;91mPrepare change root..." | |
echo -e "\e[0m" | |
mkdir /mnt/gentoo | |
mount /dev/sda3 /mnt/gentoo | |
mkdir /mnt/gentoo/boot | |
mount /dev/sda1 /mnt/gentoo/boot | |
echo -e "\e[1;91mCopy stage & portage to hadrdisk..MODIFY!!!!..." | |
####################################### | |
sudo cp /media/843B-F976/* /mnt/gentoo/ | |
###################################### | |
mkdir /mnt/win | |
mount -t vboxsf D_DRIVE /mnt/win | |
cd /mnt/gentoo | |
tar xvjpf stage3-*.tar.bz2 | |
tar xvjf /mnt/gentoo/portage-*.tar.bz2 -C /mnt/gentoo/usr | |
echo -e "\e[1;91mChange Root....." | |
cp -L /etc/resolv.conf /mnt/gentoo/etc/ | |
mount -t proc none /mnt/gentoo/proc | |
mount --rbind /dev /mnt/gentoo/dev | |
chroot /mnt/gentoo /bin/bash | |
echo -e "\e[1;91mEmerge git....." | |
#git config --global user.name jinleileiking | |
#git config --global user.email jinleileiking@gmail.com | |
mkdir /boot/grub | |
echo -e "\e[1;91mGet Gento Config Files from git hub....." | |
cd / | |
git init | |
git remote add http https://jinleileiking@github.com/jinleileiking/GentooCfgFiles.git | |
git fetch http | |
git branch master http/master | |
git checkout master | |
################################################## | |
echo -e "\e[1;91mCheck make.conf, conf.d/hostname conf.d/net, /etc/fstab, boot/grub/grub.conf....." | |
################################################# | |
echo -e "\e[1;91m!!!!!Modify make.conf!!!!!!.....\e[0m" | |
echo -e "\e[1;91mUpdating Emerge database and make kernel.....\e[0m" | |
emerge --sync --quiet | |
eselect profile select | |
emerge gentoo-sources | |
make menuconfig | |
# file system ext2,ext4 | |
# cpu type | |
# smp | |
# device->wirelsee->ar5xxx | |
make && make modules_install | |
echo -e "\e[1;91m!!!!!!!!!!Change version!!!!!!" | |
######################################################## | |
cp arch/x86_64/boot/bzImage /boot/kernel-3.2.??-gentoo-r2 | |
######################################################## | |
echo -e "\e[1;91mSetup Net!!....." | |
cd /etc/init.d | |
############################################ | |
ln -s net.lo net.eth0 | |
rc-update add net.eth0 default | |
ln -s net.lo net.wlan0 | |
rc-update add net.wlan0 default | |
############################################ | |
# make sure use the newest vbox-guest-additions...... | |
emerge syslog-ng dhcpcd grub | |
##option del after | |
rc-update add sshd default | |
echo -e "\e[1;91mSet Root Password!!....." | |
passwd | |
# | |
# | |
grub --no-floppy | |
################### | |
#root (hd0,0) | |
#setup (hd0) | |
#quit | |
################### | |
reboot | |
##################Now using harddisk linux, root########telnet it, You can use copy & past######################################## | |
emerge xorg-server virtualbox-guest-additions terminator sudo google-chrome git sudo | |
emerge awesome | |
emerge kdebase-startkde xdm | |
rc-update add virtualbox-guest-additions default | |
echo "exec startkde" > ~/.xinitrc | |
rc-update add dbus default # chromium need it | |
rc-update add syslog-ng default | |
visudo | |
# uncomment %wheel line | |
echo -e "\e[1;91mAdding user........." | |
useradd -m -G root -s /bin/bash jinleileiking | |
usermod -a -G vboxguest jinleileiking | |
passwd jinleileiking | |
# | |
# | |
su jinleileiking | |
echo -e "\e[1;91mcloning Dotfiles...." | |
cd ~ | |
git init | |
git remote add http https://jinleileiking@github.com/jinleileiking/DotFiles.git | |
git fetch http | |
git branch master http/master | |
git checkout master | |
##################Now using harddisk linux, user, gui################################################ | |
########useradd -m -G root,usb,wheel,portage,bin,daemon,sys,adm,video,mongodb,redis,tty,disk,lp,mem,kmem,floppy,news,uucp,console,audio,cdrom,tape,cdrw,users,utmp,man,sshd,messagebus,lpadmin,mail,postmaster,ssmtp -s /bin/bash jinleileiking | |
emerge zsh wqy-microhei ubuntu-font-family eix gentoolkit flaggie cscope ctags ack gvim pciutils axel aria2 adobe-flash layman wpa_supplicant | |
emerge mongodb redis memcached pygments | |
emerge feh pcmanfm scrot alsa-mixer porthole virtualbox | |
echo -e "\e[1;91mEmerge Packages...." | |
emerge -u world | |
#echo -e "\e[1;91mInstalling gvim....." | |
#git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle | |
#vim +BundleInstall +qa | |
#cd ~/.vim/bundle/Command-T/ruby/command-t/; ruby extconf.rb; make; cd - | |
echo -e "\e[1;91mInstalling OH MY ZSH....." | |
#git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh | |
chsh -s /bin/zsh | |
################################################################################### | |
easy_install pygments | |
sudo mkdir /data/db -p | |
######################################################################################## | |
echo -e "\e[1;91mInstalling rvm....." | |
bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer) | |
. .bashrc | |
rvm requirements | |
emerge libiconv readline zlib openssl curl git libyaml sqlite libxslt libtool gcc autoconf automake bison m4 | |
rvm install 1.9.3 | |
rvm 1.9.3 | |
gem install bundler | |
cd ~ | |
bundle install | |
########################################################################################## | |
#Sound | |
rc-update add alsasound boot | |
alsamixer | |
############################################## | |
# emerge --update --deep --with-bdeps=y world # dont do this!!!!! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
!/bin/bash
GENTOO INSTALL SCRIPT BASIC INSTALL AND DEFAULT CONFIGS
Created by assembled from few parts finded on Internet and adopted by: anest
v.0.4
Display Introduction
echo ""
echo "Welcome to the GENTOO install script, please note you must be at your system for instructions"
echo "this script will perform a majority of the configurations for you however certain interaction"
echo "may be required on your part."
echo
echo
echo "NOTE: THIS WILL RESULT IN DATA LOSS OF THE CURRENT DRIVE"
echo "Please press enter when your ready to continue."
echo ""
read
Configure hard disk
echo "The following is a list of found Hard Disk devices (sda/hda):"
ls /dev/ | grep -E [s:h]da$
fdisk -l
echo
echo "Please enter the device you would like to install to:"
echo "example: sda"
read HD_DEVICE
HDD="/dev/${HD_DEVICE}"
warn user last time
echo
echo "THIS IS YOUR LAST CHANCE TO CANCEL, Press CTRL+C to cancel this install or ENTER to continue"
read
echo "p" | fdisk $HDD
echo "Please specifiy the total number of partitions:"
PARTS=4
cleanup
rm -f fdisc.in
TODO: add integer checking
echo -n "Generating fdisk operation file"
echo -n "Removing old partitions on hdd"
fdisk -l
sleep 5
dd if=/dev/zero of=$HDD bs=512 count=1
sleep 5
fdisk -l
sleep 5
echo "Create partitions"
echo "n" > fdisc.in # New Partiton
echo "p" >> fdisc.in # Primary
echo "1" >> fdisc.in # Partion 1
echo "" >> fdisc.in # default
echo "+512M" >> fdisc.in # 512 MB size
echo "a" >> fdisc.in # Set flag
echo "1" >> fdisc.in # bootable
echo -n "."
echo "n" >> fdisc.in # New Partion
echo "p" >> fdisc.in # Primary
echo "2" >> fdisc.in # Partion 2
echo "" >> fdisc.in # default
echo "+2048M" >> fdisc.in # 2048 MB size
echo "t" >> fdisc.in # Set partition type
echo "2" >> fdisc.in # Partition 2
echo "82" >> fdisc.in # 82 = SWAP
echo -n "."
echo "n" >> fdisc.in # New Partition
echo "p" >> fdisc.in # Primary
echo "3" >> fdisc.in # Partition 2
echo "" >> fdisc.in # default
echo "" >> fdisc.in # new Line
echo -n "."
echo "w" >> fdisc.in # Write partion table
echo "q" >> fdisc.in # Quit
echo ". Done"
sleep 5
Execute file
echo "Executing fdisk script ..."
echo
fdisk $HDD < fdisc.in
clean up
rm -f fdisc.in
sleep 5
fdisk -l
echo ""
echo "Partitions created"
echo "Applying filesystem to partitions"
echo " *** mkfs disk *** "
sleep 5
echo "format ext2 /dev/${HD_DEVICE}1"
mke2fs /dev/${HD_DEVICE}1 > /dev/null 2>&1
echo "format ext4 /dev/${HD_DEVICE}3"
mkfs.ext4 /dev/${HD_DEVICE}3 > /dev/null 2>&1
echo "swap /dev/${HD_DEVICE}2"
mkswap /dev/${HD_DEVICE}2
echo "Activating swap partition"
swapon /dev/${HD_DEVICE}2
echo ""
echo "Mounting partitions"
mkdir /mnt/gentoo
mount /dev/${HD_DEVICE}3 /mnt/gentoo
mkdir /mnt/gentoo/boot
mount /dev/${HD_DEVICE}1 /mnt/gentoo/boot
echo "mount:"
mount
echo ""
sleep 2
echo "Starting STAGE 3 Install"
echo ""
cd /mnt/gentoo
url="http://mirrors.kernel.org/gentoo/releases/amd64/autobuilds"
wget $url/
curl $url/latest-stage3-amd64.txt | tail -1
echo "unpack stage3..."
tar xvjpf stage3-.tar.bz2 > /dev/null 2>&1
echo ""
echo "Installing portage..."
cd /mnt/gentoo
wget http://mirrors.kernel.org/gentoo/snapshots/portage-latest.tar.bz2
echo "unpack portage..."
tar xvjf /mnt/gentoo/portage-latest.tar.bz2 -C /mnt/gentoo/usr > /dev/null 2>&1
echo "Cleaning up..."
rm -f portage-latest.tar.bz2
rm -f stage3-amd64-.tar.bz2
echo ""
echo "Getting ready to CHROOT"
cp -L /etc/resolv.conf /mnt/gentoo/etc/resolv.conf
echo "Mount Dev and Proc"
mount -t proc none /mnt/gentoo/proc
mount -o bind /dev /mnt/gentoo/dev
echo "Chrooted"
echo "Updating portage..."
sleep 2
echo 'EMERGE_DEFAULT_OPTS="--nospinner --keep-going"' >> /mnt/gentoo/etc/make.conf
echo "Updating Metadata..."
chroot /mnt/gentoo emerge --metadata > /dev/null 2>&1
echo "Updating Sync..."
chroot /mnt/gentoo emerge --sync > /dev/null 2>&1
echo "Updating Portage..."
chroot /mnt/gentoo emerge portage > /dev/null 2>&1
echo "Installing Grub..."
chroot /mnt/gentoo emerge grub > /dev/null 2>&1
echo "Portage updated, downloading kernel source..."
echo "#!/bin/bash" > /mnt/gentoo/portage
echo 'USE="-doc symlink" emerge gentoo-sources > /dev/null 2>&1' >> /mnt/gentoo/portage
chmod 700 /mnt/gentoo/portage
chroot /mnt/gentoo ./portage
rm -f /mnt/gentoo/portage
echo "#!/bin/bash" > /mnt/gentoo/portage
echo 'cd /usr/src/linux' >> /mnt/gentoo/portage
echo 'echo ""' >> /mnt/gentoo/portage
echo 'echo "_"' >> /mnt/gentoo/portage
echo 'echo "_* KERNEL CONFIGURATION "' >> /mnt/gentoo/portage
echo 'echo ""' >> /mnt/gentoo/portage
echo 'echo " You will now be prompted with the linux kernel _"' >> /mnt/gentoo/portage
echo 'echo "menu configurator, please ensure that you specify"' >> /mnt/gentoo/portage
echo 'echo "_the right settings, as once you exit this script _"' >> /mnt/gentoo/portage
echo 'echo "_will compile and install the new kernel "' >> /mnt/gentoo/portage
echo 'echo "************************************************"' >> /mnt/gentoo/portage
echo 'echo ""' >> /mnt/gentoo/portage
echo 'echo "Please press enter to continue"' >> /mnt/gentoo/portage
echo 'read' >> /mnt/gentoo/portage
echo "install genkernel"
chroot /mnt/gentoo emerge genkernel > /dev/null 2>&1
chroot /mnt/gentoo genkernel --install --oldconfig --save-config --mountboot kernel
echo 'cd /usr/src/linux' >> /mnt/gentoo/portage
echo 'make defconfig' >> /mnt/gentoo/portage
echo 'make oldconfig' >> /mnt/gentoo/portage
echo 'make menuconfig' >> /mnt/gentoo/portage
echo 'echo "kernel compilation ..."' >> /mnt/gentoo/portage
echo 'make > /dev/null 2>&1' >> /mnt/gentoo/portage
echo 'echo "modules compilation ..."' >> /mnt/gentoo/portage
echo 'make modules_install > /dev/null 2>&1' >> /mnt/gentoo/portage
echo 'echo "kernel install..."' >> /mnt/gentoo/portage
echo 'make install > /dev/null 2>&1' >> /mnt/gentoo/portage
echo 'cp arch/i386/boot/bzImage /boot/originalKernel' >> /mnt/gentoo/portage
echo 'echo ""' >> /mnt/gentoo/portage
chmod 700 /mnt/gentoo/portage
chroot /mnt/gentoo ./portage
rm -f /mnt/gentoo/portage
echo "Generating fstab"
echo "# /etc/fstab: static file system information." > /mnt/gentoo/etc/fstab
echo "#" >> /mnt/gentoo/etc/fstab
echo "# noatime turns off atimes for increased performance (atimes normally aren't" >> /mnt/gentoo/etc/fstab
echo "# needed; notail increases performance of ReiserFS (at the expense of storage" >> /mnt/gentoo/etc/fstab
echo "# efficiency). It's safe to drop the noatime options if you want and to" >> /mnt/gentoo/etc/fstab
echo "# switch between notail / tail freely." >> /mnt/gentoo/etc/fstab
echo "#" >> /mnt/gentoo/etc/fstab
echo "# The root filesystem should have a pass number of either 0 or 1." >> /mnt/gentoo/etc/fstab
echo "# All other filesystems should have a pass number of 0 or greater than 1." >> /mnt/gentoo/etc/fstab
echo "#" >> /mnt/gentoo/etc/fstab
echo "# See the manpage fstab(5) for more information." >> /mnt/gentoo/etc/fstab
echo "#" >> /mnt/gentoo/etc/fstab
echo "" >> /mnt/gentoo/etc/fstab
echo "# <dump/pass>" >> /mnt/gentoo/etc/fstab
echo "" >> /mnt/gentoo/etc/fstab
echo "# NOTE: If your BOOT partition is ReiserFS, add the notail option to opts." >> /mnt/gentoo/etc/fstab
echo "/dev/${HD_DEVICE}1 /boot ext2 defaults,noatime 1 2" >> /mnt/gentoo/etc/fstab
echo "/dev/${HD_DEVICE}2 none swap sw 0 0" >> /mnt/gentoo/etc/fstab
echo "/dev/${HD_DEVICE}3 / ext4 defaults,errors=remount-ro,relatime 0 1" >> /mnt/gentoo/etc/fstab
echo "#/dev/cdroms/cdrom0 /mnt/cdrom iso9660 noauto,ro 0 0" >> /mnt/gentoo/etc/fstab
echo "" >> /mnt/gentoo/etc/fstab
echo "# NOTE: The next line is critical for boot!" >> /mnt/gentoo/etc/fstab
echo "proc /proc proc nodev,noexec,nosuid 0 0" >> /mnt/gentoo/etc/fstab
echo "" >> /mnt/gentoo/etc/fstab
echo "# glibc 2.2 and above expects tmpfs to be mounted at /dev/shm for" >> /mnt/gentoo/etc/fstab
echo "# POSIX shared memory (shm_open, shm_unlink)." >> /mnt/gentoo/etc/fstab
echo "# (tmpfs is a dynamically expandable/shrinkable ramdisk, and will" >> /mnt/gentoo/etc/fstab
echo "# use almost no memory if not populated with files)" >> /mnt/gentoo/etc/fstab
echo "shm /dev/shm tmpfs nodev,nosuid,noexec 0 0" >> /mnt/gentoo/etc/fstab
cat /mnt/gentoo/etc/fstab
sleep 5
echo ""
echo "Configuring rc scripts"
cd /etc/init.d/
ln -s net.lo net.eth0
chroot /mnt/gentoo rc-update add net.eth0 default
chroot /mnt/gentoo rc-update add sshd default
echo "**************************************************"
echo "Installing pwgen..."
chroot /mnt/gentoo emerge -u pwgen > /dev/null 2>&1
chroot /mnt/gentoo pwgen -s -1 16
sleep 5
echo ""
chroot /mnt/gentoo passwd
echo "Installing tools..."
chroot /mnt/gentoo emerge app-admin/syslog-ng > /dev/null 2>&1
chroot /mnt/gentoo emerge -C slocate > /dev/null 2>&1
chroot /mnt/gentoo emerge sys-apps/mlocate > /dev/null 2>&1
chroot /mnt/gentoo emerge net-misc/dhcpcd net-misc/dhcp > /dev/null 2>&1
chroot /mnt/gentoo emerge sys-process/vixie-cron > /dev/null 2>&1
chroot /mnt/gentoo rc-update add syslog-ng default
chroot /mnt/gentoo rc-update add vixie-cron default
echo ""
echo ""
echo "Installing Grub..."
chroot /mnt/gentoo emerge grub > /dev/null 2>&1
echo "boot=/dev/${HD_DEVICE} # Install Grub in the MBR" >> /mnt/gentoo/etc/grub.conf
echo "prompt # Give the user the chance to select another section" >> /mnt/gentoo/etc/lilo.conf
echo "timeout=50 # Wait 5 (five) seconds before booting the default section" >> /mnt/gentoo/etc/lilo.conf
echo "default=gentoo # When the timeout has passed, boot the "gentoo" section" >> /mnt/gentoo/etc/lilo.conf
echo "" >> /mnt/gentoo/etc/lilo.conf
echo "# For non-genkernel users" >> /mnt/gentoo/etc/lilo.conf
echo "image=/boot/originalKernel" >> /mnt/gentoo/etc/lilo.conf
echo " label=gentoo # Name we give to this section" >> /mnt/gentoo/etc/lilo.conf
echo " read-only # Start with a read-only root. Do not alter!" >> /mnt/gentoo/etc/lilo.conf
echo " root=/dev/${HD_DEVICE}3 # Location of the root filesystem" >> /mnt/gentoo/etc/lilo.conf
echo "timeout 2" > /mnt/gentoo/boot/grub/grub.conf
echo "default 0" >> /mnt/gentoo/boot/grub/grub.conf
echo "" >> /mnt/gentoo/boot/grub/grub.conf
echo "#default saved" >> /mnt/gentoo/boot/grub/grub.conf
echo "#fallback 1" >> /mnt/gentoo/boot/grub/grub.conf
echo "" >> /mnt/gentoo/boot/grub/grub.conf
echo "title=Gentoo Linux" >> /mnt/gentoo/boot/grub/grub.conf
echo "#savedefault 1" >> /mnt/gentoo/boot/grub/grub.conf
echo "root (hd0,0)" >> /mnt/gentoo/boot/grub/grub.conf
echo "kernel /boot/vmlinuz root=/dev/${HD_DEVICE}3 panic=5" >> /mnt/gentoo/boot/grub/grub.conf
echo "#makeactive" >> /mnt/gentoo/boot/grub/grub.conf
echo "" >> /mnt/gentoo/boot/grub/grub.conf
echo "title=Gentoo Linux OLD [WRK]" >> /mnt/gentoo/boot/grub/grub.conf
echo "root (hd0,0)" >> /mnt/gentoo/boot/grub/grub.conf
echo "kernel /boot/vmlinuz.old root=/dev/${HD_DEVICE}3" >> /mnt/gentoo/boot/grub/grub.conf
echo "make /etc/mtab"
chroot /mnt/gentoo grep -v rootfs /proc/mounts > /etc/mtab
echo "grub-install 1"
chroot /mnt/gentoo grub-install --root-directory=/boot /dev/${HD_DEVICE}
echo "# " >> /mnt/gentoo/boot/grub/grub.conf
ls -la /boot >> /mnt/gentoo/boot/grub/grub.conf
sleep 5
echo "grub-install 2"
chroot /mnt/gentoo "grub install= (hd0,0)/boot/grub/stage2 0x8000 p"
sleep 5
echo "grub install 3"
chroot /mnt/gentoo /sbin/grub --batch --device-map=/dev/null <<EOF
device (hd0) /dev/${HD_DEVICE}
root (hd0,0)
setup (hd0)
quit
EOF
sleep 5
chroot /mnt/gentoo ls -la /boot
sleep 10
chroot /mnt/gentoo nano /boot/grub/grub.conf
cd /mnt/gentoo/boot
ln -s System.map-* System.map
ln -s config-* config
ln -s vmlinuz-* vmlinuz
cd /mnt/gentoo/usr/src
wget http://kyosls.googlecode.com/files/AR81Family-linux-v1.0.1.14.tar.gz
tar -zxvf AR81Family-linux-v1.0.1.14.tar.gz
echo "Install mc..."
chroot /mnt/gentoo emerge app-misc/mc > /dev/null 2>&1
echo "install Autoconf Pciutils Usbutils WirelessTools ..."
chroot /mnt/gentoo emerge sys-devel/autoconf sys-apps/pciutils sys-apps/usbutils net-wireless/wireless-tools net-wireless/wpa_supplicant > /dev/null 2>&1
echo 'modules="iwconfig"' >> /mnt/gentoo/etc/conf.d/net
echo 'preferred_aps="homenet"' >> /mnt/gentoo/etc/conf.d/net
echo "last stage..."
echo "type exit for quit second shell and unmount"
sh
sleep 2
echo "* ROOT PASSWORD *******************_"
echo "YOU ARE NOW REQUIRED TO ENTER A NEW ROOT PASSWORD "
echo "_***********************************"
chroot /mnt/gentoo passwd
sleep 2
cd /
umount /mnt/gentoo/boot /mnt/gentoo/dev /mnt/gentoo/proc /mnt/gentoo
echo "Done"
sleep 2
echo "_"
echo "__"
echo "_* SYSTEM WILL REBOOT NOW "
echo "_"
echo "_***"
beep
sleep 2
reboot
exit