If you use the same compilation options as Ubuntu, and you also install the corresponding modules, and you regenerate the initramfs, this will work. Get Ubuntu's configuration file, put it in the kernel compilation directory, and run make oldconfig
.
It would be less error-prone to Ubuntu's own compilation process. Get the kernel source package, substitute the kernel source, and compile.
If you build your own kernel with your own compilation options, there's a good chance that you'll forget some critical option or module. The kernel is broken down into lots of tiny bits so that each system can load only the bits that it needs. Run make localmodconfig
to configure a kernel that includes all the currently-loaded drivers, and thus will be suitable for the machine it's compiled on (at least as long as you don't plug in a new removable peripheral, or use a new network feature, etc.).
See Configuring, compiling and installing a custom Linux kernel for a more extensive guide to configuring and compiling a kernel.
There's rarely much benefit in getting the latest and greatest kernel. It won't let you run more programs: very few programs care about recent kernel features. You should only do it if the new kernel has something you need, such as a driver for your hardware. If you just want to play, do it in a virtual machine, perhaps with a bleeding-edge distribution rather than Ubuntu.