Installing Gentoo: Difference between revisions

From BitFolk
Jump to navigation Jump to search
m (warning about this not being finished)
(Formatted it to look nice, took the comments from the talk page, and appended stuff I've learned since the initial install)
Line 46: Line 46:
like PCI, power management etc.</p></li>
like PCI, power management etc.</p></li>
<li>In /etc/rc.conf, set rc_sys="xenU"</li>
<li>In /etc/rc.conf, set rc_sys="xenU"</li>
<li>Xen and grub didn't play well for me. Create some hda symlinks and then it's happy:
<syntaxhighlight>
ln -s /dev/xvda /dev/hda
ln -s /dev/xvda1 /dev/hda1
ln -s /dev/xvda2 /dev/hda2
</syntaxhighlight></li>
</ol>
</ol>
Finally, YMMV. Don't blame me if this goes wrong!


==Pre install work==
==Pre install work==
Line 72: Line 64:
<li>Disks are located at /dev/xvda and /dev/xvdb (swap disk) (run fdisk -l to be sure)</li>
<li>Disks are located at /dev/xvda and /dev/xvdb (swap disk) (run fdisk -l to be sure)</li>
<li>fdisk /dev/xvda, and partition accordingly.
<li>fdisk /dev/xvda, and partition accordingly.
<p>I created a 50MB /boot partition (short on space) and the rest for /</p>
<p>As this is a VPS, we don't really need a /boot partition, so just create 1 partition for /</p>
<p>For completness, I toggled the boot flag on the /boot partition.</p></li>
<p>For completness, I toggled the boot flag on the /boot partition.</p></li>
<li>Because I like things to be correct, I fdisk'd the swap disk to change the type to 82,
<li>Because I like things to be correct, I fdisk'd the swap disk to change the type to 82,
Line 78: Line 70:
<li>Filesystem types - I'm going with ext4. Change to suit.
<li>Filesystem types - I'm going with ext4. Change to suit.
<syntaxhighlight>
<syntaxhighlight>
mkfs.ext4 -L boot /dev/xvda1
mkfs.ext4 -L root /dev/xvdb1
mkfs.ext4 -L root /dev/xvdb2
</syntaxhighlight></li>
</syntaxhighlight></li>
<li>
<li>
Line 86: Line 77:
LABEL=swap, UUID=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
LABEL=swap, UUID=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
</syntaxhighlight></li>
</syntaxhighlight></li>
<li>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.</li>
</ol>
</ol>


==Install==
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.
<ol>
<li>Make dirs and mount</li>
<syntaxhighlight>
<syntaxhighlight>
mkdir /mnt/gentoo
mkdir /mnt/gentoo
Line 94: Line 90:
mkdir /mnt/gentoo/boot
mkdir /mnt/gentoo/boot
mount /dev/xvda1 /mnt/gentoo/boot
mount /dev/xvda1 /mnt/gentoo/boot
# Change the URL to match current version and arch
</syntaxhighlight>
 
<li>Grab the source code and extract. Change the URL to match current version and arch</li>
<syntaxhighlight>
wget http://www.mirrorservice.org/sites/distfiles.gentoo.org/releases/amd64/autobuilds/current-stage3-amd64/stage3-amd64-20131031.tar.bz2
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
tar xvjpf stage3-*.tar.bz2
# Make the appropriate edits.
</syntaxhighlight>
# Again for some seinsible defaults, I've got:
 
# CFLAGS="-march=native -O2 -pipe -fomit-frame-pointer"
<li>
# CXXFLAGS="${CFLAGS}"
Make the appropriate edits to CFLAGS in /etc/portage/make.conf
# CHOST="x86_64-pc-linux-gnu"
Read the guide at http://wiki.gentoo.org/wiki/CFLAGS for  
# MAKEOPTS="-j2"
Make your own decision, but I've got:
nano /mnt/gentoo/etc/portage/make.conf
<syntaxhighlight>
mirrorselect -i -o >> /mnt/gentoo/etc/portage/make.conf
CFLAGS="-march=corei7 -O2 -pipe -fomit-frame-pointer", but make your own decision.
mirrorselect -i -r -o >> /mnt/gentoo/etc/portage/make.conf
</syntaxhighlight>
</li>
 
<li>
Make the appropriate edits to MAKEOPTS in /etc/portage/make.conf.
Make your own decision based on what virtual hardware you have, but I've got 1 core, so have got:
<syntaxhighlight>
"MAKEOPTS="-j2"
</syntaxhighlight>
</li>
 
<li>
Mirror select isn't available in the rescue environment, so here are a couple of good example for the SYNC and GENTOO_MIRRRORS to paste into /etc/portage/make.conf:
<syntaxhighlight>
SYNC="rsync://rsync.uk.gentoo.org/gentoo-portage"
GENTOO_MIRRORS="http://gentoo.virginmedia.com http://www.mirrorservice.org/sites/www.ibiblio.org/gentoo http://mirror.bytemark.co.uk/gentoo http://mirror.qubenet.net/gentoo"
</syntaxhighlight>
</li>
 
<li>
Setup the virtual environment, and chroot in
<syntaxhighlight>
cp -L /etc/resolv.conf /mnt/gentoo/etc/
cp -L /etc/resolv.conf /mnt/gentoo/etc/
mount -t proc none /mnt/gentoo/proc
mount -t proc none /mnt/gentoo/proc
Line 113: Line 133:
source /etc/profile
source /etc/profile
export PS1="(chroot) $PS1"
export PS1="(chroot) $PS1"
</syntaxhighlight>
</li>
<li>
Update Gentoo
<syntaxhighlight>
emerge-webrsync
emerge-webrsync
emerge --sync
emerge --sync
# Read the news. This stuff is useful, and should be read.
</syntaxhighlight>
Read the news. This stuff is useful, and should be read.
<syntaxhighlight>
eselect news read
eselect news read
# Look at the profile list. I'm sticking with a "server" install, the default.
</syntaxhighlight>
</li>
 
<li>
Basic setup
Look at the profile list. I'm sticking with a "server" install, the default.
<syntaxhighlight>
eselect profile list
eselect profile list
# Make any changes to the USE variable. I chose to leave it as is for now.
</syntaxhighlight>
Make any changes to the USE variable. I chose to leave it as is for now.
<syntaxhighlight>
nano -w /etc/portage/make.conf
nano -w /etc/portage/make.conf
# I'm in the UK. Change accordingly.
</syntaxhighlight>
I'm in the UK. Change accordingly.
<syntaxhighlight>
cp /usr/share/zoneinfo/Europe/London /etc/localtime
cp /usr/share/zoneinfo/Europe/London /etc/localtime
echo "Europe/London" > /etc/timezone
echo "Europe/London" > /etc/timezone
# I like gentoo-sources. You can go with vanilla-sources if you wish, there are others too.
</syntaxhighlight>
I like gentoo-sources. You can go with vanilla-sources if you wish, there are others too.
<syntaxhighlight>
emerge gentoo-sources
emerge gentoo-sources
</syntaxhighlight>
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.
<syntaxhighlight>
cd /usr/src/linux
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 menuconfig
make && make modules_install
make && make modules_install
cp arch/x86_64/boot/bzImage /boot/vmlinuz
cp arch/x86_64/boot/bzImage /boot/vmlinuz
# Edit your fstab. Mine is below:
</syntaxhighlight>
nano -w /etc/fstab
Edit your /etc/fstab. Mine is below:
#/dev/xvda1             /boot          ext4            noatime        1 2
<syntaxhighlight>
#/dev/xvda2             /              ext4            noatime        1 1
/dev/xvda1              /              ext4            noatime        1 1
#/dev/xvdb1              none            swap            sw              0 0
/dev/xvdb1              none            swap            sw              0 0
# Edit your hostname.
</syntaxhighlight>
Edit your hostname.
<syntaxhighlight>
nano -w /etc/conf.d/hostname
nano -w /etc/conf.d/hostname
# Edit your network settings. Mine is below (change your numbers! run ifconfig -a to get them):
</syntaxhighlight>
nano -w /etc/conf.d/net
Edit your network settings in /etc/conf.d/net. Mine is below (change your numbers! run ifconfig -a to get them):
#config_eth0="XXX.XXX.XXX.XXX netmask XXX.XXX.XXX.XXX brd XXX.XXX.XXX"
<syntaxhighlight>
#routes_eth0="default via XXX.XXX.XXX.XXX"
config_eth0="XXX.XXX.XXX.XXX netmask XXX.XXX.XXX.XXX brd XXX.XXX.XXX"
# Add hosts for your hostname.
routes_eth0="default via XXX.XXX.XXX.XXX"
nano -w /etc/hosts
</syntaxhighlight>
# Change the root password
Change the root password
<syntaxhighlight>
passwd
passwd
# Modify your RC to suite. Set rc_sys="xenU"
</syntaxhighlight>
nano -w /etc/rc.conf
Modify /etc/rc,conf - set:
# Modify your keymap (for completeness, you'll never be at the actual keyboard)
<syntaxhighlight>
nano -w /etc/conf.d/keymaps
rc_sys="xenU"
# I didn't change the clock settings, but have a look
</syntaxhighlight>
nano -w /etc/conf.d/hwclock
If you only want a certain language, you can configure it in /etc/locale.gen:
# If you only want a certain language, you can configure it in /etc/locale.gen.
<syntaxhighlight>
nano -w /etc/locale.gen
en_GB ISO-8859-1
en_GB.UTF-8 UTF-8
</syntaxhighlight>
If you do change locales, you need to run:
<syntaxhighlight>
locale-gen
locale-gen
# Setup your env language:
</syntaxhighlight>
nano -w /etc/env.d/02locale
Setup your env language in /etc/env.d/02locale
# Load the languages
<syntaxhighlight>
LANG="en_GB.UTF-8"
LC_COLLATE="C"
</syntaxhighlight>
And update the environment:
<syntaxhighlight>
env-update && source /etc/profile
env-update && source /etc/profile
</syntaxhighlight>
</li>


# Optional choices here. I went with the gentoo choices of syslog-ng for syslog,
</li>
#      vixie-cron for cron and installing mlocate.
Optional choices
I went with the gentoo choices of syslog-ng for syslog, vixie-cron for cron and installing mlocate.
You decide.
<syntaxhighlight>
emerge syslog-ng
emerge syslog-ng
rc-update add syslog-ng default
rc-update add syslog-ng default
Line 168: Line 227:
rc-update add vixie-cron default
rc-update add vixie-cron default
emerge mlocate
emerge mlocate
# Guess we want ssh on startup.....
</syntaxhighlight>
Guess we want ssh on startup.....
<syntaxhighlight>
rc-update add sshd default
rc-update add sshd default
</syntaxhighlight>
</li>


# Bootloader. I tried grub2, but it wasn't happy. So I went with grub-legacy,
<li>
# and even that was tricky.
Bootlader.
emerge sys-boot/grub:0
Grub isn't needed. you only need a grub.conf
nano -w /boot/grub/grub.conf
<syntaxhighlight>
# Here's mine. I'm not too worried about backup kernels, because we have the rescue environment.
mkdir -p /boot/grub
#default 0
</syntaxhighlight>
#timeout 0
Here's by grub.conf:
#
<syntaxhighlight>
#title Gentoo Linux
default 0
#root (hd0,0)
timeout 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
title Gentoo Linux
grub> root (hd0,0)   (Specify where your /boot partition resides)
root (hd0,0)
grub> setup (hd0)    (Install GRUB in the MBR)
kernel /boot/vmlinuz root=/dev/xvda2
grub> quit            (Exit the GRUB shell)
</syntaxhighlight>
 
</li>
# All done! Unmount and reboot, and cross fingers! Give it a minute to boot, and then you should
be able to ssh in!


<li>
All done!
Unmount and reboot, and cross fingers! Give it a minute to boot, and then you should be able to ssh in!
<syntaxhighlight>
exit
exit
cd
cd
Line 201: Line 260:
umount -l /mnt/gentoo{/boot,/proc,}
umount -l /mnt/gentoo{/boot,/proc,}
reboot
reboot
# Don't panic if it doesn't work. You can start the rescue environment again,
</syntaxhighlight>
# mount the disks, and work out what went wrong.
</li>
 
</ol>
# GOOD LUCK!


</syntaxhighlight>
==Finally==
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!

Revision as of 10:27, 29 November 2013

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


Warning Warning: This guide is currently a work in progress. You should not expect it to work or be correct. Please see the discussion page for some areas where it might be improved.


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"

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.

    As this is a VPS, we don't really need a /boot partition, so just create 1 partition 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 root /dev/xvdb1
  5. mkswap -L swap /dev/xvdb1
    LABEL=swap, UUID=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Install

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.

  1. Make dirs and mount
  2. mkdir /mnt/gentoo
    mount /dev/xvda2 /mnt/gentoo/                                              
    mkdir /mnt/gentoo/boot
    mount /dev/xvda1 /mnt/gentoo/boot
  3. Grab the source code and extract. Change the URL to match current version and arch
  4. 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
  5. Make the appropriate edits to CFLAGS in /etc/portage/make.conf Read the guide at http://wiki.gentoo.org/wiki/CFLAGS for Make your own decision, but I've got:
    CFLAGS="-march=corei7 -O2 -pipe -fomit-frame-pointer", but make your own decision.
  6. Make the appropriate edits to MAKEOPTS in /etc/portage/make.conf. Make your own decision based on what virtual hardware you have, but I've got 1 core, so have got:
    "MAKEOPTS="-j2"
  7. Mirror select isn't available in the rescue environment, so here are a couple of good example for the SYNC and GENTOO_MIRRRORS to paste into /etc/portage/make.conf:
    SYNC="rsync://rsync.uk.gentoo.org/gentoo-portage"
    GENTOO_MIRRORS="http://gentoo.virginmedia.com http://www.mirrorservice.org/sites/www.ibiblio.org/gentoo http://mirror.bytemark.co.uk/gentoo http://mirror.qubenet.net/gentoo"
  8. Setup the virtual environment, and chroot in
    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"
  9. Update Gentoo
    emerge-webrsync
    emerge --sync

    Read the news. This stuff is useful, and should be read.

    eselect news read
  10. Basic setup 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

    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.

    cd /usr/src/linux
    make menuconfig
    make && make modules_install
    cp arch/x86_64/boot/bzImage /boot/vmlinuz

    Edit your /etc/fstab. Mine is below:

    /dev/xvda1              /               ext4            noatime         1 1
    /dev/xvdb1              none            swap            sw              0 0

    Edit your hostname.

    nano -w /etc/conf.d/hostname

    Edit your network settings in /etc/conf.d/net. Mine is below (change your numbers! run ifconfig -a to get them):

    config_eth0="XXX.XXX.XXX.XXX netmask XXX.XXX.XXX.XXX brd XXX.XXX.XXX"
    routes_eth0="default via XXX.XXX.XXX.XXX"

    Change the root password

    passwd

    Modify /etc/rc,conf - set:

    rc_sys="xenU"

    If you only want a certain language, you can configure it in /etc/locale.gen:

    en_GB ISO-8859-1
    en_GB.UTF-8 UTF-8

    If you do change locales, you need to run:

    locale-gen

    Setup your env language in /etc/env.d/02locale

    LANG="en_GB.UTF-8"
    LC_COLLATE="C"

    And update the environment:

    env-update && source /etc/profile
  11. Optional choices I went with the gentoo choices of syslog-ng for syslog, vixie-cron for cron and installing mlocate. You decide.
    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
  12. Bootlader. Grub isn't needed. you only need a grub.conf
    mkdir -p /boot/grub

    Here's by grub.conf:

    default 0
    timeout 0
    
    title Gentoo Linux
    root (hd0,0)
    kernel /boot/vmlinuz root=/dev/xvda2
  13. 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

Finally

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!