Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
What would you do with this old puppy?
View unanswered posts
View posts from last 24 hours

Goto page Previous  1, 2  
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
timeBandit
Bodhisattva
Bodhisattva


Joined: 31 Dec 2004
Posts: 2719
Location: here, there or in transit

PostPosted: Wed Dec 06, 2006 4:29 am    Post subject: Reply with quote

Caution: Despite appearances, these instructions may be incomplete or slightly inaccurate.

I did this well over a year ago, using the then-current Stage 1/2/3 install process and an equally old baselayout. It's a bit out of date now so adjustments are necessary if you try this (locations of config files, mostly). I plan to bring this up to date as soon as time permits. Until then, don't trust this blindly--use your head. :wink:

Here we go. When reading the code transcripts, it helps to remember:
  • The build host machine is named fastbox.
  • The target becomes smallbox.

PART I -- HOST MACHINE
Step 0 - emerge sync
Before anything else, Portage on the host machine MUST BE up to date and in sync with the Stage 1 tarball. emerge sync and download a fresh tarball or LiveCD ISO (not shown). I had the ISO on hand because I'd tried that route first, and a boot CD is needed at some point anyway. So unless you already have a Gentoo boot CD handy, now is a good time to get one.

Clean out Portage temp files before you start--it avoids some odd emerge problems.
Code:
fastbox root # cd /var/tmp/portage
fastbox portage # rm -rf *

Step 1 - Create an incubator
I chose a location under /home because it fit my sensibilities for long-term use, and that partition is huge on my host PC. It can go anywhere you have at least a gigabyte free.
Code:
fastbox portage # cd /home
fastbox home # mkdir micron          ## I was rebuilding an old Micron PC
fastbox home # chgrp users micron/
fastbox home # chmod g+rx micron/
fastbox home # cd micron
fastbox micron # mkdir gentoo

Step 2 - Unpack Stage 1 tarball
I built my machine with loopback devices so I just mounted the ISO file directly. If you didn't configure loopback support on your host, you'll have to burn a CD. I made a mount point (cdrom) alongside the incubator so I wouldn't tie up my normal CD mount point during this job.
Code:
fastbox micron # cd gentoo
fastbox gentoo # mkdir etc boot
fastbox gentoo # cd ..
fastbox micron # mkdir cdrom
fastbox micron # mount -t iso9660 -o loop ~ron/download/patches/install-x86-universal-2004.3.iso ./cdrom
fastbox micron # ls cdrom/stages/
stage1-x86-2004.3.tar.bz2            stage3-pentium3-2004.3.tar.bz2
stage1-x86-2004.3.tar.bz2.md5        stage3-pentium3-2004.3.tar.bz2.md5
   ... more ...
fastbox micron # cd gentoo
fastbox gentoo # tar xjvpf ../cdrom/stages/stage1-x86-2004.3.tar.bz2
   ###  ... much noise ...

Step 3 - Bind the Portage tree into the incubator
Note that I keep my distfiles outside the /usr filesystem (long story)--you wouldn't have that extra mount (unless you did the same). I've shown it so I don't have to remember to edit it out everywhere it appears. :-)
Code:
fastbox gentoo # mkdir ./usr/portage
fastbox gentoo # mount --bind /usr/portage ./usr/portage
fastbox gentoo # mount --bind /home/portage/distfiles ./usr/portage/distfiles
fastbox gentoo # mount --bind /var/tmp ./var/tmp
fastbox gentoo # mount
      ### ... only showing the important mounts:
/home/ron/download/patches/install-x86-universal-2004.3.iso on /home/micron/cdrom type iso9660 (rw,loop=/dev/loop0)
/usr/portage on /home/micron/gentoo/usr/portage type none (rw,bind)
/home/portage/distfiles on /home/micron/gentoo/usr/portage/distfiles type none (rw,bind)
/var/tmp on /home/micron/gentoo/var/tmp type none (rw,bind)

Step 4 - Configure resolver and Portage for TARGET system
Use the same nameserver and mirrors as the host. Set up make.conf as appropriate for the target. Be careful to edit the correct file!
Code:
fastbox gentoo # cp -L /etc/resolv.conf ./etc/resolv.conf
fastbox gentoo # grep "GENTOO_MIRRORS=" /etc/make.conf >>./etc/make.conf
fastbox gentoo # vi ./etc/make.conf

Here are the important settings in my target make.conf. Very lean.
Code:
CFLAGS="-O2 -march=i586 -pipe -fomit-frame-pointer"
CHOST="i586-pc-linux-gnu"
LDFLAGS="-Wl,-O1 -Wl,--no-keep-memory"
USE="X -qt -gnome -kde -arts -avi -f77 -libg++ -mikmod -oggvorbis -opengl -quick
time -xmms -xv"

Step 5 - Start the incubator (chroot)
The /boot partition must be mounted or emerge grub will fail. It won't be modified because you'll be in chroot jail, but it must be mounted.
Code:
fastbox gentoo # mount -t proc none ./proc
fastbox gentoo # mount /boot
fastbox gentoo # chroot /home/micron/gentoo /bin/bash
fastbox / # env-update
>>> Regenerating /etc/ld.so.cache...
fastbox / # source /etc/profile

Step 6 - Configure locales for glibc
This is extremely important on a space-constrained system. If you tell glibc to build only those locales you will actually use, you save tens of megabytes. I leave it to you to discover the locale names you need. :)
Code:
fastbox / # echo "sys-libs/glibc userlocales" >> /etc/portage/package.use
fastbox / # rm /etc/locales.build
fastbox / # touch /etc/locales.build
fastbox / # echo "en_US/ISO-8859-1" >>/etc/locales.build
fastbox / # echo "en_US.UTF-8/UTF-8" >>/etc/locales.build

Step 7 - Bootstrap
From this point on, until the fledgling system is ready for the target PC, it's a fairly standard Gentoo Stage 1 install.
Bootstrap Stage 1 to Stage 2...
Code:
fastbox / # cd /usr/portage
fastbox portage # scripts/bootstrap.sh -f
fastbox portage # scripts/bootstrap.sh

...and Stage 2 to Stage 3. When finished, set time zone.
Code:
fastbox portage # emerge --fetchonly system
fastbox portage # emerge system
fastbox portage # ln -sf /usr/share/zoneinfo/EST5EDT /etc/localtime

During this process I always performed separate fetch and build operations. It's not necessary, but it gave me peace of mind that any problem at my ISP could not interrupt a long-running build.

Step 8 - Build Kernel
Choice and configuration of a kernel is of course up to you, but don't forget to enable NFS support!
Code:
fastbox portage # cd /root
fastbox root # emerge gentoo-dev-sources
fastbox root # cd /usr/src/linux
fastbox linux # make menuconfig
fastbox linux # cp .config /boot/config-2.6.9-gentoo-r4
fastbox linux # make && make modules_install
fastbox linux # cp arch/i386/boot/bzImage /boot/kernel-2.6.9-gentoo-r4
fastbox linux # cp System.map /boot/System.map-2.6.9-gentoo-r4
fastbox linux # ln -s /boot/System.map-2.6.9-gentoo-r4 /boot/System.map

Remember you're still in a chroot shell, so copying the kernel to /boot does not affect the host machine. At the moment, /boot is just a directory in the incubator.
If it helps, these are the NFS kernel options (that I can remember...) from my config:
Code:
CONFIG_LOCKD=m
CONFIG_SUNRPC=m
CONFIG_NFS_FS=m
CONFIG_NFS_V3=y
CONFIG_NFSD=m
CONFIG_NFSD_V3=y
CONFIG_NFSD_TCP=y

Step 9 - Configure kernel modules
Don't forget NFS, if you compiled it as a module (the module name is 'nfs').
Code:
fastbox linux # nano -w /etc/modules.autoload.d/kernel-2.6
fastbox linux # modules-update

Step 10 - Core config: filesystems, networking, basic services
Standard Gentoo stuff...no point in showing my files because yours will differ.
Code:
fastbox root # nano -w /etc/fstab
fastbox root # echo smallbox >/etc/hostname
fastbox root # echo localdomain >/etc/dnsdomainname
fastbox root # rc-update add domainname default
 * domainname added to runlevel default
 * Caching service dependencies...
 * rc-update complete.
fastbox root # nano -w /etc/conf.d/net
fastbox root # rc-update add net.eth0 default
 * net.eth0 added to runlevel default
 * Caching service dependencies...
 * rc-update complete.
fastbox root # nano -w /etc/hosts
fastbox root # nano -w /etc/rc.conf
fastbox root # passwd
New UNIX password:
Retype new UNIX password:
passwd: password updated successfully

Step 11 - Install/configure logger, cron and bootloader
More standard stuff. Choose your own favorites.
Code:
fastbox root # emerge syslog-ng
fastbox root # rc-update add syslog-ng default
 * syslog-ng added to runlevel default
 * Caching service dependencies...
 * rc-update complete.
fastbox root # emerge vixie-cron
fastbox root # rc-update add vixie-cron default
 * vixie-cron added to runlevel default
 * Caching service dependencies...
 * rc-update complete.
fastbox root # emerge grub
fastbox root # nano -w /boot/grub/grub.conf

Step 12 - Set up udev and NFS
As it happened, I can't use udev yet because it doesn't recognize my tape drive. But, at least it's here for that distant day when I feel ambitious. :-) We only built kernel support for NFS above--this is the rest of it.
Code:
fastbox root # emerge --fetchonly udev hotplug nfs-utils
fastbox root # emerge udev hotplug nfs-utils
fastbox root # rc-update add hotplug default
 * hotplug added to runlevel default
 * Caching service dependencies...
 * rc-update complete.
fastbox root # nano -w /etc/conf.d/rc

Step 13 - Configure filesystem exports
The easy way is to export the entire filesystem (/). For my own crazy reasons (having to do with partitioning on both machines), I chose to individually export all filesystems except dev, tmp, proc and sys.
Code:
fastbox root # ls / >>/etc/exports
fastbox root # nano -w /etc/exports

The result. Note the no_root_squash option is required! Without it, Portage on the target won't work properly when you mount its filesystems onto the host.
Code:
# /etc/exports: NFS file systems being exported.  See exports(5).

/bin    fastbox(rw,no_root_squash,sync)
/boot   fastbox(rw,no_root_squash,sync)
/etc    fastbox(rw,no_root_squash,sync)
/home   fastbox(rw,no_root_squash,sync)
/lib    fastbox(rw,no_root_squash,sync)
/opt    fastbox(rw,no_root_squash,sync)
/root   fastbox(rw,no_root_squash,sync)
/sbin   fastbox(rw,no_root_squash,sync)
/usr    fastbox(rw,no_root_squash,sync)
/var    fastbox(rw,no_root_squash,sync)

Step 14 - Create a user
The last bit of standard Gentoolery. "ron" in the example is ... me. :D
Code:
fastbox root # useradd -m -G users,wheel -s /bin/bash ron
fastbox root # passwd ron
New UNIX password:
Retype new UNIX password:
passwd: password updated successfully

Step 15 - Exit incubator and create tarball
You're done (with the first part)! The incubator directory on the host now contains a complete, bootable Gentoo system for the target PC. All that remains is to get it onto the target, and install grub/lilo to the MBR. Exit the chroot environment and make a tarball of the incubated system.
Important: use the -l option to constrain tar to one filesystem. This leaves the Portage tree out of the tarball and off the target--the whole point of this exercise.
Code:
fastbox root # exit
fastbox gentoo # umount ./proc
fastbox gentoo # tar cjlvf ../gentoo-system.tbz2 .


PART II -- TARGET MACHINE
Step 1 - Prepare disks
Boot the target machine from a LiveCD and create partitions & filesystems as you desire. This is how mine looks (note the "tiny" disk: 1.2GB!):
Code:
## /dev/hda1   32MB   ext2   /boot
## /dev/hda2   96MB   swap
## /dev/hda3   1.1GB   ext2   /
##
livecd root # mount /dev/hda3 /mnt/gentoo
livecd root # mount /dev/hda1 /mnt/gentoo/boot
livecd root # swapon /dev/hda2

Step 2 - Configure networking
First, you need to change the root password because the LiveCD sets a random one.
Code:
livecd root # passwd
New UNIX password:
Retype new UNIX password:
passwd: password updated successfully
livecd root # net-setup eth0
livecd root # nano -w /etc/hosts

That last step is essential: You must make two entries in /etc/hosts, for the host and target. Example:
Code:
192.168.1.100     fastbox
192.168.1.50      livecd
IMPORTANT: Notice the target's hostname is livecd at this point. That's the name you must use--don't use the hostname you built into the tarball yet!

Step 3 - Prepare for remote installation
Start the SSH service and create a user who can become root. Not necessary I guess, but it seems I was being thorough that day. :)
Code:
livecd root # /etc/init.d/sshd start
livecd root # useradd -m -G users,wheel ron
livecd root # passwd ron
New UNIX password:
Retype new UNIX password:
passwd: password updated successfully
livecd root # su - ron
ron@livecd ron $ clear

...And then walk away.

PART III -- FINAL INSTALLATION from host machine
Step 1 - Deliver tarball to target
Using the secure FTP subsystem of SSH, login to the target from your host machine and ship the tarball over. (EDIT: If you're really space-constrained on the target, you can combine this with the next step: stream the tarball through ssh and unpack in one step, saving 100MB+. This didn't occur to me at the time.)
Code:
ron@fastbox micron $ sftp root@smallbox
Connecting to smallbox...
Password:
sftp> cd /mnt/gentoo
sftp> put gentoo-system.tbz2
Uploading gentoo-system.tbz2 to /mnt/gentoo/gentoo-system.tbz2
gentoo-system.tbz2                                 100%  139MB 762.6KB/s   03:07
sftp> quit

Step 2 - Unpack incubated system
Connect to the LiveCD-booted target, unpack and remove the tarball just delivered.
Code:
ron@fastbox micron $ ssh smallbox
The authenticity of host 'smallbox (192.168.1.50)' can't be established.
RSA key fingerprint is 3e:07:8d:97:c1:38:da:3c:22:31:d6:94:94:bf:39:d9.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'smallbox,192.168.1.50' (RSA) to the list of known hosts.
Password:

Welcome to the Gentoo Linux Minimal Installation LiveCD!

The root password on this system has been auto-scrambled for security.

If any ethernet adapters were detected at boot, they should be auto-configured
if DHCP is available on your network.

Type "net-setup eth0" to specify eth0 IP address settings by hand.

/proc/config(.gz) for kernel configuration.

ron@livecd ron $ su -
Password:
livecd root # cd /mnt/gentoo
livecd gentoo # tar xjvpf gentoo-system.tbz2
   ### ... much noise ...
livecd gentoo # rm gentoo-system.tbz2
rm: remove regular file `gentoo-system.tbz2'? y

Step 3 - Install bootloader
Here again, standard install stuff--just by remote this time. After configuring grub.conf (or lilo if that's your style) ... you're done!
Code:
livecd gentoo # mount -t proc none ./proc
livecd gentoo # chroot /mnt/gentoo /bin/bash
livecd / # env-update
>>> Regenerating /etc/ld.so.cache...
 * Caching service dependencies...
livecd / # source /etc/profile
livecd / # grub
   grub> root (hd0,0)
   grub> setup (hd0)
   grub> quit
livecd / # nano -w /boot/grub/grub.conf

Step 4 - Activate remote services
This is the final step to prepare the target machine to boot entirely on its own.
Code:
livecd / # rc-update add portmap default                 
livecd / # rc-update add nfs default
livecd / # rc-update add netmount default
livecd / # rc-update add sshd default

Afterward, exit the chroot shell and prepare for a reboot. (You could also issue the umount commands at the console of the target machine.)
Code:
livecd / # exit
livecd gentoo # umount ./proc
livecd gentoo # umount ./boot
livecd gentoo # cd /root
livecd root # umount /mnt/gentoo
livecd root # exit

Step 5 - Reboot target!
Back at the target console:
Code:
ron@livecd ron $ exit
livecd root # reboot

...and watch your new system come to life!

PART IV -- REMOTE ADMINISTRATION of target from host
Step 0 - Prepare NFS mount point (incubator)
The directory that served as the incubator for the initial tarball can now be reused as a mount point for the filesystem(s) exported from the target. But first, the cruft from the initial setup should be cleaned out.
Code:
fastbox micron # cd gentoo
fastbox gentoo # for fs in var usr opt lib etc bin sbin root home boot; do rm -rf ./$fs; done
fastbox micron # cd ..

Step 1 - Mount target & host (portage) filesystems to incubator
Connecting and disconnecting the target is tedious, so I wrote a script (included below) to handle that chore.
Code:
fastbox micron # ./incubator attach
Mounting remote filesystems: var usr opt lib etc bin sbin root home boot
Binding host Portage tree into incubator...
Mounting proc filesystem...
Incubator ready.  To use:
        chroot /home/micron/gentoo /bin/bash
        env-update
        source /etc/profile
fastbox micron # chroot /home/micron/gentoo /bin/bash
fastbox / # env-update
>>> Regenerating /etc/ld.so.cache...
 * Caching service dependencies...
fastbox / # source /etc/profile

Step 2 - Install/remove packages
Use portage as usual. The portage tree, including distfiles, remains on the host machine. The installed package database, logs, and so on are maintained on the target. Beauty. 8) By way of example, these are the packages I added to my little server.
Code:
fastbox / # emerge --fetchonly mt-st logrotate vi dos2unix unix2dos traceroute ftp netkit-telnetd ntp at lsof lshw whois bind-tools
fastbox / # emerge mt-st logrotate vi dos2unix unix2dos traceroute ftp netkit-telnetd ntp at lsof lshw whois bind-tools

Later I decided to add the X Window System, VNC, and Xfce--and it still fit in under 800MB! 8)

Step 3 - Unmount target system
When you finish a maintenance cycle, exit the chroot shell and disconnect the target mounts.
Code:
fastbox / # exit
fastbox micron # ./incubator detach
Unmounting proc filesystem...
Unbinding host Portage tree...
Unmounting incubator filesystems: var usr opt lib etc bin sbin root home boot
Purging tmp directory...
Incubator shutdown complete.

That's all. :)
Whenever you need to do routine maintenance on the target system, repeat this last part (except step 0).

Here is the script I use to manage the incubator, which you may find useful.
Code:
#!/bin/bash

INCUBATOR=/home/micron/gentoo
TARGET=smallbox
TARGET_EXPORTS="var usr opt lib etc bin sbin root home boot"

function mount_all()
{
   cd $INCUBATOR
   echo -n "Mounting remote filesystems into incubator: "
   for fs in $TARGET_EXPORTS
   do
       echo -n "$fs "
       [ -d ./$fs ] || mkdir ./$fs
       mount -o nolock ${TARGET}:/$fs ./$fs
   done
   echo

   echo Binding host Portage tree into incubator...
   mount --rbind /usr/portage ./usr/portage
   mount --bind /var/tmp ./var/tmp

   echo Mounting proc filesystem...
   mount -t proc none ./proc
}

function umount_all()
{
   cd $INCUBATOR
   echo Unmounting proc filesystem...
   umount ./proc

   echo Unbinding host Portage tree...
   umount -l ./usr/portage
   umount ./var/tmp

   echo -n "Unmounting incubator filesystems: "
   for fs in $TARGET_EXPORTS
   do
      echo -n "$fs "
      umount ./$fs
      [ -d ./$fs ] && rmdir ./$fs
   done
}

function purge_tmp()
{
   cd $INCUBATOR
   echo Purging tmp directory...
   [ -d ./tmp ] && rm -rf ./tmp
   [ -d ./tmp ] || mkdir ./tmp && touch ./tmp/.keep && touch -r ./proc ./tmp
}

##
## Entry point
##
if [ ! -d $INCUBATOR ] ; then
   echo "Incubator ($INCUBATOR) does not exist!"
   quit
fi

ping -c1 $TARGET >/dev/null 2>&1
if [ $? -ne 0 ] ; then
   echo "$TARGET unreachable ... down?"
   quit
fi

CMD=help
if [ $# -eq 1 ] ; then
   CMD=$1
   shift
fi

case $CMD in
   attach)
      mount_all
      echo "Incubator ready.  To use:"
      echo "   chroot $INCUBATOR /bin/bash"
      echo "   env-update && source /etc/profile"
      ;;
   detach)
      umount_all
      echo
      purge_tmp
      echo Incubator shutdown complete.
      ;;
   *)
      echo "Usage: $0 {attach|detach}"
      echo "  attach - mount target ($TARGET) filesystems for remote admin"
      echo "  detach - unmount target filesystems"
      ;;
esac


Note that when I referred to installing X above, it was monolithic X.Org 6.8. I don't know how much larger the 7.x series is on disk. I can't say whether it will still fit in such a small environment, but I expect it should.
_________________
Plants are pithy, brooks tend to babble--I'm content to lie between them.
Super-short f.g.o checklist: Search first, strip comments, mark solved, help others.


Last edited by timeBandit on Mon Apr 27, 2009 6:09 pm; edited 2 times in total
Back to top
View user's profile Send private message
JohnerH
Apprentice
Apprentice


Joined: 01 Mar 2004
Posts: 197
Location: Manchester,United Kingdom

PostPosted: Thu Dec 14, 2006 10:44 am    Post subject: Reply with quote

Goooooooodddd Morning all!!

Well it's official, gentoo's running on this old puppy, I pretty much followed the above guide apart from bits n pieces that I had to manually do to fit my needs,

Let me know if anyone needs me to post it up and I will do...

Again thank you all for the support on this....

Gentoo reigns again!

J
_________________
------------------------------------------------------
I think I had a thought once but it Died of Lonelyness...
Back to top
View user's profile Send private message
jspeybro
Tux's lil' helper
Tux's lil' helper


Joined: 06 Apr 2004
Posts: 121
Location: Brussels

PostPosted: Thu Dec 14, 2006 11:12 am    Post subject: Reply with quote

Hi, I just got a pentium 1 75MHz laptop. I'm going to try to put gentoo on it. So I guess I will try to follow this guide too.

If you have things I should be aware of that are not in the instructions above, I'd like to hear about them.

thanks,

Johan
_________________
http://counter.li.org - Registered Linux user #295636
Back to top
View user's profile Send private message
erik258
Advocate
Advocate


Joined: 12 Apr 2005
Posts: 2650
Location: Twin Cities, Minnesota, USA

PostPosted: Wed Dec 20, 2006 4:13 pm    Post subject: Reply with quote

I highly recommend that everyone using old hardware + new hardware together use crossdev and distcc to make their compilations go many times faster.
_________________
Configuring a Firewall? Try my iptables configuration
LinuxCommando.com is my blog for linux-related scraps and tidbits. Stop by for a visit!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum