[lang]

Present Perfect

Personal
Projects
Packages
Patches
Presents
Linux

Picture Gallery
Present Perfect

Filed under: General — Thomas @ 12:08

2003-12-31
12:08

I suppose everyone sometimes gets that little voice in the back of the head telling you not to try something you're about to try. Either because it's stupid or because it makes no sense or whatever ...

Sometimes it pays to listen, as I just found out. The problem was simple : while writing a kickstart file, I needed to get one file from the floppy disk which was mounted as / to the new file system. Normally you'd do this in the %post section in the kickstart configuration file.

Now, %post executes in a chroot'ed environment equivalent to your newly installed system. So there's no way to get at the file you want to install. But you can run %post without the chroot'ed environment by using --nochroot.

Only problem is, you cannot go back to the chroot'ed environment (I thought the chroot command might do the trick, but that either starts a new shell interactively, which is bad of course, or allows you to execute the one command you put behind it).

Ok, so you think of a few ways around this :

  • Actually try to mount the floppy disk in the %post script and copy the file from the disk. Works, but the user needs to keep the floppy in. He probably will, but it doesn't feel right.
  • Write the new file line by line from the kickstart config file. Works, but totally style-less.
  • Do %post --nochroot, and execute each of the other commands (which should run in a chroot environment) prepended with chroot /mnt/sysimage. Works, but equally style-less and cumbersome.
  • Do %post --nochroot, put all of the chroot'ed commands in a separate file on the disk, and do something like chroot /mnt/sysimage /post.sh. By far the best solution, but still not satisfying.

So what do you do when none of the solutions is aesthetically pleasing, and a little voice in the back of your head says : Wouldn't it be nice if you could just have two %post sections, one labeled "%post" and another labeled "%post --nochroot" and just put the right commands in the right section ?

And you think to yourself, yeah, that would be nice, but no way would that work. I'm sure the Red Hat engineers didn't code to allow that, and otherwise I would have come across that on Usenet and in the docs.

But the voice says : Try it. You know you want to.

So you do.

And what do you know ? It works.

So to all of those out there who have the voice : make sure you listen.

2 Comments

No comments yet.

RSS feed for comments on this post. TrackBack URL

Sorry, the comment form is closed at this time.

picture