In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)06/01 Report--
Computer has become an indispensable tool in modern people's daily work, study and life. The operating system is the soul of the computer, as the interface for users to use the computer, it is responsible for scheduling and executing various user programs to enable the computer to complete specific tasks; as the manager of computer hardware resources, it is responsible for coordinating the efficient work of all kinds of devices in the computer. The importance of the operating system is self-evident. The mainstream operating systems on the market are Windows, Unix, Linux and Mac OS X.
Linux, developed by Finnish university student Linus in 1991, is an open source Unix-like operating system with the following features:
Open operating system
Linux is a free software, developers are free to install and modify the source code of the software, compared with the command line operation of Unix, Linux provides a window management system, relatively easy to operate, enterprises can use Linux free of charge, greatly reducing the cost budget.
Strong hardware support
The Linux system is very easy to maintain, and users can update the operating system and all installed software centrally, which is both safe and efficient. Linux can effectively use system resources, allow users to install according to specific hardware requirements, and allow Linux to be installed on old computers, thus helping to make the best use of computer hardware resources.
High security and stability
Under the Linux system, unless the user logs in as root, the program cannot change the system settings and configuration, and it is rare that the computer cannot be started because of the user's misoperation. The permissions of files and malware downloaded by Linux will be limited, which can effectively avoid the invasion of viruses. The common blackmail viruses and worms in Windows systems can not run under Linux. Linux is very stable and not easy to crash, and Linux will be able to run at the same speed in a few years as it was when it was first installed. And Windows may not be able to keep up with the speed after half a year of operation.
The success of the Linux system is attributed to the contribution of every Linux enthusiast, whether in the Linux kernel or open source software, which provides a good learning and research environment for our later generations.
Let's do a small experiment: by tailoring the existing Linux system, according to our own needs, we can build a small Linux system of our own, so that it can have some common small functions of Linux.
Second, principle
Introduction to the startup process:
Before making the Linux mini system, it is necessary to take a look at the startup process of Linux:
1. First of all, Linux has to pass the POST self-test to check whether the hardware is faulty.
2. If you have multiple boot disks, you need to select the boot disk in BIOS
3. Start the bootloader bootstrap in MBR
4. Load kernel files
5. Init, the parent process and ancestor of all processes
6. Print welcome interface
In the startup process of Linux, two other files are needed to load the kernel file:
1) initrd, which is a disk device simulated in memory on CentOS5
2) initramfs, which is a file system simulated in memory on CentOS6
What is the main purpose of init in the departure process?
Init calls the configuration file / etc/inittab, and then executes the system initialization script of / etc/rc.d/rc.sysinit
Well, we already know the principle, so let's take a look at the specific ideas.
Third, train of thought
1. We need to add a hard disk / dev/sdb to an existing Linux system, divide it into two partitions, one is / boot, the other is /, and format it. Of course, we need to make it clear that the hard drive we are adding is / dev/sdb in the existing Linux system, but when we have everything set up, we need to unplug the hard drive and put it on our new system. At this point, it is / dev/sda.
2. On the hard drive / dev/sdb, we want to build it into an independent Linux system, in which all the files need to be copied one by one. And, as a hard drive that will be / dev/sda in the future, there must be grub files in it, so we have to install grub files.
3. At the same time, as a Linux system that can run independently, the kernel is indispensable! So, we need to copy the kernel file and the initramfs file to our / dev/sdb as well.
4, now that our system has begun to take shape, the next thing is to need the program 0.0 about the copy of the program we can achieve through a script. The specific script will be mentioned below.
When the above steps are completed, our homemade Linux is complete. That's what our thinking is all about. Next, let's get started!
IV. Operation steps
In this experiment, we take centos6.9 as an example.
1. Target disk partition
First, we add a 20g hard disk to the host:
Uploading... cancel
When the addition is complete, click OK, and then we open the host. Partition our / dev/sdb through fdisk:
Next, we format the partition of / dev/sdb:
After the formatting is complete, we create a folder. To mount:
Note: the newly created folder must be / mnt/boot
2. Install grub to the target disk
We install it directly with the grub-install-root-directory=/mnt command. Using this command will install the files for the second phase of grub boot.
We can take a look at binary to confirm whether our installation is successful:
Installation succeeded.
3. Copy kernel files and initrd files
Copy the kernel file and initrd file to the boot directory under / dev/sdb:
4. Establish the grub.conf file
We have migrated the kernel and initrd files above, and we can write grub.conf files according to their version:
Note that we need to turn off selinux, set init at the same time, and tell the kernel not to look for this program again, otherwise there will be an error when booting.
5. Create a first-level directory and copy files
At this point, we are short of directories and files.
Create a first-level directory after boot, and mount / dev/sdb2 to / mnt/sysroot to make it the root directory:
Copy the file, copy the file we execute through the script, copy our usual commands, the editor copied the ls,ifconfig,bash,reboot,rm,modprobe,mount,ip,mkdir,touch,cat,vi,less,shutdown,insmod here. We can use tree to see how these commands are copied:
Obviously, we all copied it successfully.
Attached: copy the script source code of the command
6. Copy the network card driver
Our basic work has been completed. If we want to make this virtual machine have the function of network card, we must copy the network card driver as follows:
1) query the details of the Nic:
2) copy the path of the Nic module to the library file of / mnt/sysroot:
Above, all our operations have been completed. Now we can turn off the computer, then remove the hard drive / dev/sdb and run it on the new virtual machine.
5. Test and start up
We create a new virtual machine and boot with a hard disk. We don't need it, delete it and add our own defined hard disk:
At this time, the hard drive we have made has been added. We can try to see if it can be started. If the virtual machine can be turned on normally, it means that our experiment is successful.
Sixth, realize the network function.
As the picture may not be seen clearly, please mark the code as follows:
# add Nic drivers manually
Insmod / lib64/e1000.ko
# View ip
Ip a
# add IP address
Ifconfig eth0 192.168.252.62/24 up
# View ip
Ip a
Because I forgot to copy ping when copying the command. So let's use another machine to ping this ip address:
You can ping ~
At this point, we have completed all the operations of private customization of Linux, and our homemade Linux can also be connected to the Internet.
Summary:
In recent years, Linux has developed rapidly because of its stability, open source, free, secure and efficient characteristics, and its market share in the server has exceeded 80%. With the development of cloud computing, Linux is still the trend in the future server and personal computer field.
Welcome to join the 51 software testing family, where you will get [latest industry information], [free test tool installation package], [software testing technology], [job interview skills]. 51 learn and grow with you! Looking forward to your joining: QQ Group: 755431660
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: 0
*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.