Slashdot Mirror


Dynamic Root Support For FreeBSD Now Available

Dan writes "FreeBSD's Gordon Tetlow has committed his enhancements to enable users to build /bin and /sbin dynamically linked on FreeBSD. His reason to do this is two-fold. One is to give better support for PAM and NSS in the base system. The second is to save some disk space. Currently (on his x86 box), /bin and /sbin are 32 MB. With a dynamically linked root (and some pruning of some binaries), the /bin, /lib, and /sbin come out to 6.1 MB. This should be great for people with 2.x and 3.x era root partitions that are only about 50 MB. Gordon says that there will be a performance hit associated with this. He did a quick measurement at boot and his boot time (from invocation of /etc/rc to the login prompt) went from 12 seconds with a static root to 15 seconds with a dynamic root."

25 of 112 comments (clear)

  1. bad bad bad by Tirel · · Score: 5, Insightful

    not only will this affect performance, but it will also make it impossible to recover a server if you accidentally delete /usr,

    there are less and less reasons to use seperate partitions for root directories, and this is *NOT GOOD*

    1. Re:bad bad bad by Fweeky · · Score: 4, Insightful

      Er, why? /bin, /sbin and /lib should all be on the same partition, and if you're really screwed, that's what /rescue is for.

    2. Re:bad bad bad by Nizzt · · Score: 5, Informative

      Thats why the librarys are in /lib not /usr/lib

    3. Re:bad bad bad by cperciva · · Score: 5, Informative

      it will also make it impossible to recover a server if you accidentally delete /usr

      No. The libraries used by stuff in /bin and /sbin are being moved into /lib, so everything which is being changed from static to dynamic will still work even if /usr is gone.

      Also note that /rescue is still static (and crunched).

    4. Re:bad bad bad by jkujawa · · Score: 2, Informative

      The point of static binaries in /bin and /sbin is not only being able to mount /usr of a file server, but also being able to recover if you kill ld.so.

    5. Re:bad bad bad by Anonymous Coward · · Score: 2, Informative

      not only will this affect performance, but it will also make it impossible to recover a server if you accidentally delete /usr,

      Only if you do something stupid, like put critical system libs into /usr. The binaries in /bin and /sbin shouldn't rely on anything in /usr, only libraries in /lib.

    6. Re:bad bad bad by ctr2sprt · · Score: 4, Insightful

      It's not good as a default, but it's good as an option. So while I hope FreeBSD installs still come with a static bin+sbin, it's nice to have the option, on a make world, to change the behavior if I decide I need to. It's added flexibility without any added complexity. What more could you want?

    7. Re:bad bad bad by Arandir · · Score: 2, Funny

      Screw /usr. I still want to know how to recover the server after I accidentally deleted / last week...

      --
      A Government Is a Body of People, Usually Notably Ungoverned
    8. Re:bad bad bad by shlong · · Score: 4, Informative

      " not only will this affect performance, but it will also make it impossible to recover a server if you accidentally delete /usr,"

      What wasn't mentioned in the write-up is that /rescue contains statically-link versions of the tools that one would need to recover from problems. It might not be able to recover a deleted filesystem, but if you're trouncing careless around like that then there are plenty of other ways to shoot your feet off too.

      --
      Cat, the other, tastier white meat.
    9. Re:bad bad bad by R.Caley · · Score: 2, Informative
      Screw /usr. I still want to know how to recover the server after I accidentally deleted / last week...

      Stick in the fixit cdrom.

      You do keep a copy of /etc somewhere don't you?

      --
      _O_
      .|<
      The named which can be named is not the true named
  2. Re:Linux distro's already do this. by __past__ · · Score: 2

    Mostly because very, very few people think that this is a good idea.

  3. Re:25% by Anonymous Coward · · Score: 2, Informative

    This is just an option. The default way is still via static binaries.

    This won't change for some time (wheather it will change at all still has to be discussed).

  4. good and bad here by josepha48 · · Score: 4, Informative
    This is good in the case of people who want to run a system off a cdrom or floppy or flash memory. On a cdrom you don't need to worry about deleteing /usr cause it should be burned into the cdrom. Also any partitions that you need end up in ram / memory disks. /dev is a good example of a ram disk. By having a smaller /bin and /sbin one can suddenly have nice small routers / gateways using freebsd, instead of Linux.

    I'd imagine that if NetBSD and OpenBSD don't already have this ability it will be a matter of time as the BSD's share much between each other. Just look at the realpath vulnerability that they all were affected by.

    --

    Only 'flamers' flame!
    Does slashdot hate my posts?

    1. Re:good and bad here by vesamies · · Score: 3, Informative

      NetBSD is also using dynamic /bin, /sbin, not sure what OpenBSD is doing. This is not much of an ability since /usr/bin, /usr/sbin have always been dynamic, now everything is dynamic. Well, looks like everyone has all-dynamic system now, which is good.

    2. Re:good and bad here by MobyTurbo · · Score: 2, Informative
      I'd imagine that if NetBSD and OpenBSD don't already have this ability it will be a matter of time as the BSD's share much between each other.
      NetBSD has had dynamic root (with /rescue, etc.) in -current for months. :-)
    3. Re:good and bad here by JDizzy · · Score: 2, Informative

      I'd imagine that if NetBSD and OpenBSD don't already have this ability it will be a matter of time as the BSD's share much between each other.

      Silly didn't you know that FreeBSD is stealling this from NetBSD's dynamic world? Well they are. FreeBSD has also taken the idea of a /rescue incase one of the libs that is dynamicly linked by (say init) is damaged. This was also a NetBSD idea. I guess that leaves OpenBSD to make the changes, but they probably think dynamic bins is insecure or some shit because an attacker would simply replace a lib that contains harmfull code-fu.

      --
      It isn't a lie if you belive it.
  5. Re:Linux distro's already do this. by phoenix_rizzen · · Score: 5, Interesting

    "Because Linux does it" is not always a good reason to do something. Linux developers tend to throw anything and everything they can into the mix. BSD developers tend to watch what others do, research the pros/cons, then develop a plan on how to do it right ... before tackling the coding.

    Hence, while Linux distros tend to get things first, BSD tends to get things right. :)

  6. My understanding... by devphil · · Score: 3, Interesting


    ...was that, in earlier *nixes, sbin programs were always statically linked, to avoid problems with requiring /usr, or accidentally damaging the dynamic loader, or still functioning while restoring dynamic libs from tape, etc, etc.

    Not necessarily FreeBSD, but just some flavor of Unix. The versions of Digital Unix (under different names) which I teethed on were designed like this.

    It's always annoyed me that Linux's [/usr]/sbin was dynamically linked.

    --
    You cannot apply a technological solution to a sociological problem. (Edwards' Law)
  7. What about independent of external libs? by moncyb · · Score: 2, Interesting

    It's good that they are trying to save disk space, but why don't they just rewrite them so they don't use libc? Linux assembly.org is working on such a project, though it doesn't have to be in assembly. I've done some work using direct syscalls in Linux with C (look at /usr/include/asm--start with unistd.h). I haven't looked at FreeBSD in this way yet, but I think it can be done. At the very least, simple utilities like cp and ln could be written this way. Save disk space and be staticly linked--good all the way around.

    1. Re:What about independent of external libs? by Piquan · · Score: 2, Insightful

      Because there's a lot of logic in, say, PAM or NSS, which are needed often in /bin and /sbin. You could write that into each program, but then you'd have to update them all each time you found a bug or needed to add a feature. You could share a .o file between them, and then it's the same thing as statically linking them in the first place.

    2. Re:What about independent of external libs? by josepha48 · · Score: 2, Insightful

      You should look at the uClibc project which is trying to make a smaller libc for small floppy based distros. Also busybox, can be used to make a smaller system. Progamming in assembly is not pretty.

      --

      Only 'flamers' flame!
      Does slashdot hate my posts?

  8. Re:25% by JDizzy · · Score: 3, Insightful

    It really depends if your a pesimist, or an optimist. Yes 3 units of 12 is indeed 25%, and since it is 3 units over 12 to 15 it could be seen as an additional 25% extra time. The more correct way to look at it is from the point of view for the number 15. aka the boot was an entire 1/5 faster without dynamic bins.

    Besides, there have also been improvements in caching libs in conjunction with linking so that dynamic bin's always load faster. It could also be possible to make certain /bin and /sbin stuff static, but thats what /rescue is for with the crunched bins. Besides, this will only lead to a more optimised ld program and linking system there after. Not having the entire bulk of libc repliated allover the place in /bin and /sbin is entirly acceptible to me. Architecturally speaking that is a big faux pax to leave such a clutter. This is why elf was devised in the first place, and slow to implement Operating Environments is partly to blame for the hindering of cool features like dynamic linking tricks such as thosed used in pam and nss. This is, after all, the reason we have libraries.

    --
    It isn't a lie if you belive it.
  9. Re:25% by moncyb · · Score: 2, Interesting

    How about some utils which are written in assembly and are not dependent upon other libs? They're faster and smaller. You may want to look at LinuxAssembly.org's asm utils. They say it works for FreeBSD and other BSDs, though I haven't tested this myself (yet). When I tried them in Linux a few years ago, they weren't quite complete, but being small and independent has its advantages. When it's complete (maybe it is now?), I imagine these programs will be the choice for those who want to save disk space or speed up their system. Such a project would work in C. If it was in C, it would probably get more developers on board too...

  10. Re:Linux distro's already do this. by Arandir · · Score: 4, Interesting

    Hence, while Linux distros tend to get things first, BSD tends to get things right.

    Actually, BSD gets a lot things first. First to have a commercial support, first to have a free and complete operating system, and first to get sued by obnoxious companies :-). More recently, first to implement IP6, Serial ATA, Hyperthreading, etc. I would have to check, but I think they got USB and Firewire first as well.

    --
    A Government Is a Body of People, Usually Notably Ungoverned
  11. Blink by timotten · · Score: 2, Interesting

    enable users to build /bin and /sbin dynamically linked on FreeBSD

    I am having difficulty parsing this, and neither the article nor the comments here help me. This is my best guess. Someone please correct me.

    SITUATION: For some executable program $P in /bin or /sbin; for some executable library $L in /lib; there exists some subroutine $p in $P and some object $l in $L such that $p uses $l.

    OLD BEHAVIOR: When building $P, static-linker resolves name "$l", yielding an address or the desired data.

    NEW BEHAVIOR: When executing $P, dynamic-linker resolves name "$l", yielding an address or the desired data.

    DETAILS OF CHANGE: The kernel enforced the old behavior by examining every request sent to the generic 'dynamic-link' facility and blocked any requests which involved programs which happened to be in /bin or /sbin. The new behavior is achieved by removing the arbitrary, stupid prohibition.

    ALTERNATIVE DETAILS OF CHANGE: The old behavior was enforced by the build scripts for $P and $L; we didn't want our super-important $P to be disturbed if something as lame as the dynamic linker crapped out on us. The new behavior is achieved by changing some compiler flags. We will all die when the dynamic linker craps out.