The following instructions apply to building a kernel from upstream. Personally I find that simplest. I don't know how to obtain a tree with the ubuntu patches applied, ready to build like this.
(1) Theoretically the way you build kernels in more reasonable
timespans for testing is supposed to be
cp /boot/config-`uname -r` .config
you don't need to enable anything newer, so - only problem is this
breaks if they renamed stuff:
now disable all the modules not currently loaded. (Make
sure you have all your usb devices you need plugged in...):
It worked for me recently, so might be useful. Not so well the
previous time I tried it.
I think I got it from about one hour down to ten minutes. Even after
make localmodconfig it's still building crazy amounts of stuff I don't need. OTOH actually finding and disabling that stuff (e.g. in
make xconfig) takes a while too (and even longer if you mistakenly disable something you do need).
I guess it's worth knowing it exists, it's just not guaranteed to make you happy.
(2) But you don't actually need two-hour builds for each modification to your "module". (It actually needs to be a builtin if you're implementing a new system call).
make will just recompile your modified files and integrate it into a kernel binary. Therefore - for the specific situation you describe - it would be simplest to accept the initial two-hour build. Getting Kconfigs right is just a pain.
It's useful to make Kconfigs (e.g. minimal ones) however if you want to port to different kernel versions, do
git bisect, test different build options, etc.