4

I've always found it daunting and confusing how an OS hacker sets up their workflow. As a web-developer I find it easy to set up a workflow because web-sites run on servers and as such my OS is never touched. But an OS programmer, how do you do it? Do you develop on one machine and then somehow transfer code to the other machine? Do you develop on the OS you are developing, that last option seems rife with paradoxes? So how you do it?

P.S.

My similar Quora question still has no answer to this question...

Victor S
  • 143
  • 3
  • 1
    I'm confused by your question. Do you mean systems programming for OS or maliciously hacking an OS? – Pubby Oct 18 '11 at 13:05
  • 1
    @Pubby8 My assumption is programming an OS based on the term "hacked on" instead of just "hack" in the title. – Jetti Oct 18 '11 at 13:26
  • 6
    It's the media that have made "hack" a malicious term, when infact it's "crack" that is the malicious one. – badgerr Oct 18 '11 at 13:48
  • Please see this link if you want to get into it: http://www.dedoimedo.com/computers/crash-analyze.html This website is an amazing resource for hacking around the linux kernel – CamelBlues Oct 18 '11 at 17:44
  • I mean it as in 'programming'... – Victor S Oct 18 '11 at 19:09

5 Answers5

8

Ever since virtual machines like VMWare, KVM/Qemu or Virtualbox are widely (and freely for most) available, the job has become a lot easier.

Before that, boot managers like GRUB or LILO allowed control over what binaries to boot on (allowing you to keep at least one 'stable' OS on your machine).

I guess that before that, you'd have to dedicate a whole machine for your developments.

rahmu
  • 1,026
  • 6
  • 16
7

I've never poked at Plan 9, but for Unix-type OSes (Linux, BSD), I just setup a system running the kernel I want to hack on, get the compiler toolchain installed (not very difficult on most modern Linux distros), and start building kernels.

If I'm fooling with the kernel itself, I rig the boot setup menus (grub or whatever I'm using) to have an extra option for my dev kernels, and reboot into the kernel under development.

For hardware hacking it's a bit easier, as I usually work with loadable modules, and so I can just load and unload the module I'm developing.

Debugging isn't the easiest thing in the world when working on the kernel, but that's when you learn to read the system log files.

Michael Kohne
  • 10,038
  • 1
  • 36
  • 45
6

While I don't do this personally, it seems like what would make the most sense is using a Virtual Machine (such as VM Player). This would allow you to make changes right away and then fire up the VM and load it to see those almost immediately instead of having to go through the whole process of putting it on a separate machine.

Jetti
  • 5,163
  • 2
  • 26
  • 41
  • Agreed. Your build process should output a disk image that you can boot with qemu. When I worked on RMoX, that was what we did. –  Oct 18 '11 at 13:18
  • 5
    It also removes any chance of major screw-ups bricking your workstation. –  Oct 18 '11 at 13:32
  • @World Engineer: linux is not that easy to be screwed unless that's your intention because 1) you can have multiple kernels in multiple separated files; 2) chroot can be used to isolate other normal files. If you want to modify a kernel code and see how it behaviors, just compile it into a new kernel and load this kernel from boot loader. If it crashes, reboot and load the old kernel. I don't see how could that process screwing up your system. – Codism Oct 18 '11 at 16:32
  • 1
    @Codism - never underestimate the powers of a noob! – Jetti Oct 18 '11 at 17:04
0

The traditional way to do low-level hacking - I assume we're talking about the likes of device drivers - was to have 2 systems connected by a debug cable. This approach is still used to various degrees when developing embedded systems, although emulation and virtualisation make this largely a niche approach now.

The debug-cable approach means the controlling machine can inspect memory/registers on the slave even if the OS is in an unusable state - really valuable in some circumstances. JTAG debugging can take you even further, but I that's drifting off-topic into embedded systems.

Phil Lello
  • 875
  • 6
  • 14
0

The easiest and fastest way to do it nowadays is to use a virtual machine. Regarding Plan 9, even though it can be installed on QEMU, its distributed nature can only be exposed by using a client (computer with limited computing and disk space capabilities) server (multicore CPU server, huge capacity file server, etc.) organization.

sakisk
  • 3,377
  • 2
  • 24
  • 24