Re: /etc/fstab query



On Monday 26 October 2009 22:33 in alt.os.linux, somebody identifying as
Phil B wrote...

A silly question.

I want to move a directory tree from one partition to another on my
mythbuntu system as I think it will make backup easier. It will also
be a good exercise for this novice.
Specifically, it currently has /etc/lib on a separate partition from
/, and I want to move all of it except /etc/lib/mythtv back to the
partition holding /.

I plan to mount the partitions under a live distro then mv the
directories to the right partitions, then edit /etc/fstab to reflect
the changes. I'll be doing it on a 'spare' drive so no real grief if I
mess it up.

There's a way to do it without a live CD as well. Just "mount --bind"
the root filesystem to - say - */mnt* and then copy the contents of the
regularly mounted */etc/lib* filesystem to the */etc/lib* directory on
the bind-mounted root filesystem - this would then be */mnt/etc/lib.*

Next, you unmount the bind-mounted root filesystem and the separate
*/etc/lib* filesystem, but be careful here as something may actually be
using files on that filesystem, so it's best to do it from single-user
maintenance mode, i.e. runlevel 1.

That raises a chicken and egg situation in my mind:
/etc/fstab defines which partitions are to be mounted and what's on
them.
How then does the system at boot time (would it be the kernel?) find
/etc?

The bootloader passes the filesystem designated as the root filesystem
to the kernel. When the kernel is decompressed in memory - which is
after the processor has been switched into protected mode (or long mode
on x86-64) - the boot parameters and such are copied from low memory to
high memory so the kernel will still have access to that information
once the low memory that was used by the realmode code - i.e.
bootloader and kernel bootstrapping code - has been cleared out.

If you've got a kernel that uses an /initrd,/ it will load its driver
modules from there, and if it's a kernel built to boot without
an /initrd/ it'll have the necessary drivers built-in for directly
accessing the root filesystem - other drivers may then still be loaded
as modules, as long as the kernel knows where to find them, and this
would be the */lib/$(uname -r)/modules* directory on the known root
filesystem.

Now, the root filesystem was specified as a boot option in the
bootloader and this information copied to where the kernel can access
it once it has decompressed. The kernel will then check this root
filesystem for errors, and if none are found, it will launch
*/sbin/init* - this is hardcoded into the kernel as a default, but can
be overridden with a boot parameter, as is done to boot up into
single-user maintenance mode.

Once /init/ starts running - at this stage, userspace is already
active - it starts forking off some processes which take care of the
the mounting of the filesystems as specified in */etc/fstab* and the
starting of the necessary daemons for the default runlevel.

So to put a long story short: the kernel doesn't actually look for
*/etc* at boot, but it does look for the directories */lib* - if it
needs to load modules directly off of the root filesystem - and
*/sbin,* both residing on the filesystem of which it was made clear by
the bootloader that this is the root filesystem to use, and /init/
takes care of the rest.

--
*Aragorn*
(registered GNU/Linux user #223157)
.



Relevant Pages

  • Re: booting linux using a floppy
    ... which kernel of the list to boot from. ... Note that this will at this point remove your ability to boot into windows. ... I think I recall that you said the grub loader... ... and grub will search for a partition containing grub's stage2 file ...
    (comp.os.linux.misc)
  • Re: My Machine Wont Boot
    ... The boot order is correct in the bios. ... Decoded into readable language, the,0 is the partition number of the (0 ... Installing Grub And A Kernel ... won't install grub because the kernel hasn't changed. ...
    (Fedora)
  • Re: /boot on a separate partition
    ... >> partition at the start of the drive. ... The problem I'm having is trying to actually boot the system. ... Undaunted, I type 'ad(0,d)/loader' to load the stage 3 loader. ... the message "can't load 'kernel". ...
    (freebsd-questions)
  • Re: Kernel boot configuration in modern Linux systems
    ... is enough to copy this image file to the boot medium like the ... BIOS to load the kernel, the kernel image had to be located beyond this ... This is not a problem for a sane install, ... because there will be a fairly small partition holding / and it is not ...
    (comp.os.linux.development.system)
  • Re: Kernel recompile has left /boot empty
    ... same as the main partition. ... 8.0K boot ... >> I successfully recompiled my kernel, ... > The first thing that came to mind was that maby the boot scripts faild ...
    (alt.os.linux)