21 ms·
Experiment in booting Linux fast
- cm-t 13y agoBooting linux to the graphical server in 0.25 seconds ?
- hrkristian 13y agoShort answer: No. > qemu-kvm -nographic -kernel kernel -boot c -drive file=./kvm-squashfs,if=virtio -append "quiet root=/dev/vda console=ttyS0 init=/sbin/halt"
- michaelmior 13y agoNo, booting to a barely usable system :)
- hmottestad 13y agoAs the author says, it's just an experiment to see how fast he can get the filesystem and kernel up. There is no network and most functionality is missing. There are not services or anything else. So no point comparing this to Windows or OSX or anything else that requires any functionality other than kernel and filesystem.
- ambrop7 13y agoActually, if you use efficient software, you can get lots of stuff running in basically no time. In particular that means avoiding shell scripts and using as little external commands as possible. In fact, I'm pretty sure that if the author stopped using OpenRC and used systemd instead, to initialize the same things, it would have made a noticable difference. And a little self-promotion now :P As far as network config is concerned, using my NCD[1] software, it can be set up in no time (that is, not much more than the time it takes to negotiate a DHCP lease). In fact if you were super crazy, you would drop systemd and just run NCD as init, doing both basic initialization, as well as network config, all in one NCD process. I've even tried it some time ago, and got some very basic stuff working[2]. [1] https://code.google.com/p/badvpn/wiki/NCD https://code.google.com/p/badvpn/wiki/NCD [2] https://code.google.com/p/ncdinit/ https://code.google.com/p/ncdinit/
- hmottestad 13y agoRecommend you have a look at how Apple does DHCP negotiations. http://cafbit.com/entry/rapid_dhcp_or_how_do http://cafbit.com/entry/rapid_dhcp_or_how_do
- ambrop7 13y agoThanks for the link, that is some interesting info. I've only skimmed it, but yes, I'm aware that DHCP requests can be made without a discover phase (I've had to read the RFC to implement DHCP in NCD ;). I suspect that it's not actually directly doing some low-level ARP magic; rather the DHCP client may just be sending multiple DHCP request packets to past DHCP servers, and only the one whose automatic ARP request succeeds actually gets sent out. At least that'd how I would implement it.
- aidenn0 13y agoI actually experimented with a kvm image of gentoo where I replaced openrc with daemontools (plus some sh scripts I wrote to manage dependencies). I boot to a login with DHCP and NIS in under 5 seconds.
- nilved 13y agoI have an pretty standard Arch Linux installation with an SSD and my boot time is 1.5 seconds. My MacBook with an SSD takes nearly a minute.
- dman 13y agoDoes that exclude bios init time?
- dmix 13y agoNo it doubt it. I also ran Arch Linux on a Macbook Air 2012 w/ ssd and the bios init time was (way) longer than the Arch linux boot.
- jlgreco 13y agoBIOS init time on my chromebook pixel is absolutely a killer. The "OS verification is turned off" screen appears instantly, but then I have to manually press ctrl-l to make seabios start loading, and seabios isn't particularly snappy about loading then picking the harddrive so grub can kick off. That whole process takes maybe 4 seconds which I think is a bit absurd. My solution of course is to just suspend/hibernate instead of powering down, but it is a little disappointing that I don't get to play the "fast boot" game.
- dman 13y agoYes if you do unsafe things you can be fast. There is a hilarious open issue that google refuses to fix - critical information required to boot is written to a part that is battery backed. So if you have your pixel in developer mode, and have installed linux on it, just close the screen and and let your battery drain to zero - your pixel will become non bootable. All of this because storing this information in TPM where it would be persistent would "slow" down the boot. Speaking from experience - my pixel has lost data three times because of this.
- jlgreco 13y agoHuuh, that sounds pretty shit, I'll have to increase the frequency of my backups... Do you have a link to that issue handy?
- ubersoldat2k7 13y agoAnd that's a great point he implicitly makes in his "study". With Linux (or any OSS OS for that matter) you strip out all this different services, dig deep into the code, remove lots of stuff and you still get an OS working. Sure, you can't use LibreOffice, but that's not the point. You cannot get this sort of flexibility with the operating systems you mention. Good luck removing Internet Explorer from freaking Windows.
- pygy_ 13y agoWindows and OS X are actually "cheating" regarding their boot time. The UI becomes responsive before all services are loaded.
- ajanuary 13y agoI remember before I got my SSD I'd have to wait for the clock in the menu bar to update before I could use anything.
- andreif 13y agoI really hate this. My MBA gets to sleep again before I can type my login password, so I have to press something (usually arrow) to keep it awake till UI responds. If I type the password before UI responds, then there is a good chance that the first characters are lost. I should probably reinstall the system or do some clean up, but it is still an UI/UX issue.
- rguldener 13y agoHad a similar issue (screen would just go black again a random interval after wakeup from sleep and have to login again). Resetting the system management controller did the trick for me: http://support.apple.com/kb/HT3964 http://support.apple.com/kb/HT3964
- okrasz 13y agoAmazing! I would like to see such experiment with "boot to browser" on real hardware.
- ebtalley 13y agoI came here to post something like this as well. I'm less concerned with bootup time and more concerned with how much time it takes to get to actually using the system. its still in the 5~10 minute range for me.
- chromaton 13y agoCan you elaborate on that? I've never seen bootup on Linux take that long unless something goes wrong (e.g. fsck fails).
- weavie 13y agoWhat on earth takes so long?
- ds_ 13y agoAre you including the time it takes to open whatever applications you need to be productive?
- ebtalley 13y agoabsolutely, gnome boots up very quickly but the churn that happens right after boot slows opening applications to a crawl.
- Semaphor 13y agoThat seems weird. My PC is rather slow for a dev machine (+ a few lowkey games): i3 @ 3.3GHz, 16GB DDR3 RAM, GTX 550 TI, Samsung SSD 830 for the OS. Windows 8.1 Professional. I just took some non-exact measurement (stopwatch) from pressing the power button: 26s to login screen, another 13s from pressing enter after login to having Chrome show me a useable Outlook Web Access. And I haven't performance optimized anything. Steam, 2 VPN clients, Trillian and Directory Opus all load on login.
- jnazario 13y agothe shutdown loop in one of the blog posts there - sync(), then sleep(2) - has me worried he may get filesystem corruption at times under those circumstances. i could be wrong, but i recall that sync() will return immediately even though it's not done synchronizing the filesystem writes (for a filesystem that needs that). as such, the sleep(2) gives it some time to get that done. is that a correct understanding? if so, is that a reasonable risk i see (filesystem corruption at times)?
- viraptor 13y agoI've definitely seen `sync` itself waiting/blocking (especially if you use fuse for something network based and disconnect the cable first), but whether it's guaranteed or not... that's an interesting question. Edit: after some googling: On Linux, sync is guaranteed only to schedule the dirty blocks for writing; it can actually take a short time before all the blocks are finally written. The reboot(8) and halt(8) commands take this into account by sleeping for a few seconds after calling sync(2). This page describes sync as found in the fileutils-4.0 package; other versions may differ slightly. So it doesn't look like the writes are guaranteed to take place. Just a best effort + wait + pray :)
- deleted 13y ago[deleted]
- jabiko 13y agoInteresting. http://linux.die.net/man/2/sync http://linux.die.net/man/2/sync says On Linux, sync is guaranteed only to schedule the dirty blocks for According to the standard specification (e.g., POSIX.1-2001), sync() schedules the writes, but may return before the actual writing is done. However, since version 1.3.20 Linux does actually wait. (This still does not guarantee data integrity: modern disks have large caches.) So it seems like the sleep(2) is there to give the disk enough time to write the cache data.
- igravious 13y ago
- moneyrich4 13y agoI would be curious how to achieve similar or better results on other distros, particularly ubuntu.
- claudius 13y agoAt this point, I don’t think that the distro matters much, as there is quite exactly nothing there except for the kernel, udev and the very first steps of startup.
- DanBC 13y agoThere's the famous "5 second boot" for Fedora on an EEE PC 701. That's a weak machine with a small, old, SSD. It's an "honest" boot time - from power on to desktop up with idle CPU and disk. (https://lwn.net/Articles/299483/ https://lwn.net/Articles/299483/) Here's an article trimming boot time of Fedora 17 to 3 seconds. (http://www.harald-hoyer.de/personal/blog/fedora-17-boot-optimization-from-15-to-3-seconds http://www.harald-hoyer.de/personal/blog/fedora-17-boot-opti...) There's some overlap between the two different approaches. If you wanted some esoteric hardware you could make an always powered RAM disc.
- rwmj 13y agolibguestfs can boot & shutdown a small appliance in around 3½ seconds. However we have to use the standard distro kernel, distro udev and distro KVM (for security policy reasons we cannot ship our own). We could do a lot better if we could custom compile everything. http://libguestfs.org/guestfs-performance.1.html http://libguestfs.org/guestfs-performance.1.html
- RexRollman 13y agoI recently started using Linux again and installed Arch Linux. This was the first time I had used it since the init system was switched to systemd and its speed is impressive. Both booting and shutting down are very fast and I really like the journal feature. That said, when I installed a virgin system on Monday, I was sad to see that systemd is creating a .local directory in the home directories of users (even root). This is on a system with no Xorg what-so-ever. Call me old fashioned but I don't think an init system should be creating directories in a user's home directory.
- rfnslyr 13y agoIs Arch Linux still near impossible to install flawlessly on first try? Reporting in @ 7 tries here before I finally got it working.
- ihodes 13y agoI've installed it about 7 times, and never had a problem. Haven't had to deal with drivers, though, as I always use it on server only.
- andypants 13y ago3 tries here, although I broke some things by the time I rebooted the next day.
- agumonkey 13y agoDescribe your desired setup. For a simple xorg / xmonad / emacs / chromium[1] it's a few traditional commands and a few arch specific commands[2]. [1] single GPT partition, no lvm, no encryption, no fancy devices. [2] simple unix tools : disk, mkfs., *chroot. arch : netctl (network setup), pacman and a bit of systemd (not traditional yet ;)
- deleted 13y ago[deleted]
- klrr 13y agoYou mean human-errors, or do you mean that Arch breaks itself mistakenly? If so, it might be worth reporting the problem. I used Arch a year ago or so(but switch to CRUX due to systemd), and I've never had any problems that wasen't me messing up things.
- agumonkey 13y agoWhile looking for this : http://www.youtube.com/watch?v=-l_DSZe8_F8 http://www.youtube.com/watch?v=-l_DSZe8_F8 (boot to embedded real time application around 1 sec) I found this more recent desktop talk http://www.youtube.com/watch?v=aVcfjs02Srs http://www.youtube.com/watch?v=aVcfjs02Srs (Integrating systemd: Booting Userspace in Less Than 1 Second - ELCE 2011)
- DanBC 13y agoIf I had the money I'd set up a small yearly prize for "quickest boot on an RPi". Have some rules for what is or isn't allowed, and maybe different categories (IE, "anything goes" for people who want to overclock the hardware) but concentrating on having a usable system when you finish timing. The boot to a desktop in 5 seconds on an EEE PC 701 is still impressive. Noodling through the author's site it's pretty interesting to see what they did to cut times, and they're honest about this just being about boot time. Does anyone else do this kind of optimization, or does it carry too much risk or cost?
- ollydbg 13y agoKickstarter?
- masklinn 13y ago> and they're honest about this just being about boot time. reboot, not boot, boot was already a non-issue after booting into sh and removing most of the services. The later posts deal with shutdown, mostly by removing sleeps... which are there to wait for lying hardware to finish flushing its caches. So some of TFA's fixes are really recipes for data corruption if you're not using a readonly FS (which TFA is, so it's no problem for his precise use-case).
- leoh 13y agoHmmm. For hard disks, a call to fsync could be sufficient instead of the sleeps, no?
- mro 13y agoNo: http://brad.livejournal.com/2116715.html http://brad.livejournal.com/2116715.html
- magila 13y agoThat blog post is from 2005. There was a major rework of how the block layer handles flushes back around 2010 and I'm pretty sure the issue he was having with fsync not being reliable has been resolved.
- Beltiras 13y agoHere's the real world thing we need: Start enough services to enable: networking, cron, one wsgi server and a database. I need to do this next month for a deployment.
- virtualwhys 13y ago# me> systemd-analyze Startup finished in 2.480s (kernel) + 623ms (initrd) + 570ms (userspace) = 3.674s Fedora 18 on Dell Precision M4700 Not quite 0.25 seconds though ;-) Here's one way to get there: http://www.harald-hoyer.de/personal/blog/fedora-17-boot-optimization-from-15-to-3-seconds http://www.harald-hoyer.de/personal/blog/fedora-17-boot-opti...
- nine_k 13y agoExperiments like that might benefit server VMs most. How soon your nodes go up after a reboot or after spinning up a new one can matter. But, of course, you'll not be cutting corners as the poster does; you'd need a usable system. On a desktop or laptop, you probably use hibernation, and your biggest time sinks are typing your password and having your network connection go back up. Rebooting these things is rarely needed.
- sounds 13y agoApple "cheats" on that regard, getting your wifi back up after sleep. http://cafbit.com/entry/rapid_dhcp_or_how_do http://cafbit.com/entry/rapid_dhcp_or_how_do http://news.ycombinator.com/item?id=2755461 http://news.ycombinator.com/item?id=2755461 <-- good discussion
- saosebastiao 13y agoFor comparison, does anybody know what kind of boot times to expect with CoreOS?
- deleted 13y ago[deleted]
- eliben 13y agoChrome OS boots Linux really fast and gives you a usable system within seconds :)
- metric10 13y agoFor extremely small values of "usable"... I attended Google I/O this year and received a Pixel. It's a really nice piece of hardware, but as a developer it's worthless. I saw Google presenters using a lot of Macs and a ThinkPad running Linux. Not a single Chromebook.
- joestringer 13y agoWith secure shell, you can make it significantly more useful. Of course, you still need a box to SSH into. https://chrome.google.com/webstore/detail/secure-shell/pnhechapfaindjhompbnflcldabbghjo?hl=en https://chrome.google.com/webstore/detail/secure-shell/pnhec...
- eliben 13y ago/rant/ Old news, someone on HN assumes everyone is a developer, and in the mean-time 99.9% of the market are not
- frezik 13y agoI've noticed that dhcpcd always gets the lease, then broadcasts on the network to see if anybody else has that address, waits for a timeout, and then proceeds. This seems like an unnecessary waste of boot time when you're on uncomplicated home networks; the DHCP server can be trusted to give a fresh address almost always. Doubly so if you've set your AP to static MAC address mappings. Is there a way to shut that off, or a Linux DHCP client that doesn't do that?
- rake 13y agoWhy just not use static IP addresses instead?
- simcop2387 13y agoSwitching to dhclient instead of dhcpcd will usually help that. Once it has an address it will go into the background during that check if the ip address is actually available. You can stop that by running it with -d if you're debugging a bad network.
- malone 13y agoThat check is actually recommended by the RFC, but using the --noarp switch should disable it.
- ohazi 13y agoFastest "reasonably complete" boot I've ever seen was on a BeOS setup I had on a 600 MHz laptop (~2000?). ~4 seconds to the login prompt, and another 1-2 seconds to finish "thinking" after login. Man, that thing was fast.
- agumonkey 13y agoI didn't know about BeOS booting process, but I stumbled upon good old demos[1] recently, I remember how I was amazed back in the days. I'm still amazed, more than before. Sad. [1] http://www.youtube.com/watch?v=BsVydyC8ZGQ http://www.youtube.com/watch?v=BsVydyC8ZGQ
- hcarvalhoalves 13y agoBeOS was super responsive. I had the opportunity to test the last release on some early MMX I had and was blown away by how responsive it was compared to Windows, or even to my Slackware installation.
- e12e 13y agoI also seem to recall that the somewhat legendary QNX demo floppy (a 1.44 floppy image that booted to a full graphical desktop) was also pretty fast to come up. I can't recall exactly how fast though. On a side note I somewhat recently booted up our old Amiga 2000, running an upgraded cpu (68020 I think, maybe 10 Mhz) -- booting off its ancient 40 MB scsi hd -- and I was surprised how slow bootup was. Can't remember that I gave bootup time much thought when the thing was new (then again, most reboots were done to boot into a game off of floppies...).
- dchichkov 13y ago:)
- vacri 13y agoIn contrast, my win98SE desktop took 4'30" to boot back in the day. I know this because I decided to time it after yet-another-BSOD-while-gaming...