In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-08 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article will explain in detail about the Ubuntu kernel basic system reduction and compilation example analysis, Xiaobian think it is very practical, so share it for everyone to make a reference, I hope you can gain something after reading this article.
Ubuntu kernel reduction and compilation
1. Install make ,gcc, make-kpkg, run menuconfig, etc. and compile Ubuntu kernel related tools. The installation command is as follows: $sudo apt-get install build-essential kernel-package libncurses5-dev If you cannot install, check/etc/apt/sources.list
2. Extract the source code to any directory, where we extract it to/usr/src
tar -xvf linux-2.6.28.N -C /usr/src cd /usr/src/linux-2.6.28.N
3. Start pre-compilation preparations
$ sudo make mrproper
A lot of tutorials on the Internet say to copy the config of the Ubuntu kernel you are using now for reference. According to experiments, it is not needed. ubuntu and debian will automatically do this step. However, this command could be learned. Of course, you can copy the previous configuration. Command: Code:cp /boot/config-`uname -r` ./. config
Start configuring Ubuntu kernel options
a, sudo make menuconfig, configure Ubuntu kernel as needed.
5. Compile the Ubuntu kernel
$sudo make-kpkg clean This command does not seem to have super permissions, many data say yes, but this is not a matter of principle.$ sudo make-kpkg --initrd [--append-to-version= arbitrary name] kernel_image [kernel-headers]
e.g. make-kpkg -initrd kernel_image
kernel-headers (kernel specific version number such as 2.6.28.3, if *** compiler if specified kernel-headers error.) The description can be replaced with make -j2.
6. Install the Ubuntu kernel
Completion of compilation is installation work. The compiled Ubuntu kernel is located one level up. Includes linux-headers-... -_ i386.deb and linux- image-... - i386.deb two files, if you do not engage in development, as long as you install the Ubuntu kernel can, the header file later to use when to say.
Installation related commands: $ cd..
$ sudo dpkg -i linux-image-(press tab) Description: 1. If you compile with make -j2, you can use make install and make modules_install instead
2. If you compile directly with make, you need to generate the initrd file with,mkinitramfs -o initrd.img-2.6.28.N 2.6.28.N and add the new Ubuntu kernel option to/boot/grub/menu.lst.
3. In/boot/grub/menu.lst, uuid can be omitted. The method can comment the contents of/etc/initramfs-tools/conf.d/resume with #, update-initramfs -u -k `uname -r`(if Kinit: no resume image,doing normal boot...) If this error is reported, it can be solved by this method.
II. Basic system reduction
Generally there are two ways to delete the original system, delete useless files; another way is to add files in the new file system, we can use *** methods to do, the simpler way is to copy all files to a new disk partition, operating system file reduction, if the deletion of files causes the system to fail to start can copy files from the original system.
First, we delete the commands and delete those that are not commonly used.
2. Delete the dynamic library and use ldd comand to determine the dynamic library used by the file. (Try to compile all modules into the Ubuntu kernel rather than into modules, which reduces the difficulty of file system pruning.), Delete redundant dynamic libraries.
3. Reduce the/dev directory. By default, you can keep MAKEDEV,console,null,random, urrandom, and bus, pts hm files and directories.
4. Reduce the/usr directory, and keep only bin, lib, sbin, share, and local directories.
A, bin, sbin Keep the necessary commands as needed.
b. lib Keep gconv,i686,locale,sudo,ssl,udev directories and necessary dynamic libraries.
c, share directory keep command-not-found file i18n terminfo zoneinfo, and you can delete unwanted files in these directories.
5, reduce var directory to keep lock log mail run spool several directories, delete redundant files in these directories as needed.
6. Reduce the etc directory, and reduce it as needed.
Description:
1. The/usr/bin/tput command and/etc/lsb-* file can cause [0K] to be invisible when the system is restarted, and must be reduced.
2. Modify the time zone on the command line a. sudo tzselect to select;b. Change/usr/share/zoneinfo/Asia/Shanghai/etc/localtime
7. Boot directory reduction
Modify initrd.img-2.6.28.N as needed
The requested URL/boot/imagefile.img was not found on this server.| cpio -imd -quiet Unzip initrd.img-2.6.28.N and modify parameters.
2. Use find . |cpio -quiet -H newc -o |gzip -9 -n > /boot/initrdfile.img Generate a compressed initrd file. Or use (find . |cpio -quiet -c -o |gzip -9 -n > /boot/initrdfile.img, although older versions of the Ubuntu kernel use the previous compression method.
3. You can use mkinitramfs -o initrd.img-2.6.28.N 2.6.28.N to generate an initrd file, or you can use update-initramfs -u -k `uname -r` to upgrade an existing initrd.
8. Restart to make necessary adjustments.
Description:
1. If error:"kernel.maps_protect" is an unknown key"can be blocked in/etc/sysctl.conf.
2. If error:"vm.mmap_min_addr" is an unknown key, you can set the Security option to recompile the Ubuntu kernel.
About "Ubuntu kernel basic system reduction and compilation example analysis" This article is shared here, I hope the above content can be of some help to everyone, so that you can learn more knowledge, if you think the article is good, please share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 238
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.