Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Saturday, June 27, 2009

Linux From Scratch

Last year I successfully built a Linux from scratch system by following the book. The date was April 24th and it took roughly 3 days to complete. I remember the process being relatively laborious. The system is only for those whom want to see how it all fits together.

I haven't touched it since then. Only off and on doing some research into boot disks, root disks, loopback devices, etc. What is interesting to me is the differences between ISOLINUX and my LFS system. I'm intrigued at how a LiveCD can give you roughly the same thing without the "installation" process as a normal distribution. Why install (30 minutes or so) when you can copy? Maybe it takes the same amount of time ... but anyway, it's for the learning experience.

From the grub command:

grub> root (hd0,3)
grub> kernel /boot/isolinux/linux root=iso:/dev/hda4:/root/lfslivecd-x86-6.3-r2160.iso rootfstype=ext2
grub> initrd /boot/isolinux/initramfs_data.cpio.gz
grub> boot

From this command the kernel is loaded into memory, the kernel mounts the initial RAM disk and finally the initial RAM disk performs a pivot root and mounts the ISO image as root and eventually provides you with a terminal. Fascinating. Generally my description is correct but there are gaps in my understanding.

Here is some of the information I've gathered from the process.

1. The second part of the kernel command (grub command), i.e. root=iso: ...
is passed to the kernel to load as a boot parameter. In other words after the kernel is loaded it will look to this boot parameter in which to mount the root filesystem.
2. But the initrd is loaded first as a preliminary root filesystem.
3. Somehow the kernel and the initrd work in tandem to know what to do with the boot parameter that I listed at #1.

How #3 happens I don't know. Reason being is that I've replaced the root=iso: ... part with a simple root filesystem on disk (instead of the ISO). It doesn't work.
Why? What is compiled in the linux kernel from the LFS disk that won't allow it to accept a regular uncompressed root filesystem on disk? What make an ISOLINUX unique from a regular compiled Linux kernel? What does the ISOLINUX kernel have to do with with the ISO9660 El Torito file system?

Maybe I just answered my own question. ISOLINUX kernel understands the El Torito (CD ROM) filesystem. So it knows how to mount the ISO image. Whereas a normal root filesystem is an EXT2 filesystem. In order for our generic ISOLINUX kernel to mount an EXT2 filesystem we would have to tell the init RAM disk how to install the kernel module in order to finally mount the root filesystem.

Once I figure out how to install modules from the init RAM disk environment I will be able to run a generic kernel from anywhere, everywhere I go.

The goal for me is to build a Linux Live USB. And not merely following the instructions provided by a website.

Wednesday, May 13, 2009

Ubuntu Mirror

Working with Ubuntu exclusively on my workstation now since April 24th (Jaunty release). I've also been exploring virtualization technology as well. I gave XenServer, KVM a try. Settled on VMware only because the files were portable (so I can take it to work). I'll write about the different products another time.

My intent was to create a VM so that I can run some genealogy software. The VM for the obvious reason of backing it up easily. Funny thing is that after installing Ubuntu (a few times) it appeared to me that Ubuntu *required* a connection to the Internet to install. I found out after some experimentation that this isn't the case. Anyway, I wanted to set up a mirror so that I didn't need to do this. However, I didn't want to set up a mirror by downloading the entire Ubuntu repository (22+ GB).

So I experimented with apt-mirror and here are some of my results.

- I purchased the entire Ubuntu repository from a store called LinuxStore.ca (LinuxStore.org.uk).
- So instead of downloading the mirror I wanted to copy it from my set of DVDs
- I followed the instructions in setting up apt-mirror
- Instead of pointing mirror.list to a mirror like http://ca.archive.ubuntu.com/ubuntu I followed an instruction to add the line: deb file:/media/cdrom/ubuntu jaunty main
- This didn't work so I read the /usr/bin/apt-mirror perl script
- Problem with the script is that it strips "http://" from the mirror name and creates a folder under /var/spool/apt-mirror/skel/. Since my URL = file:/media/cdrom/ubuntu this just didn't work.
- So what I ended up doing was keeping a single entry in the mirror.list file and mirroring that (i.e. jaunty-security main - 66 MB).
- I then confirmed the file structure and copied the pattern for the rest of the files
- I then confirmed file structure of the locally (DVD) retrieved files by confirming that apt-mirror when executed would update the packages
- Therefore I know that copying universe and multiverse components (from the DVD) of the repository will work correctly

Quick summary

- If I could do this again I would not buy the entire repository. Downloading "main" and "restricted" is good enough.
- Creating a mirror isn't necessary. You can point any VM sources.list file to a local directory or a NFS mounted file system or a DVD mounted iso and apt-get will retrieve the files.

Ubuntu Install

/dists/jaunty/binary-i386/main/Release.gz contains the list of packages for the component (i.e. main)
/pool/main/a
/pool/main/b ... etc.
contains all the packages.
Running apt-mirror for a different component, eg. main, will check the most recently available packages from the repository and update your mirror. So this is the benefit of using apt-mirror.

Question: Is the archive of apt-mirror the same as an archive stored at /var/cache/apt/archive ?
When running Update Manager it saves the updated packages to /var/cache/apt/archive .