[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Chrooted Debian install from base image (was Re: Instalation question: Toshiba TECRA 8000)



This is a draft of a HOWTO I'm working on for doing a chrooted Debian 
install.  It's a method I've found useful over the years.

I'm requesting feedback on this essay, there are a few points that need
additional information (search 'FIXME').  If someone wants to try
following these procedures and reporting back on what works, let me
know.

The one component I _don't_ address here is module configuration for
support of networking, sound, etc.  Not sure how best to deal with this.


on Mon, Apr 01, 2002, David A. Sakmar (dsakmar@kent.edu) wrote:
> Hello,
> 
> I just recently came into the posesion of a toshiba tecra 8000 and
> have been having some trouble installing Dabian on it.  I have been
> trying my old stack of bootable CD's and so far the only ditro I have
> been able to get to boot off the CD is Redhat 6.2(7.1 and 7.2 both
> don't boot either).  If anyone has any suggestions on how I could get
> a Debian CD to install on this laptop I would apreciate the input.

As an alternative, it's possible to bypass the installation CD using one
of several other methods of getting a base image onto the system.

I've been meaning to document this procedure anyway, so here's a crack
at it.  Suggestions welcome.  Some of this is based on prior discussion
between myself and Joey Hess on debian-user here:

  http://lists.debian.org/debian-user/2002/debian-user-200202/msg03033.html
  http://lists.debian.org/debian-user/2002/debian-user-200202/msg03038.html



	Performing A chroot Debian Install From A Booted System
	-------------------------------------------------------

The goal is to end up with an upacked tarball of the base system on a
partition, with a working, bootable, kernel, and networking, from which
additional configuration may be performed.  The means:

  1. Booting some other OS on the system. 
  2. Partitioning the system as desired.
  3. Getting the base system copied over.
  4. Unpacking it.
  5. Chrooting into it.
  6. Completing installation tasks.
  7. Converting to journaled filesystems.
  8. Further OS package installs.

My preferences for bootable systems are Tom's Root Boot (TRB) and the
LNX-BBC bootable GNU/Linux Business Card (LNX-BBC):

  - http://www.toms.net/rb/
  - http://www.lxn-bbc.org/

TRB is 1.7 MiB of GNU/Linux and utilities.  It's pretty minimal, but can
get you a consol, and usually networking, on a system.  As it runs in a
RAMdisk, you can modify all the underlying storage.  You can also create
up to 13 additional RAMdisks of 4 MiB each (TRB itself runs in three),
for a total of 52 MiB storage (memory permitting).

LNX-BBC is far more capable, packing about 110 MiB of utilities,
including an X server, web browsers, games, and more, onto a
small-format CDROM.


If you already have an OS installed on the system (and better:  a
GNU/Linux system), you may also be able to use it to assist you.

The advantage to this method is that you're working in a chrooted
environment.  Outside this "chroot jail", you've got a fully capable
GNU/Linux system -- more so if you're using the LNX-BBC or an existing
install.  Once you've got the new Debian system configured to your
preference, you can migrate your existing user data (if any) to it, and
keep on rolling.  Thus it's a "zero downtime" GNU/Linux install.  Also a
damned good way for dealing with hardware that otherwise doesn't play
friendly with various boot or installation media.

It helps greatly to have a network-accessible live GNU/Linux system
available, or better, a physically accessible one if you need to do a
floppy-based transfer.



Getting Started
---------------

In either case, boot whichever works.  If you're going to repartition
the hard drive, do it now.  My suggestions on partitioning may be found
at:

    http://kmself.home.netcom.com/Linux/FAQs/partition.html

Create ext2 filesystems (Potato doesn't support ext3fs or reiserfs out
of the box, more later), and a swap partition, as needed.

I _strongly_ recommend creating at least two filesystems, plus swap,
You'll use one of these filesystems as the locate for saving the base
image tarball prior to unpacking it.  Mount one partition as
/mnt/debinst (the installation point, to be the root (/) filesystem on
your new system) and the other as /mnt/utility (the names are strictly
arbitrary, but I'll refer to them as such for the remainder of this
document).

My preference is for separate partitions, in order of preference for
creation: /, swap, /boot, /usr, /home, /tmp, /var, and /usr/local.  If
not created as partitions, I prefer putting /tmp and /var as symlinks to
/usr/tmp and /usr/var.

Mount two of your partitions to /mnt/debinst and /mnt/utility.  While
you're at it, make sure a /mnt/floppy directory exists. 



Transferring The Base Image
---------------------------

Transfer the base image tarball to the system.  If you can get
networking configured under your install system (e.g.:  TRB, LNX-BBC),
this is your best bet.  It may be possible to configure a laplink
connection, but I find this to be tempermental, uneven, and usually
unsuccessful endeavor.  You're likely better off schlepping floppies
between the two systems.  If you use two floppies, you can write one
while reading the other.  The transfer takes about 11 disks.

The base image itself is found here:

http://http.us.debian.org/debian/dists/potato/main/disks-i386/current/base2_2.tgz 

You can use 'split', 'cp', and 'cat' to split up, transfer, and
recombine the tarball.

On the source system:

    $ split -b 1440K base2_2.tgz base2_2.tgz-

    # This will copy each fragment to a floppy disk without your having
    # to type each filename.  It will *DELETE* the contents of the disk.
    # You may need root permissions to run this.
    # This won't make up for you hitting '<return>' at the wrong time,
    # so stay sharp.
    $ for file in base2_2.tgz-*; 
    do 
        echo -e "Insert floppy and hit <return> \c"
	read ans
	mount /mnt/floppy
	rm /mnt/floppy/*
	cp $file /mnt/floppy
	umount /mnt/floppy
	echo -e "\aRemove floppy\n"
     done
     echo "Completed"

On the target side, things are easier, type <ctrl>-C when done.  You may
need to create the /mnt/floppy mountpoint.  Run this from where you want
the bits to land.  Again, I'd suggest you create _at least_ two
partitions, a place to install the base (at least 40 MiB, 64 MiB is
generally sufficient), and a place to unpack the tarball (at least 20
MiB).

     cd /mnt/utility
     $ while :
     do
         mount -t auto /dev/fd0 /mnt/floppy
	 cp /mnt/floppy/* .
	 umount /mnt/floppy
     done

...when the above has completed, on the target system:

    $ cat base2_2.tgz-* > base2_2.tgz

    # You're done with the pieces:
    $ rm base2_2.tgz-*

    # Change to the installation root and unpack:
    $ cd /mnt/debinst
    # TRB's tar doesn't handle gzipped archives natively...
    $ zcat < /mnt/utility/base2_2.tgz | tar xvf



Configuring The Base System
------------------------------

You've now got a real Debian system, though rather lean, on disk.
Chroot into it:

    $ chroot . bin/bash

OK.  You've got a few things to configure that would ordinarially be
handled by the installed (dbootstrap):

   - keyboard
   - language
   - time zone
   - partitioning
   - networking
    
You've already dealt with partitioning.  I'll assume you've got
networking handled through your boot system, though we'll try to address
this in the chroot install as well.

You've already partitioned your system, so no need to revisit this.  So,
you need to configure your keyboard, language, timezone, and networking.
I'm not sure about language (locales?), and we'll get to networking.
For the rest:

   # Keyboard.
   $ dpkg-reconfigure console-data

   # Time zone
   $ tzconfig

For the remainder of the system configuration, run:

   $ dpkg-reconfigure base-config

   (You may have to run 'dpkg --install --reinstall base-config' instead
   to force this).

You still likely don't have networking configured.  This requires hand
edits of:

   - /etc/network/interfaces  -- see /usr/share/doc/ifupdown/examples for
     examples.  This configures your interfaces.  In general, you need
     to know your IP, network, netmask, network, broadcast, and gateway.

   - /etc/resolv.conf -- your nameserver(s) and search directives go
     here.

   - /etc/hostname -- your system's host name -- 2 - 63 characters.
   
And, if the system hasn't already prompted you, set up a nonpriviledged
user account:

    $ adduser <username>	# ...and follow prompts.
    $ passwd <username>

OK, now, munge /etc/apt/sources.list to your preference.  If you want to
run a 'testing' or 'unstable' system, you can make this switch now.
After the edits (and setting the $http_proxy environment variable if
necessary:

    $ apt-get update
    $ apt-get dist-upgrade

...will update your system.

I'd suggest a set of packages which I like installed in all instances:

   $ apt-get install aptitude w3m screen ssh lftp vim gpw 

You probably want a Linux kernel and a bootloader.  I've become partial
to GRUB these days, though LILO's an old standard.  'apt-get install'
for your preferences.

Reboot to confirm your settings.  If your system doesn't come up, you've
got your boot disk (TRB/LNX-BBC) to salvage you.  Chroot into the
installation and try again.



After Rebooting -- FS Conversions
---------------------------------

Once your system is booted, you can try converting to a journaling
filesystem if you prefer -- e.g.:  ext3fs, reiserfs.  I recommend ext3fs
on filesystems < 150-200 MiB, and reiserfs above this value.  Reiserfs
is unsuited to small partitions due to the fixed size of its 32 MiB
journal file.  Its benefits are somewhat limited on small filesystems
anyway, so ext3fs /boot, /, and /tmp are generally recommended.  For
large partitions, reiserfs offers some performance benefits,
particularly for directories with many files.

For ext3fs, there's no major hassle.  Make sure your kernel supports
ext3fs, and run for each partition:

    $ tune2fs -j /dev/<partition>

...you may also want to set the '-c' (mounts between fs checks) or '-i'
(interval between fs checks) options, and possibly the '-m' (reserved
blocks percentage) options.  FIXME:  recommended values?

For ext3fs, the solution is a dance called the reiserfs shuffle:

  - tar the partition to be converted to altnernate storage (if you've
    created a fair number of partitions, you can "park" it elsewhere --
    e.g.:  /home or /usr, usually).  For /usr, archived to /home:
     
     $ tar czvf /home/usr.tar.gz /usr

    ...and verify:

     $ tar tzvf /home/usr.tar.gz

   ...the exit value ($?) should be 0.

  - Create reiserfs:

     $ mkreiserfs /home/usr.tar.gz

  - Unpack the archive to the target:

     $ cd /
     $ tar xzvf /home/usr.tar.gz

...repeat for each partition, and you're set.



Further Configuration and Package Installs
------------------------------------------

From here, you can build out the system by:

  - Schlep in a package list from another source that you'd like to run:

      # On other box:
      $ dpkg --get-selections > file
      $ $EDIT file

      # Transfer file to your new system (floppy, network, carrier
      # pigeon, whatever).

      $ dpkg --set-selections < file

      # In theory, the following works, though I had to kick it a few
      # times to make it go right:

      $ apt-get dist-upgrade		# This should work.
      $ apt-get dselect-upgrade		# This is what I ended up using.

    FIXME:  ...can someone straighten me out on this?

  - Run aptitude (far more intuitive than dselect IMVAO), and pick
    packages.

  - Pick and install packages in onesies-twosies from the command line
    with 'apt-get install foo'.

  - Other method of your choosing.


Credits  
-------

Thanks to:

  - Rob Walker, formerly of VA (Research|Linux|Software), who inspired
    the original concept when he mentioned how the Debian project was
    being supported under a chroot shell on a Red Hat box at VA, leading
    to my initial investigation of chroot installs.

  - Tom Oehser, author of Tom's Root Boot, for saving my ass more times
    than I can recall, and giving us a really useful 1.7 MiB of
    sweetness.  http://www.toms.net/rb/

  - Seth Schoen, Duncan MacKinnon, Nick Moffitt, and others, for the
    LNX-BBC project.  http://www.lnx-bbc.org/

  - Joey Hess for the base-config tip, among many others.


----------------------------------------

Any questions / answers / comments / suggestions?

Peace.

-- 
Karsten M. Self <kmself@ix.netcom.com>           http://kmself.home.netcom.com/
 What Part of "Gestalt" don't you understand?
   A guide to GNU/Linux browsers:
     http://kmself.home.netcom.com/FAQs/browsers.html

Attachment: pgpR1EcCjanZi.pgp
Description: PGP signature


Reply to: