Slashdot Mirror


Reboot Linux Faster Using kexec

An anonymous reader writes "Even if your work doesn't require you to reboot your Linux machine several times a day, waiting for a system to reboot can be a real drag. Enter kexec. Essentially, kexec is a fast reboot feature that lets you reboot to a new Linux kernel -- without having to go through a bootloader. Faster reboot is a benefit even when uptime isn't mission-critical -- and a lifesaver for kernel and system software developers who need to reboot their machines several times a day. Kexec is currently available on the x86 32-bit platform only."

59 comments

  1. pfft. by hookedup · · Score: 4, Funny

    I get paid by the hour. So how would this help me? :)

  2. Get Windows by Anonymous Coward · · Score: 5, Funny

    You're paid by the hour and use Linux?!?!?!. What you need is Windows, and make sure you don't have a firewall or a virus checker program. You'll greatly increase your billable hours.

  3. I thought... by me98411 · · Score: 0, Redundant

    Ctrl+Alt+Del is the fastest way to reboot :)

    1. Re:I thought... by noselasd · · Score: 1

      Here Ctrl+Alt+Del asks me wether to log out or reboot/poweroff. And the reboot option is no "fast" reboot.

    2. Re:I thought... by cyb97 · · Score: 2, Funny

      well kexec is brought to you buy the same guys that invented ctrl+alt+del. I guess you can think of it as the next-generation of the three fingered salute ;-).

  4. Init scripts... by ErisCalmsme · · Score: 4, Interesting

    For me what takes the longest isn't the bootloader, it's the starting and stopping of services. This is still cool though.

    --
    Chaos is Divine *
    1. Re:Init scripts... by cyb97 · · Score: 0

      how many services do you actually need on a workstation?

    2. Re:Init scripts... by phaze3000 · · Score: 4, Insightful
      You're quite right, the starting and stopping of services takes much longer than the bootloader.

      What takes even longer though, and is avoided by use of kexec, is all the BIOS stuff. This can take an age, particularly with SCSI controllers in my experience.

      --
      Blaming GW Bush for the Iraq war is like blaming Ronald McDonald for the poor quality of food.
    3. Re:Init scripts... by ErisCalmsme · · Score: 1

      Well my point wasn't that it takes long for my laptop, my point was that starting and stopping services when I reboot takes longer than grub, where the total reboot time = (time it takes for the bios and grub) + (time it takes to stop services) + (time it takes to start them again)

      --
      Chaos is Divine *
    4. Re:Init scripts... by zenyu · · Score: 1

      For me what takes the longest isn't the bootloader, it's the starting and stopping of services. This is still cool though.

      True for me too, but if I were developing the kernel I would probably just reboot to single user mode.

    5. Re:Init scripts... by Fweeky · · Score: 2, Informative

      Try using a system which doesn't kill each service one by one in a serial manner; the difference between shutdown speed in, say, Slackware or FreeBSD compared with RedHat and friends is quite significant. You'll have to learn to live without the fancy green [OK]'s though :)

    6. Re:Init scripts... by Godman · · Score: 1

      Yes, I agree. What really bugs me is that if my ethernet connection isn't currently activated it takes several minutes before it gives it a [failed] and moves on. O.o

      --
      I have this really funny quote that I like to put here. Unfortunately, there's this really annoying thing called a char
    7. Re:Init scripts... by Paul+Jakma · · Score: 1

      So dont start and stop them. Just close the lid and let it suspend to disk. I think I had over 100 days uptime on my laptop because of that at one stage. (Course, it does mean you need a laptop with decent APM support, or for ACPI you need to use the swsusp patch to have linux do the save/restore as ACPI itself cant do it).

      --
      I use Friend/Foe + mod-point modifiers as a karma/reputation system.
  5. Avoid BIOS by crow · · Score: 3, Informative

    Rebooting a box that has SCSI drives means that the BIOS does a scan of the SCSI bus that takes a while, and then the new kernel does the same thing. That's the slowest part of my boot process, and it looks like kexec will bypass the BIOS half of it.

    1. Re:Avoid BIOS by cyb97 · · Score: 3, Informative

      usually the slowest part of booting a scsi-kernel is "waiting for scsi-devices to settle". Which is usually set to 15s for quite a few drivers in the kernel. Bumping that down to a resonably low number like 2-3 s (usually enough for modern devices, would skimp 10-13s of you boot-time ;-)

    2. Re:Avoid BIOS by pavon · · Score: 1

      Yeah the thing that kills my reboot time on x86 boxes is definately the BIOS, in particular the "Verifying DMA Buffers" check that cannot be turned off and adds about 20 seconds to the boot time.

    3. Re:Avoid BIOS by iguana · · Score: 1

      Not just the SCSI cards but those **** Intel EExpress cards that wait for 4 seconds for ctrl-s before continuing the boot.

      Or, on cheaper hardware (like mine), those IDE controllers scanning the bus for ATA100 devices. I have an el-cheapo whitebox that takes almost 2 minutes to get to the GRUB prompt.

  6. Equivalent by Anonymous Coward · · Score: 1, Informative

    In 'Windos' terms, this is equivalent to the 'shift+restart' feature on earlier windows. You would press shift while hitting restart and it would only restart without rebooting the machine.

    1. Re:Equivalent by Anonymous Coward · · Score: 0

      -1, No Fucking Shit

  7. BIOS by ggeens · · Score: 4, Informative

    The boot loader spends most of its time waiting for the user to press a key, so they can enter custom boot parameters. If you set the timeout to 0 in LILO or GRUB, loading the kernel happens almost instantly.

    The BIOS startup routine is longer, especially if you have a SCSI card. (I have 2 of those in my machine, and they account for most of the wait during startup.)

    --
    WWTTD?
    1. Re:BIOS by ErisCalmsme · · Score: 1

      I see what you guys mean about the BIOS, I just mentioned the bootloader 'cause it's the sub-title of the article, i.e. "Eliminate the bootloader for greater uptime"

      It should probably say "Eliminate the BIOS for greater uptime" ?

      --
      Chaos is Divine *
  8. Quicker reboots? by sweede · · Score: 3, Informative

    If you read the article, it says that kexec doesnt do a normal,clean shutdown, so you have to stop all running programs and unmount all partitions before running kexec to do a reboot.

    When i boot into linux, it takes longer to start up services than it does to go through the BIOS, SATA raid controller BIOS, grub's 3 second time out, and the loading of the linux kernel (before initd takes over).

    however, this program is still in ints infancy and no doubt someone will create an initd that can utilize kexec in a run level for rebooting without a full shutdown. But I dont think it will be that much quicker.

    --
    I follow the SDK and GDN principles.. Spelling Dont Kount, Grammer Dont Neither
    1. Re:Quicker reboots? by n1ywb · · Score: 1

      It would be a trivial task to write a wrapper script that automates stopping processes and unmounting partitions. I bet somebody already has.

      --
      -73, de n1ywb
      www.n1ywb.com
    2. Re:Quicker reboots? by walt-sjc · · Score: 1

      Try rebooting on a server like a HPaq DL380. The BIOS portion of the boot is 4 times longer than the linux portion. My desktop with SATA is about equal, so kexec would still speed that up by a factor of two.

    3. Re:Quicker reboots? by Marillion · · Score: 2, Informative
      Perhaps something like, dropping to run level 1 first, then remount all drives as readonly.

      # init 1
      # mount -o remount,ro -a
      # kexec ...
      --
      This is a boring sig
  9. Sounds great, but... by You're+All+Wrong · · Score: 5, Insightful

    $ uptime
    17:44:44 up 439 days, 7:50, 7 users, load average: 1.07, 1.02, 1.00

    I think I'll install it some time in 2005, maybe.

    Actually it's not so great - if you're mucking around with different kernels etc. then what you really want is virtualisation, not fast reboots. VMWare, or Bochs, or whatever. At least that's what I'd prefer, YMMV.

    YAW.

    --
    Your head of state is a corrupt weasel, I hope you're happy.
    1. Re:Sounds great, but... by Drantin · · Score: 1

      Wouldn't the emulator have to emulate the target hardware as well as the standard VGA/VESA, soundblaster, etc?

      --
      Actio personalis moritur cum persona. (Dead men don't sue)
    2. Re:Sounds great, but... by mausmaki · · Score: 0

      VMWare is 3vil.. you want UserModeLinux.

  10. Nice, but not critical. by Blackknight · · Score: 3, Funny

    Yeah, that 90 seconds to reboot a server is killing me.

    1. Re:Nice, but not critical. by jovlinger · · Score: 2, Insightful

      [ok, I get the joke... but]

      well, if you're chasing 5 nines, you only get 315 seconds downtime a year.

    2. Re:Nice, but not critical. by Molt · · Score: 1

      If you're chasing that kind of reliability the way forward is redundant machines behind reliable load-balancing of some sort, not fudging about with new and relatively untesed 'fast reboot' code which could well get up and bite you in the back-end server at any time..

      --
      404 Not Found: No such file or resource as '.sig'
  11. Famous last words: by jfisherwa · · Score: 4, Funny
    $ uptime
    17:44:44 up 439 days, 7:50, 7 users, load average: 1.07, 1.02, 1.00
    .. Now you've done it.. ;)
  12. Useful for other reasons than speed by Anonymous Coward · · Score: 5, Interesting

    While there is a marginal speedup in skipping the BIOS startup, the main benefit for me is the ability to choose which kernel to boot remotely. I don't have physical access to my colocated system and permanently setting GRUB to boot a new kernel is a bit scary. With kexec I can choose which kernel to boot from ssh. If it doesn't work out I don't have to pay the colo people to reinstall the box. They just hit the reset button :)

    1. Re:Useful for other reasons than speed by nilsjuergens · · Score: 1

      If you get marginal speedup you have never used "real" server hardware.
      The Bios and other hardware init stuff on our Dell Servers takes (compared to the speed of the machines) ages.

      --
      -- Having problems sending big files over the net? Try out Efisto (http://efisto.org)
    2. Re:Useful for other reasons than speed by sjames · · Score: 1

      The faster the machine, the slower the POST and floppy drive. It seems to be the case most of the time since the first XT running faster than 4 MHz.

  13. What's taking it so long? by Brandybuck · · Score: 3, Interesting

    I normally use FreeBSD. But recently I took a Linux device drivers class. The first thing I noticed was the extremely slow booting of Linux. Why?

    Under FreeBSD it takes about one second from the boot manager handing off to the root partition to start seeing device probing messages. But under Linux the same thing takes about twenty seconds. From appearances, it seems that the root partition LILO is merely loading the kernel, but there's no way that should take twenty seconds. Can it?

    --
    Don't blame me, I didn't vote for either of them!
    1. Re:What's taking it so long? by 0x0d0a · · Score: 2, Informative

      You are right. Something is decidedly wrong on your system. It takes me, IIRC, under a second to go from "bootloader screen" to "kernel spitting out init data". It is definitely not twenty seconds.

      Now, the time spent sitting in init scripts when a desktop could be brought up much faster and initscript loading continued in the background is an arguable issue...

    2. Re:What's taking it so long? by hyc · · Score: 1

      I'm a bit skeptical that running the init scripts in the background will speed things up appreciably. On a box with only a single system disk, spawning a lot of processes at once is only going to thrash the disk and make all of the startup *slower*, especially if those services all start reading their config files, prepping their application caches, etc...

      My Windows XP laptop starts up this way, and even after optimizing the disk, startups are slow because of all of the startup programs trying to initialize themselves simultaneously. Yes, Windows has other problems working against it, but the fact remains - multitasking/job control is not the cure for slow system startup.

      I never use X on my Linux box, because the startup time to get the X server and a window manager going is too annoying. If you think having that startup in parallel with the regular system init scripts is going to get you logged in faster, you're sadly mistaken. You can't do anything useful until your home directory is mounted anyway, and there's a bunch of network services that you probably need (on my system, named, dhcpd, dhclient, and sshd) before it's worth thinking about.

      To me the obvious way to make this fast is to put the boot and root filesystems on a solid state disk. Swap doesn't matter for bootup unless your system is woefully short of main RAM... It's the disk seek time that kills you when you try to start a slew of processes in rapid succession, no matter what your OS.

      --
      -- *My* journal is more interesting than *yours*...
  14. List *your* uptime! by 0x0d0a · · Score: 1

    I'm just curious -- anyone reading this that can beat the listed uptime?

    1. Re:List *your* uptime! by vericgar · · Score: 2, Insightful

      uptime that high == insecure

      I know there have been several vulnerabilites in the linux kernel in that time. (search google for mremap).

  15. Speeding up boot by 0x0d0a · · Score: 4, Insightful

    The biggest gain I can think of would be moving from an initscript system in which all services are serially numered to one where dependencies are expressed with a directed acyclic graph. All you have is "X depends on network being up" "cups depends on network being up", etc.

    You could even leave in the old numbers (or *generate* the old-style numbers from the acyclic graph) and do serialized booting if necessary for troubleshooting.

    There's no reason not to have as many service starting at once as possible, and several benefits.

    * Boot time would decrease because Linux has a good disk scheduler and keeping more outstanding requests keeps the scheduler well-fed with requests to optimize the order of.

    * Boot time would decrease because Linux service startups are not constantly hitting the disk. Some hit the network or the CPU. You want to keep a steady stream of requests to the disk running.

    * User-percieved boot time would decrease because the first thing that the user generally cares about is the password dialog (and subsequently their desktop). With a DAG, a partial ordering of the boot sequence, the init system has the freedom to load X up as soon as possible and get the user to a password prompt, and continue loading less important things (ntp and the like, sendmail, etc) in the background.

    1. Re:Speeding up boot by oojah · · Score: 2, Informative

      The biggest gain I can think of would be moving from an initscript system in which all services are serially numered to one where dependencies are expressed with a directed acyclic graph. All you have is "X depends on network being up" "cups depends on network being up", etc.

      You mean like in Gentoo?

      Roger
      --
      Do you have any better hostages?
  16. It's not the kernel boot time by bfandreas · · Score: 1

    but the setup time of my regular tools that makes rebooting such a drag.
    I usually have 10-12 telnet sessions open, monitoring log files, machine load and application layer protocol network traffic for a couple of servers.
    This takes an awful lot of time to set up. Not to mention IDE boot times, finding the right documentation and whatnot. Thank god I wasn't vulnerable to the newest and brightest Windows worm that got my whole company. Anything forcing me to boot my Debian box would really tick me off. YMMV.

    --
    20 minutes into the future
    1. Re:It's not the kernel boot time by hyc · · Score: 1

      Yeah, I totally identify with this. Reboots were still a pretty infrequent thing for me, and I could use programs like screen to keep my context around if I was just logging off for an evening.

      Windows suspend/standby is worthless for this; when the network drivers go to sleep Winsock kills all your connections. (Which, by the way, is a violation of the OSI stack architecture.) And my Win XP laptop has proven to be pretty unreliable after about 2-3 suspend/resume cycles (not to mention the consistent BSOD from the ATI Mobility Radeon driver when I try to use standby/resume. sigh...).

      Oh well. You can always customize your .Xsessionrc or whatever to re-establish your persistent telnet sessions and such.

      --
      -- *My* journal is more interesting than *yours*...
  17. Paralising init by oliverthered · · Score: 1

    Some services spend quite a while waiting for things to happen, e.g. initilising a cd-rom drive.

    Services that are independant could be started in parrell so that waiting for a cd-rom drive &co wouldn't slow the whole things down. e.g. I could load the cd-rom drive, networking and keyboard mapping, then while the cd-rom drive is still waiting for an interrupt start up apache.

    --
    thank God the internet isn't a human right.
  18. You mean like in FreeBSD? by Ayanami+Rei · · Score: 2, Informative

    You mean like BSD init + rcorder, which predates Gentoo.

    --
    THIS THING CAN TURN ON A DIME, MACROSSZERO STYLE ALSO FUCK BETA, ~NYORON
    1. Re:You mean like in FreeBSD? by oojah · · Score: 1

      Yeah. I realise that and wasn't trying to imply that Gentoo was the first to do so, I just prefer to talk about something that I actually know about (ie. not FreeBSD :)

      Cheers,

      Roger

      --
      Do you have any better hostages?
  19. Experimental kernals... by m4k3r · · Score: 2, Insightful

    Sounds like just the thing for testing a newly compiled kernel without modifying the bootloader. I'd much prefer to test the kernel on the "real" system then some sort of virtualisation (VMware etc) using kexec. Much faster than accidentally screwing the system, trying to find a bootable cd etc.

  20. Remote Systems by osewa77 · · Score: 0, Offtopic

    As mentioned before, remote systems are where this utility would really shine. If there was a simple way to tell a kernel to reboot on error instead of locking up the system, then it'd be the perfect system for testing various kernels on a remote system. No need to call your colocation host and ask for a manual reboot! Again, there are projects being developed to reduce the imit time for Linux. On such systems, the relative speed of this approach wil be significant. And, yes, 150 seconds can be a lot of time to wait for a reboot.

  21. You mean like in NetBSD? by cperciva · · Score: 1

    Give credit to whom it is due: FreeBSD just borrowed the rcorder system from NetBSD.

  22. Is this the end of this journey of discovery? by Ayanami+Rei · · Score: 1

    I was hoping somebody would chime in saying NetBSD stole it from somewhere else. Something unexpected, like AcornOS or some such.

    --
    THIS THING CAN TURN ON A DIME, MACROSSZERO STYLE ALSO FUCK BETA, ~NYORON
  23. Yes, this is the end. by cperciva · · Score: 1

    Luke Mewburn wrote the new rc.d system for NetBSD.

  24. kloader by Ushakov · · Score: 2, Interesting

    In NetBSD kloader(4) does a similar job. It is used on HPC and game console ports.

  25. Re:Windows by Anonymous Coward · · Score: 0

    Another MStrolll spewing FUD I see. Don't see the point, considering that it is mainly linux developers who are looking at this post,and they'll know better than that.
    Linux has given me uptimes of up to two months, and it would be longer if my
    house had better wiring or if I had a UPS (Uninterruptable Power Supply).
    In Windows, I have never gotten an uptime of more than a few days. And the only
    day that I did not have an application crash was teh day I left the system
    untouched for a day (well two days, but it somehow crashed on the 2nd day
    anyways....)

    Personally, I won't be using kexec that often since I like to leave my system
    on as long as possible. I don't reboot often enough for my BIOS or kernel
    loading times to make a difference. (init scripts, and the filesystem checks
    that happen every 26 mounts, would benefit from a speed up of course, but
    thats another topic.) In windows, I had to reboot so often that even if it had a
    shorter loading time (it didnt for me) it would still be too long.

    Even if Linux booting was forever slower than Windows, it would be paid off by
    the fact that Linux stability is forever better than Windows...