Installing Gentoo: Difference between revisions

From BitFolk
Jump to navigation Jump to search
(initial version)
 
m (moved Gentoo to Installing Gentoo: match same pattern as Slackware)
(No difference)

Revision as of 02:37, 11 November 2013

Very lightly-edited copy-paste from an emailed guide that a customer supplied:

OK, my guide to running gentoo on bitfolk.

It presumes you know a fair bit about linux in general. including using bash, fdisk, making a kernel, etc.

I've got a single core machine, 20GB disk, with 500MB RAM VMS. This will work fine on the smallest package of a 10GB disk too. I've done most of my install now, and sitting < 3GB.

I'm also going for a 64 bit OS, feel free to change the various bits to make a 32 bit OS.

A lot of this is a summary of http://www.gentoo.org/doc/en/handbook/handbook-amd64.xml, so if you've done Gentoo installs before, you need to know 4 things:

  1. Your disks are /dev/xvda (main disk) and /dev/xvdb (swap disk)
  2. You need to enable the following kernel modules (in addition to your normal stuff):
    CONFIG_XEN=y
    CONFIG_XEN_MAX_DOMAIN_MEMORY=500
    CONFIG_XEN_SAVE_RESTORE=y
    CONFIG_XEN_BLKDEV_FRONTEND=y
    CONFIG_XEN_NETDEV_FRONTEND=y
    CONFIG_HVC_XEN=y
    CONFIG_HVC_XEN_FRONTEND=y
    CONFIG_XEN_FBDEV_FRONTEND=y
    CONFIG_XEN_BALLOON=y
    CONFIG_XEN_BALLOON_MEMORY_HOTPLUG=y
    CONFIG_XEN_SCRUB_PAGES=y
    CONFIG_XEN_DEV_EVTCHN=y
    CONFIG_XENFS=y
    CONFIG_XEN_COMPAT_XENFS=y
    CONFIG_XEN_SYS_HYPERVISOR=y
    CONFIG_XEN_XENBUS_FRONTEND=y
    CONFIG_XEN_GNTDEV=m
    CONFIG_XEN_GRANT_DEV_ALLOC=m
    CONFIG_XEN_PRIVCMD=y
    CONFIG_XEN_HAVE_PVMMU=y
    

    It's possible you can trim this little lot down, but that's working

    You can also trim away a lot of stuff from a standard kernel, like PCI, power management etc.

  3. In /etc/rc.conf, set rc_sys="xenU"
  4. Xen and grub didn't play well for me. Create some hda symlinks and then it's happy:
    ln -s /dev/xvda /dev/hda
    ln -s /dev/xvda1 /dev/hda1
    ln -s /dev/xvda2 /dev/hda2

Finally, YMMV. Don't blame me if this goes wrong!

Pre install work

  1. Copy the PASSWORDS file somewhere, so that you have it.
  2. Change the root password (we'll be binning the install soon, but in the interests of security whilst we work)
  3. Change your domain DNS to point to the right IP.
  1. Log into the console, look in your PASSWORDS file
  2. Run the rescue environment.
  3. You'll need the password for the user "user", which is displayed on screen.
  4. You can either work off the terminal you are in, or you can now ssh in.

Layout

YOU ARE ABOUT THE DELETE EVERYTHING ON YOUR BITFOLK DISKS. STOP UNLESS YOU WANT TO LOSE EVERYTHING!

  1. Disks are located at /dev/xvda and /dev/xvdb (swap disk) (run fdisk -l to be sure)
  2. fdisk /dev/xvda, and partition accordingly.

    I created a 50MB /boot partition (short on space) and the rest for /

    For completness, I toggled the boot flag on the /boot partition.

  3. Because I like things to be correct, I fdisk'd the swap disk to change the type to 82,

    "Linux swap / Solaris"

  4. Filesystem types - I'm going with ext4. Change to suit.
    mkfs.ext4 -L boot /dev/xvda1
    mkfs.ext4 -L root /dev/xvdb2
  5. mkswap -L swap /dev/xvdb1
    LABEL=swap, UUID=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  6. A summary of commands to run, with comments on decisions I made. Best advice is to use the gentoo handbook, so that you can make informed decisions yourself, and also have up to date information! Current on 2013-11-07. This is provided just to give some insight.
mkdir /mnt/gentoo
mount /dev/xvda2 /mnt/gentoo/                                              
mkdir /mnt/gentoo/boot
mount /dev/xvda1 /mnt/gentoo/boot
# Change the URL to match current version and arch
wget http://www.mirrorservice.org/sites/distfiles.gentoo.org/releases/amd64/autobuilds/current-stage3-amd64/stage3-amd64-20131031.tar.bz2
tar xvjpf stage3-*.tar.bz2
# Make the appropriate edits.
# Again for some seinsible defaults, I've got:
# CFLAGS="-march=native -O2 -pipe -fomit-frame-pointer"
# CXXFLAGS="${CFLAGS}"
# CHOST="x86_64-pc-linux-gnu"
# MAKEOPTS="-j2"
nano /mnt/gentoo/etc/portage/make.conf
mirrorselect -i -o >> /mnt/gentoo/etc/portage/make.conf
mirrorselect -i -r -o >> /mnt/gentoo/etc/portage/make.conf
cp -L /etc/resolv.conf /mnt/gentoo/etc/
mount -t proc none /mnt/gentoo/proc
mount --rbind /sys /mnt/gentoo/sys
mount --rbind /dev /mnt/gentoo/dev
chroot /mnt/gentoo /bin/bash
source /etc/profile
export PS1="(chroot) $PS1"
emerge-webrsync
emerge --sync
# Read the news. This stuff is useful, and should be read.
eselect news read
# Look at the profile list. I'm sticking with a "server" install, the default.
eselect profile list
# Make any changes to the USE variable. I chose to leave it as is for now.
nano -w /etc/portage/make.conf
# I'm in the UK. Change accordingly.
cp /usr/share/zoneinfo/Europe/London /etc/localtime
echo "Europe/London" > /etc/timezone
# I like gentoo-sources. You can go with vanilla-sources if you wish, there are others too.
emerge gentoo-sources
cd /usr/src/linux
# Configure your kernel. See my stuff at the top for essential enables, then the rest is up to you.
# Probably should look at http://www.gentoo.org/doc/en/handbook/handbook-amd64.xml if you're new to Gentoo.
make menuconfig
make && make modules_install
cp arch/x86_64/boot/bzImage /boot/vmlinuz
# Edit your fstab. Mine is below:
nano -w /etc/fstab
#/dev/xvda1              /boot           ext4            noatime         1 2
#/dev/xvda2              /               ext4            noatime         1 1
#/dev/xvdb1              none            swap            sw              0 0
# Edit your hostname.
nano -w /etc/conf.d/hostname
# Edit your network settings. Mine is below (change your numbers! run ifconfig -a to get them):
nano -w /etc/conf.d/net
#config_eth0="XXX.XXX.XXX.XXX netmask XXX.XXX.XXX.XXX brd XXX.XXX.XXX"
#routes_eth0="default via XXX.XXX.XXX.XXX"
# Add hosts for your hostname.
nano -w /etc/hosts
# Change the root password
passwd
# Modify your RC to suite. Set rc_sys="xenU"
nano -w /etc/rc.conf
# Modify your keymap (for completeness, you'll never be at the actual keyboard)
nano -w /etc/conf.d/keymaps
# I didn't change the clock settings, but have a look
nano -w /etc/conf.d/hwclock
# If you only want a certain language, you can configure it in /etc/locale.gen.
nano -w /etc/locale.gen
locale-gen
# Setup your env language:
nano -w /etc/env.d/02locale
# Load the languages
env-update && source /etc/profile

# Optional choices here. I went with the gentoo choices of syslog-ng for syslog,
#       vixie-cron for cron and installing mlocate.
emerge syslog-ng
rc-update add syslog-ng default
emerge vixie-cron
rc-update add vixie-cron default
emerge mlocate
# Guess we want ssh on startup.....
rc-update add sshd default

# Bootloader. I tried grub2, but it wasn't happy. So I went with grub-legacy,
# and even that was tricky.
emerge sys-boot/grub:0
nano -w /boot/grub/grub.conf
# Here's mine. I'm not too worried about backup kernels, because we have the rescue environment.
#default 0
#timeout 0
#
#title Gentoo Linux
#root (hd0,0)
#kernel /boot/vmlinuz root=/dev/xvda2
# To get grub to play ball with Xen, you have to create a symlink from /dev/xvda > /dev/hda
ln -s /dev/xvda /dev/hda
ln -s /dev/xvda1 /dev/hda1
ln -s /dev/xvda2 /dev/hda2
grep -v rootfs /proc/mounts > /etc/mtab

grub --no-floppy
grub> root (hd0,0)    (Specify where your /boot partition resides)
grub> setup (hd0)     (Install GRUB in the MBR)
grub> quit            (Exit the GRUB shell)

# All done! Unmount and reboot, and cross fingers! Give it a minute to boot, and then you should
be able to ssh in!

exit
cd
umount -l /mnt/gentoo/dev{/shm,/pts,}
umount -l /mnt/gentoo{/boot,/proc,}
reboot
# Don't panic if it doesn't work. You can start the rescue environment again,
# mount the disks, and work out what went wrong.

# GOOD LUCK!