Warning: this is an htmlized version!
The original is across this link,
and the conversion rules are here.
#######
#
# E-scripts on making very small Linuxes
#
# Note 1: use the eev command (defined in eev.el) and the
# ee alias (in my .zshrc) to execute parts of this file.
# Executing this file as a whole makes no sense.
#
# Note 2: be VERY careful and make sure you understand what
# you're doing.
#
# Note 3: If you use a shell other than zsh things like |&
# and the for loops may not work.
#
# Note 4: I always run as root.
#
# Note 5: some parts are too old and don't work anymore. Some
# never worked.
#
# Note 6: the definitions for the find-xxxfile commands are on my
# .emacs.
#
# Note 7: if you see a strange command check my .zshrc -- it may
# be defined there as a function or an alias.
#
# Note 8: the sections without dates are always older than the
# sections with dates.
#
# This file is at <http://angg.twu.net/e/yard.e>
#           or at <http://angg.twu.net/e/yard.e.html>.
#        See also <http://angg.twu.net/emacs.html>,
#                 <http://angg.twu.net/.emacs[.html]>,
#                 <http://angg.twu.net/.zshrc[.html]>,
#                 <http://angg.twu.net/escripts.html>,
#             and <http://angg.twu.net/>.
#
#######

# (find-etag "isearch-string")
# (find-etag "isearch-search")
# (setq isearch-string "##\n#\n# ")
# (isearch-search)




#######
#
# Loop device partitions
#
#######

# (find-k2file "Documentation/devices.txt")
# (find-k2file "Documentation/Configure.help")
# (find-k2file "drivers/block/loop.c")
# (find-k2file "fs/vfat/namei.c")

# This is a message I found via dejanews, with keywords "mkdosfs" and
# "loop".
# (find-fline "~/makeboot")

# (find-fline "/snarf/ftp/ftp.mi.us.debian.org/debian/ls-lR")

insmod $MODULES/loop.o
losetup -d /dev/loop0
dd if=/dev/zero of=/home/LOOP bs=1024 count=1440
losetup /dev/loop0 /home/LOOP
mke2fs  /dev/loop0

rm /home/LOOP

# mke2fs is ok, but mkdosfs doesn't run, as it is addicted to disk
# geometry parameters and loop devices don't seem to have geometry. As
# for vfat, I don't even know if there is a "mkvfatfs".

# How can I create a loopback file with "holes" corresponding to bad
# sectors and write it to the floppy avoiding the holes?

# It would be nice to have some gzipped images of formated floppies.

# (find-fline "/usr/src/boot-floppies/rescue.sh" "-t msdos")
# (find-node "(Yard_doc)Using a Loopback Device")


dd if=/dev/zero of=/home/o bs=1024 count=2000





#######
#
# umsdos
#
#######

# (find-k2file "Documentation/Configure.help" "umsdos:")
# (find-k2file "Documentation/filesystems/umsdos.txt")
# (find-fline "/usr/doc/umsdos_progs-0.9-2/README")
# (find-fline "/usr/doc/HOWTO/UMSDOS-HOWTO")

rpm -qpl $RP/umsdos_progs-0.9-2.i386.rpm
rpm -iv  $RP/umsdos_progs-0.9-2.i386.rpm





#######
#
# Yard 1.13
#
#######

cd /dev/
MAKEDEV -v ram
rm ram0
mknod ram0 b 1 1
chown root:disk ram0
chmod 660 ram0

rm -Rv /usr/src/yard-1.13/
cd /usr/src/
tar -xvzf /snarf/http/www.croftj.net/~fawcett/download/yard-1.13.tar.gz
cd /usr/src/yard-1.13/

cp doc/Yard_doc.info /usr/info

ed configure <<'EOF'
15a
$config_dest    =  "/usr/src/yard-1.13/CONFIGDEST";
$lib_dest       =  "/usr/src/yard-1.13/LIBDEST";
.
w
EOF

cd /usr/src/yard-1.13/
mv -v Config.pl.in Config.pl.in.orig
cp -v ~/YARD/Config.pl Config.pl.in
./configure |& tee oc
make |& tee om
make install |& tee omi

cd /usr/src/yard-1.13/
cp -v ~/YARD/Bootdisk_Contents LIBDEST/Bootdisk_Contents

insmod $MODULES/loop.o
create_loopback_file

make_root_fs  |& tee omrf
# check_root_fs |& tee ocrf


# (find-fline "~/YARD/etc/fstab.S")
# (find-fline "~/YARD/Bootdisk_Contents")
# (find-fline "~/YARD/etc/")
# (find-fline "~/YARD/etc/rc")
# (find-fline "~/YARD/etc/inittab")

# ext2
#
umount /S
# echo 't\n2\n83\nw\n' | fdisk /dev/hdd
# mke2fs -c /dev/hdd2
mount -t ext2 /dev/hdd2 /S
rm -Rv /S/*
# cd /S ; mklost+found
cp -dipvR /mnt/* /S/
cp -v ~/YARD/etc/fstab.S /S/etc/fstab


# umsdos
#
umount /S
# echo 't\n2\n4\nw\n' | fdisk /dev/hdd
# echo 't\n2\n6\nw\n' | fdisk /dev/hdd
mkdosfs -c /dev/hdd2
mount -t umsdos /dev/hdd2 /S
rm -Rv /S/*
mkdir /S/linux
umssync /S/linux
cp -dipvR /mnt/* /S/linux/
cp -v ~/YARD/etc/fstab.S /S/linux/etc/fstab
# echo -n > /S/linux/etc/mtab


umount /mnt
losetup -d /dev/loop0
rm /c5/yardloop

umount /S

echo 'l\nq\n' | fdisk /dev/hdd
# echo 't\n2\n4\nw\n' | fdisk /dev/hdd
# echo 't\n2\n6\nw\n' | fdisk /dev/hdd
# echo 't\n2\n82\nw\n' | fdisk /dev/hdd
# echo 't\n2\n83\nw\n' | fdisk /dev/hdd
# 4="DOS 16-bit <32M", 6="DOS 16-bit >=32"
# 83="Linux native",  82="Linux swap"




cd /usr/src/yard-1.13/
agrep 4096 $(find *)
agrep Config.pl $(find *)

# (find-yardnode "Top")

# cp -v Bootdisk_Contents.minimal LIBDEST/Bootdisk_Contents

# (find-yardfile "configure" 16)
#$config_dest    =  "/usr/src/yard-1.13/CONFIGDEST";
#$lib_dest       =  "/usr/src/yard-1.13/LIBDEST";
# diff -e configure~ configure
# Now we use diff's output to automate the change.

# (find-fline "~/YARD/Config.pl")
# (find-yardfile "Config.pl")
# (find-yardfile "Config.pl.orig")

# (find-yardfile "scripts/make_root_fs")
# (find-yardfile "scripts/make_root_fs" "This is more than")
# (find-yardfile "scripts/check_root_fs")
# (find-yardfile "scripts/write_rescue_disk")

# (find-yardfile "LIBDEST/yard_utils.pl")
# (find-yardfile "LIBDEST/yard_utils.pl" "ramdisk to be unlocked")

# (find-yardfile "scripts/convert_config")
# (find-yardfile "scripts/create_loopback_file")
# (find-yardfile "scripts/create_replacements")


# (find-yardfile "README")
# (find-yardfile "Makefile")
# man ram
# man ramsize
# (find-yardnode "Thanks Acknowledgements and Theft")
# (find-fline "/usr/doc/HOWTO/Bootdisk-HOWTO")
# (find-k2file "Documentation/ramdisk.txt")
# (find-k2file "drivers/block/rd.c")



# (find-yardfile "omrf")
# (find-fline "~/YARD/Bootdisk_Contents")

# (find-fline "/c5/home/root/YARD/")
# (find-fline "/c5/home/root/YARD/notes")
# (find-fline "/c5/home/root/YARD/Bootdisk_Contents")

#
# On processing a Bootdisk_Contents file my way

# (find-node "(zsh)Shell Builtin Commands" "`print")
# (find-enode "Regexps")
# (find-fline "~/ICON/parseyard.icn")
# (find-fline "/usr/src/yard-1.13/Bootdisk_Contents")
# (find-fline "/c5/home/root/YARD/notes")
# (find-yardfile "scripts/make_root_fs" "ldd")
# (find-yardfile "scripts/make_root_fs" "file $lib")

(cd ~/ICON; icont parseyard.icn)
cd /usr/src/yard-1.13/
~/ICON/parseyard < Bootdisk_Contents

cd /mnt
file $(find *) | agrep -v ELF | sort
file $(find *) | agrep ELF | agrep statically | sort
file $(find *) | agrep ELF | agrep -v statically | sort







#######
#
# Formatting a loop partition via dosemu
#
#######

C=306
H=4
S=17
( /usr/src/dosemu-0.97.5/src/tools/periph/mkhdimage \
    -c $C -h $H -s $S
  dd if=/dev/zero bs=512 count=$[$C*$H*$S]
) > /home/hd.$C.$H.$S
#
# Now enter dos to fdisk and format the loop device (currently D:),
# then pack a clean version of it for later use.
# (find-fline    "~/98jun26.pucmail" "Subject: images")
# (find-fline "~/DOSEMU/config.edrx")
# disk { cylinders 306 heads 4 sectors 17 image "/home/hd.306.4.17" }
# A floppy has CHS=80/2/18.
#
gzip -c /home/hd.306.4.17 > ~/DOSEMU/hd.306.4.17.gz
gzip -cd ~/DOSEMU/hd.306.4.17.gz > /home/hd.306.4.17

# Mounting as /dev/loop0:
#
C=306
H=4
S=17
insmod $MODULES/loop.o
umount /L
losetup -d /dev/loop0
losetup -o 8832 /dev/loop0 /home/hd.$C.$H.$S
mount -t umsdos /dev/loop0 /L
#
# Copy the yard disk contents:
umssync /L
cp -dipvR /mnt/* /L/
#
# Go to msdos mode to zip the files:
umount /L
mount -t msdos /dev/loop0 /L

# Use the small swap partition as a dos partition:
#
# (find-fline "/etc/fstab")
free
swapoff /dev/hdd2
free
# mkdosfs -c /dev/hdd2
mkdosfs /dev/hdd2
mkdir /S
mount -t umsdos /dev/hdd2 /S
mkdir /S/linux
umssync /S/linux
cp -dipvR /mnt/* /S/linux
umount /S

# O próximo passo é pôr tudo dentro do diretório "/linux".

# (find-demufile "QuickStart" "generate a bootable")
# (find-demufile "doc/README.txt" "$_vbootfloppy = \"f")
# http://std.world.com/~bochs/
# (find-demufile "src/tools/periph/mkhdimage.c")
# (find-fline "/usr/doc/HOWTO/UMSDOS-HOWTO")

#
# Why 8832? 8832 = 128 + 8192 + 512 (=2280h), but?
# Using dd and hexl-mode, we see this "signature":
#
# 00002280: eb3c 904d 5344 4f53 352e 3000 0208 0100  .<.MSDOS5.0.....
#
# (find-k2tag "msdos_boot_sector")
# (find-k2file "fs/fat/inode.c")
# (find-k2tag "fat_read_super")
# (find-k2tag "msdos_read_super")
# (find-k2tag "UMSDOS_read_super")
# (find-k2file "fs/umsdos/inode.c" "install its linux stuff in c:\\linux")
# (find-k2file "fs/umsdos/dir.c"   "directory /DOS which points to")
# (find-enode "Display Vars" "tab-width")
# (setq tab-width 4)
#
# (find-k2file "Documentation/filesystems/umsdos.txt")
# (find-fline "/usr/doc/umsdos_progs-0.9-2/README")


cd
dd if=/home/hd.306.4.17	of=/home/root/o bs=1024 count=64
dd if=/dev/hdc		of=/home/root/o bs=1024 count=64
dd if=/dev/hdc1		of=/home/root/o bs=1024 count=64
dd if=/dev/loop0	of=/home/root/o bs=1024 count=64
# (hexl-find-file "~/o")
# (hexl-find-file "/home/hdcini")
# (find-k2file "include/






#######
#
# Creating a toy partition
#
#######

# (find-k2file "Documentation/Configure.help" 117)
# (find-k2file "Documentation/Changes" 291)

# Use ramdisk/loopback (how can I detect if the kernel has freed the
# ramdisk's memory?)

# Use minix/ext2/fat... -- ext2 uses up too much space. Why?

mkdir ~/LOOP
mkdir /L
#
insmod $MODULES/loop.o

umount /L
#
LOOP=~/LOOP/loop1
cd ~/LOOP/
dd bs=1k count=1024 if=/dev/zero of=$LOOP
#
mke2fs -F $LOOP
mkfs.minix $LOOP 1024
#
mount $LOOP /L -o loop
tune2fs $LOOP
echo -e 'stats' | debugfs $LOOP

umount /L




#######
#
# Testing a boot in a small HD partition
#
#######

Posso até usar só um subdiretório, e chroot.

Posso pôr coisa demais, fazer os rcs criarem um arquivo vazio só pra
marcar o tempo, e depois com um find ver que arquivos foram acessados.

Posso dar um chroot esperto depois do boot pequeno que me leve a algo
que é quase o resultado do boot normal (só que a gente vai ter rodado
algumas inicializações usando configurações mínimas, e talvez algumas
bibliotecas sejam reduzidas).




###########
#
# Booting in single-user mode
#
###########

export DISPLAY=:0.0
cd /usr/doc/lilo-0.19-1/doc/
xdvi user.dvi &
# p.13: boot parameters

# (find-enode "Compressed Files")
# (find-etag "auto-compression-mode")
# If the howtos are compressed, add .gz to their names.
# (auto-compression-mode t)

# (find-fline "/usr/doc/HOWTO/BootPrompt-HOWTO")
# (find-fline "/usr/doc/HOWTO/BootPrompt-HOWTO" 261)
# (find-fline "/usr/doc/HOWTO/Bootdisk-HOWTO")
# (find-fline "/usr/doc/HOWTO/Bootdisk-HOWTO" 1688)

# Example: "LILO: apmg single"

# Once you're done go to multiuser mode by exiting (cleanly?) from the
# bash shell or by running "telinit 3".








#  Local Variables:
#  coding:               no-conversion
#  ee-delimiter-hash:    "\n#*\n"
#  ee-delimiter-percent: "\n%*\n"
#  ee-anchor-format:     "«%s»"
#  ee-charset-indicator: "Ñ"
#  End: