mardi 10 avril 2012

LFS Success. Retrospective.

You have successfully registered!
ID: 23340
Name: agumonkey
First LFS Version: 20120409
© 1998-2012 Gerard Beekmans. Website design by Jeremy Huntwork & Matthew Burgess.
Finally I boot a LFS system.

I don't remember, it might be my 5th attempt ? development branch no less.
Never could go further than new system gcc/glibc.
Couldn't put my mind into solving.. too much noise. Weak mental.

Wasn't a walk in the park this time, what went wrong. Or what I should call
'The Overlook List' :

- choose a host
  last attempt was on a usb key 1Go for debian live, 6Go for the new lfs
  Failed early, stayed that way.
  last attempt started bad, I didn't pay attention and used lfslivecd which was obsolete.
  => realize that no special os needed, just a right set of tools
  now I thought to reuse the usb key and debian .. but I didn't want to boot another system.
  => realize that no special os needed, I run Kubuntu .. it's actually enough even for the latest SVN branch.

- headfirst style
  Created a local lfs user. Used $HOME/lfs as target for $LFS.
  I went through the book simply. This time not writing commands, I now understand sed enough
  so I can just copy/paste, and avoid time-wasting typos.
  By the time I reach the chapter 7 I wonder how I'm gonna boot this local folder.
  So I skip the beat, erase the usb key 2nd partition. cp -R $HOME/lfs /media/usb
  and try to finish there.

- lfs-bootscript, wrong sudo : host corrupted
  In a hurry I try to trick make to install bootscripts using DESTDIR variable.
  Except, I think, that sudo doesn't inherit the environment, thus letting make
  do its job using the host /.
  Luckily, Kubuntu init.d wasn't too corrupted, network setup takes 2 minutes
  now but it still boots. At first I thought I was good for a full setup.

- can't compile kernel (predefs.h not found)
  Not caring much about Kubuntu, I reach the kernel compilation step.
  To my surprise I made something wrong. Someone in the toolchain complains about
  about 'predefs.h' and 'bits.h' not being found. Seems related to kernel headers.
  Problem : too complex, Brain : too weak.

- redo & build an env
  Frustrated by the bare naked, information overload, and fragility. I try to improve a bit
  the process. I recreate the lfs user, add a .bash.d with :
  - extract function
  - lfs specific variable setup
  - a little login message to remind me of what variables are set or not.
  Nothing fancy at all, but it's already easier.
  I also time and log everything:
  `time make $cmd 2>&1 | tee $logs/$chapter/$(basename $(pwd))-$cmd.log` ; echo ">>> $?"

  I can leverage history key bindings almost blindly. Almost.

- grub road bump
  Things are smooth, no more `sudo` havoc, kernel compiles. I'm anxious about the
  grub process but anyway.
  Grub stops, saying he can't do shit, but even grub1 is nice enough to let you poke
  around live. The usb key is hd0, so I prepend the vmlinuz path with (hd0,2).
  F10 to run. 'Decompressing Kernel...' followed by kernel panic.

- IRC saves the day again
  Can't count how much knowledge I got on IRC channels.
  @Ratrophy tell me to add rootdelay=n[seconds] to avoid mounting before the usb key is
  fully setup.
  Works fine, now the kernel only panics, but for a totally different reason.

- FS drivers !
  It's been a long time since I've compiled a kernel, the menu organisation changed a bit.
  I didn't see EXT4 because it's written Extended Fileblahblahblah-long-wording Version 4.
  Okay, since I kept linux source in their compiled state, I can rebuild it quick with ext4 module.
  ...
  Seems that it needs to be builtin. Oh yeah there's no initrd .. I don't understand it all but
  someone has to have ext4 builtin.
  Now it .. panics. Saying /dev/sda can't be mounted. My kernel parameters mention /dev/sdb
  so Y U NO bOOT ?!?

- fstab ...
  Ah I copied the fstab from the book taking a bet on the device name, thinking the usb key would
  get sda since I boot on it. Wrong. Let's go vimcorrect that.
  Now I reach init ! and then I see a horrifying error message talking about forced halt.

- Stubbornness => single mode peeping.
  So :
  - the bootloader is fine
  - the kernel is fine
  - the filesystem is fine
  - the userspace is fine ( as in, program runs when chrooted in the host )

  This can't be serious. I poke in grub, making the FS rw.. No progress.
  Some setups drop the kernel into a shell. I wish I could.. I can only try single user mode.
  Rewrite grub.cfg `linux (hd0,2)/boot/vmlinuz-xxx root=/dev/sdb2 ro single init=/bin/bash`
  Boot, and here it is, the glorious shell. First time I type in that state.
  Can't do shit since the FS is ro, but I understand that only 10 minutes later.

- devtmpfs investigation
  I try running the bootscripts by hand, line by line.
  `mount -t -o procfs none /proc`
  Now ps works ... nice but not what I want.
  I mount everything until I realize /dev is quite empty. What is udev waiting for ??
  `mount -t devtmpfs .. /dev` => error, unknown fs type devtmpfs. WAT
  What is devtmpfs anyway ? isn't it devfs ?
  Then my eyes catch the huge NOTE saying not to forget to activate 'devtmpfs' ...
  Okay, reboot Kubuntu, recompile (the whole) kernel.

- Register
  Yep it boots, grub >= kernel >= init >= login.
  60MB used, 38 for cache. Not bad Linus.

- BLFS ? Not so fast
  - the network is not setup right
  - I got a static IP
  - no route to my internet gateway
  - there's no ssh, no wget. only ftp is on the system

- Ending notes
   Even though I've had a lot of criticizing in my head about LFS, it's a wonderful tutorial.
   Thanks a lot to their team.

Aucun commentaire:

Enregistrer un commentaire