RIP Notes: Difference between revisions

From Wildsong
Jump to navigationJump to search
Brian Wilson (talk | contribs)
mNo edit summary
Brian Wilson (talk | contribs)
mNo edit summary
 
(10 intermediate revisions by the same user not shown)
Line 1: Line 1:
[RIP] is based on [http://slackware.org Slackware].
RIP is a small rescue system that can reside on a Live CD.
I am playing with using it via [[PXEboot]].
 
[http://www.tux.org/pub/people/kent-robotti/looplinux/rip/ RIP] is based on [http://slackware.org Slackware].
[http://slackware.mirrors.tds.net/pub/slackware/slackware-10.2-iso/ Slackware archive]
[http://slackware.mirrors.tds.net/pub/slackware/slackware-10.2-iso/ Slackware archive]
== What it is ==
Unpacking the PXE archive, one finds everything needed to drop into the /var/lib/tftpboot directory. There is a 2.6 series kernel and a big fat file called rootfs.cpz.
The rootfs file is a gzip compressed cpio archive image of a root filesystem.


== Customizing RIP ==
== Customizing RIP ==


The kernel and programs on the system are compressed with UPX v2.00.
I like the basic package but wanted a few things turned on at boot
So, if you do this 'file /usr/bin/lynx', you get this.
so that I could get remote access more easily.
/usr/bin/lynx: ELF 32-bit LSB executable, Intel 80386, version 1,
statically linked, corrupted section header size


You can ignore that!
=== Compression note ===
 
Also, 'ldd' will say a program is statically linked, even if it's not.


The kernel and programs on the system are compressed with UPX v2.00.
If you want, you can uncompress a program like this 'upx -d program'.
If you want, you can uncompress a program like this 'upx -d program'.
You can't uncompress the kernel!


You can get UPX here http://upx.sourceforge.net; I installed it from the Ubuntu package.
You can get UPX here http://upx.sourceforge.net; I installed it from the Ubuntu package.


=== Unpacking ===
=== Unpacking the root filesystem ===


  cd /home/diskless/tftpboot
  cd /home/diskless/tftpboot
Line 24: Line 29:
  gzip -dc ../rootfs.cgz | cpio -iumdv
  gzip -dc ../rootfs.cgz | cpio -iumdv


Make your changes
=== Make your changes ===
# I changed /etc/inittab to enable serial port login.
# I added myself to the password file and gave root a password.
# Made /etc/rc.d/rc.sshd executable so that it would start at boot.
# Set etho, eth1 to ask for IP's via DHCP in /etc/rc.d/rc.inet1.conf
# Initialize serial ports by enabling /etc/rc.d/rc.serial


=== Packing ===
cd etc


find . -depth -exec cpio -o \; | gzip > root.cpz
Give root a password. (I cut and pasted the root entry from /etc/shadow.)


== Q & A ==
mv shadow shadow-
grep root /etc/shadow > shadow
cat shadow- >> shadow
emacs shadow


===Q. Is it possible to change something, or add shell scripts and/or packages to the system? ===
Make /etc/rc.d/rc.sshd executable so that it would start at boot.


A. To remaster RIPLinuX and install an add-on package.
Apparently that's how Slackware does things; it executes every script in /etc/rc.d, in order. So if a script is not executable it will be skipped.


The add-on package must have a '.tgz' (tar/gzip) extension, and be packed
chmod 755 rc.d/rc.sshd
for extraction/installation from '/' on the Linux system.
 
Tell system to initialize serial ports by enabling /etc/rc.d/rc.serial


It can be a self-made, third-party, or Slackware package.
chmod 755 rc.d/rc.serial


# mkdir /rip1 /rip2
Edit /etc/inittab and /etc/securetty to enable serial port login.
# mount -o loop RIPLinuX-1.8.iso /rip1
Edit /etc/rc.d/rc.inet1.conf so that it will start DHCP at boot.
# cp -a /rip1/* /rip2
Edit /etc/issue so that I know what has been tweaked in this image
# umount /rip1 ; rmdir /rip1
when the system boots.
# mkdir /rip2/boot/1
# cd /rip2/boot/1
/rip2/boot/1# gzip -dc ../rootfs.cgz | cpio -iumdv
/rip2/boot/1# sbin/installpkg -root . /path-to-package/package.tgz


Remove the old system.
emacs inittab securetty rc.d/rc.inet1.conf issue


/rip2/boot/1# rm ../rootfs.cgz
=== No X ===


Then cpio/gzip the new system.
I have no interest in having X-window clogging up on my rescue image but the author provides the PXE image only with X. So first task is to try using the "No X" ISO to create a PXE image.


/rip2/boot/1# find . | bin/cpio -v -o -H newc | gzip -9 >../rootfs.cgz
I downloaded the CDROM image and loopback mounted it.
                        ^^^
"Use the RIPLinuX cpio 'bin/cpio' here!"


  # rm -rf /rip2/boot/1
  # mount -o loop RIPLinux-1.8.iso /mnt
# mkdir /rip-iso
# cd /rip2
/rip2# sh boot/mkiso.sh . /rip-iso rip.iso


Write /rip-iso/rip.iso to a CD!
Then I unpacked and copied the contents of its rootfs.cgz to a handy directory.


You can now delete the /rip2 directory.
# mkdir root & cd root
# gzip -dc /mnt/boot/rootfs.cgz | cpio -iumdv


# rm -rf /rip2
Now that I have a copy of the root filesystem without X,
I can apply the same patches as above and build a new image that is
one half the size... the new image is 30 MB versus 60+; X is big!


Note: You can also have the add-on package(s) on any media and install
=== Building a new image ===
it after the system boots. This is probably the best way to do it,
because 'rootfs.cgz' is loaded into memory (which is freed after
it's extracted), so it's best to keep it small.


You could put the add-on package(s) in /boot/pkg on the RIPLinuX CD, or any
find . | bin/cpio -v -o -H newc | gzip -9 >../rootfs.cgz
media.
          ^^^
'''Use the RIPLinuX cpio 'bin/cpio' here!''' The standard one won't work right.


If you pass this to the kernel 'rip_pkg=/dev/hdc,/boot/pkg', when the
== Cribbed from the README files ==
system boots it will mount /dev/hdc and prompt you to install any *.tgz
packages it finds in /boot/pkg.


If you pass this to the kernel 'rip_pkg=/dev/hdc,/boot/pkg,noprompt', you
=== Adding a package to RIP ===
won't be prompted.


You can pass that to the kernel in /boot/isolinux/isolinux.cfg.
Slackware 'packages' are just gzipped tar files.


=== Q. Is it possible to replace the kernel? ===
The add-on package must have a '.tgz' (tar/gzip) extension, and be packed
for extraction/installation from '/' on the Linux system.


The replacement kernel must have this support builtin.
cd /var/lib/tftpboot/root
sbin/installpkg -root . /path-to-package/package.tgz


CONFIG_SHMEM=y
You can also have the add-on package(s) on any media and install it after the system boots. This is probably the best way to do it, because the file 'rootfs.cgz' is loaded into memory and then unpacked so both the rootfs.cgz file nad the extracted filesystem have to fit into RAM at the same time. Once the boot extract process is complete the memory used up by boot.cgz is freed.
CONFIG_BLK_DEV_RAM=y
CONFIG_BLK_DEV_INITRD=y
CONFIG_ISO9660_FS=y
CONFIG_EXT2_FS=y
CONFIG_FAT_FS=y
CONFIG_MSDOS_FS=y "MSDOS and/or VFAT for USB Flash drive access!"
CONFIG_VFAT_FS=y
CONFIG_PROC_FS=y
CONFIG_TMPFS=y


A. # mkdir /rip1 /rip2
You could put the add-on package(s) in /boot/pkg on the RIPLinuX CD, or any
  # mount -o loop RIPLinuX-1.8.iso /rip1
media.
  # cp -a /rip1/* /rip2
  # umount /rip1 ; rmdir /rip1


Replace the kernel in the /rip2/boot directory.
If you pass this to the kernel 'rip_pkg=/dev/hdc,/boot/pkg', when the
system boots it will mount /dev/hdc and prompt you to install any *.tgz
packages it finds in /boot/pkg.


Create and write /rip-iso/rip.iso to a CD as described above!
If you append "noprompt" eg 'rip_pkg=/dev/hdc,/boot/pkg,noprompt', you
won't be prompted, the packages will be automatically installed.


NOTE: If you want *initramfs* to use TMPFS instead of RAMFS, apply
For PXEboot, the file /var/lib/tftpboot/pxelinux.cfg/default contains kernel options.
the patch "inittmpfs.diff" to the kernel source.
http://www.tux.org/pub/people/kent-robotti/looplinux/rip


=== Q. Is it possible to install the system on my hard drive? ===
=== Q. Is it possible to install the system on my hard drive? ===
Line 127: Line 112:
This example assumes you created a Linux partition on /dev/hda2,
This example assumes you created a Linux partition on /dev/hda2,
with a ext3 filesystem.
with a ext3 filesystem.
You can resize a Windows XP NTFS partition, using 'ntfsresize'.
If you resize Windows you'll have room on your hard drive for Linux.
For example, you have a 120 GB Windows partition on /dev/hda1 and you
want to resize it to 80 GB.
# ntfsresize -n -s 80000M /dev/hda1  "Resize to 80 GB! (test run)"
# ntfsresize -s 80000M /dev/hda1    "Resize to 80 GB! (for real)"
# fdisk /dev/hda
  Command: d
  Command: n
  p "Primary partition!"
  Partition number: 1
  First cylinder: "Press enter for default!"
  Last cylinder: +80000M
  Command: t
  Hex code: 7
  Command: a
  Partition number: 1
  Command: n
  p "Primary partition!"
  Partition number: 2
  First cylinder: "Press enter for default!"
  Last cylinder:  "Press enter for default!"
  Command: p
  Command: w "Write table to disk and exit, or q to Quit!"
You can use the shell script 'shrinkntfs' on RIPLinuX to do the above.
  # shrinkntfs 80000 /dev/hda1
The above example would shrink an NTFS filesystem on /dev/hda1 to 80000
MegaBytes (80GB)!
After the NTFS filesystem is strunk by ntfsresize, fdisk is used to rewrite
the partition table.
The shrinkntfs script is specifically for the case where you have an NTFS
system using the whole hard drive, and you want to free up space for another
operating system etc.
NOTE: The next time you boot Windows it will run 'chkdsk'!
NOTE: The script won't run if you have more than 3 partitions on
      the specified hard drive!
Then you can use the 'mkpart' script to create a Linux partition.
  # mkpart 83 20000 /dev/hda
The above example would create a type 83 (Linux) 20000 MegaBytes (20GB)
primary partition on /dev/hda!
It will use the next available partition!
If you want it made active, add '-a' at the end!
  # mkpart 83 20000 /dev/hda -a
You probably don't want the Linux partition to be made active!
To get a listing of partition types, do this!
  # mkpart -t /dev/hda
NOTE: The script won't run if you have more than 2 partitions on
the specified hard drive!
  # mke2fs -j /dev/hda2  "Create ext3 filesystem on /dev/hda2, if
                          that's the Linux partition!"
--------------------------------------------------------------------


Mount the RIPLinux CD or ISO image that has /boot/rootfs.cgz on it.
Mount the RIPLinux CD or ISO image that has /boot/rootfs.cgz on it.
Line 236: Line 147:
Slackware 10.2 or later. Only use /sbin/installpkg on RIPLinuX to
Slackware 10.2 or later. Only use /sbin/installpkg on RIPLinuX to
install Slackware packages 'installpkg package_name.tgz'.
install Slackware packages 'installpkg package_name.tgz'.
  ------------------------------------------------------------------
You can install a Slackware Linux distribution on a ext2, ext3, jfs,
reiserfs, reiser4, or xfs formatted partition.
  # setup  "Read HELP!"
You need the Slackware ISO images 'slackware-10.2-install-d1.iso
and slackware-10.2-install-d2.iso' on CD or DVD! You need at least
'slackware-10.2-install-d1.iso'!


You can also install Slackware from a partition on your hard drive
You can also install Slackware from a partition on your hard drive

Latest revision as of 18:40, 1 July 2006

RIP is a small rescue system that can reside on a Live CD. I am playing with using it via PXEboot.

RIP is based on Slackware. Slackware archive

What it is

Unpacking the PXE archive, one finds everything needed to drop into the /var/lib/tftpboot directory. There is a 2.6 series kernel and a big fat file called rootfs.cpz.

The rootfs file is a gzip compressed cpio archive image of a root filesystem.

Customizing RIP

I like the basic package but wanted a few things turned on at boot so that I could get remote access more easily.

Compression note

The kernel and programs on the system are compressed with UPX v2.00. If you want, you can uncompress a program like this 'upx -d program'.

You can get UPX here http://upx.sourceforge.net; I installed it from the Ubuntu package.

Unpacking the root filesystem

cd /home/diskless/tftpboot
mkdir root; cd root
gzip -dc ../rootfs.cgz | cpio -iumdv

Make your changes

cd etc

Give root a password. (I cut and pasted the root entry from /etc/shadow.)

mv shadow shadow-
grep root /etc/shadow > shadow
cat shadow- >> shadow
emacs shadow

Make /etc/rc.d/rc.sshd executable so that it would start at boot.

Apparently that's how Slackware does things; it executes every script in /etc/rc.d, in order. So if a script is not executable it will be skipped.

chmod 755 rc.d/rc.sshd

Tell system to initialize serial ports by enabling /etc/rc.d/rc.serial

chmod 755 rc.d/rc.serial

Edit /etc/inittab and /etc/securetty to enable serial port login. Edit /etc/rc.d/rc.inet1.conf so that it will start DHCP at boot. Edit /etc/issue so that I know what has been tweaked in this image when the system boots.

emacs inittab securetty rc.d/rc.inet1.conf issue

No X

I have no interest in having X-window clogging up on my rescue image but the author provides the PXE image only with X. So first task is to try using the "No X" ISO to create a PXE image.

I downloaded the CDROM image and loopback mounted it.

# mount -o loop RIPLinux-1.8.iso /mnt

Then I unpacked and copied the contents of its rootfs.cgz to a handy directory.

# mkdir root & cd root
# gzip -dc /mnt/boot/rootfs.cgz | cpio -iumdv

Now that I have a copy of the root filesystem without X, I can apply the same patches as above and build a new image that is one half the size... the new image is 30 MB versus 60+; X is big!

Building a new image

find . | bin/cpio -v -o -H newc | gzip -9 >../rootfs.cgz
         ^^^

Use the RIPLinuX cpio 'bin/cpio' here! The standard one won't work right.

Cribbed from the README files

Adding a package to RIP

Slackware 'packages' are just gzipped tar files.

The add-on package must have a '.tgz' (tar/gzip) extension, and be packed for extraction/installation from '/' on the Linux system.

cd /var/lib/tftpboot/root
sbin/installpkg -root . /path-to-package/package.tgz

You can also have the add-on package(s) on any media and install it after the system boots. This is probably the best way to do it, because the file 'rootfs.cgz' is loaded into memory and then unpacked so both the rootfs.cgz file nad the extracted filesystem have to fit into RAM at the same time. Once the boot extract process is complete the memory used up by boot.cgz is freed.

You could put the add-on package(s) in /boot/pkg on the RIPLinuX CD, or any media.

If you pass this to the kernel 'rip_pkg=/dev/hdc,/boot/pkg', when the system boots it will mount /dev/hdc and prompt you to install any *.tgz packages it finds in /boot/pkg.

If you append "noprompt" eg 'rip_pkg=/dev/hdc,/boot/pkg,noprompt', you won't be prompted, the packages will be automatically installed.

For PXEboot, the file /var/lib/tftpboot/pxelinux.cfg/default contains kernel options.

Q. Is it possible to install the system on my hard drive?

A. You need to create a Linux partition using 'fdisk' etc., the you need to put a ext3 etc. filesystem on it, then you need to mount the partition and extract 'rootfs.cgz' to it.

This example assumes you created a Linux partition on /dev/hda2, with a ext3 filesystem.

Mount the RIPLinux CD or ISO image that has /boot/rootfs.cgz on it.

  # mount -rt iso9660 /dev/hdd /mnt/cdrom      "Mount CD!"
  # mount -o loop RIPLinuX-1.8.iso /mnt/cdrom  "Mount ISO image!"
  # mount -t ext3 /dev/hda2 /mnt/linux
  # cd /mnt/linux
  /mnt/linux# gzip -dc /mnt/cdrom/boot/rootfs.cgz | cpio -iumdv
            # cp /mnt/cdrom/boot/kernel /mnt/linux/boot

Add this line to the top of the /mnt/linux/etc/fstab file.

  /dev/hda2    /    ext3    defaults  1   1
  # rm /mnt/linux/init  "Remove /init link!!!"

You'll need to use GRUB etc. to boot it.

From the RIPLinuX CD ISOLinux menu, you could do this to boot the Linux partition on /dev/hda2.

Choose GRUB from the menu.

Press the `c' key to get a command prompt.

  grub> root (hd0,1)
  grub> kernel /boot/kernel root=/dev/hda2 ro
  grub> boot

NOTE: You can use the Linux system on the RIPLinuX CD to create the Linux partition, and extract rootfs.cgz to it.

NOTE: RIPLinuX is based on Slackware and you can install packages from Slackware 10.2 or later. Only use /sbin/installpkg on RIPLinuX to install Slackware packages 'installpkg package_name.tgz'.

You can also install Slackware from a partition on your hard drive that has the directories (a, ap, etc.) with the Slackware tgz packages, or over NFS. It's basically the same as standard Slackware setup!

The filesystem on the partition can be any the kernel supports, at least read-only!

Slackware doesn't currently support reiser4, if you want to install Slackware on a reiser4 partition you'll have to use the RIPLinuX kernel to boot it. When asked by setup for a kernel to install choose "rip_cdrom (Use the kernel from the RIPLinuX CD)".