Build a Linux operating system that belongs to you

Source: Internet
Author: User

Linux is an open-source operating system, we can make changes to him to meet our needs, which is also the Linux lovers more than Windows because, as a Linux enthusiast, if you can not manually make a Linux, it is not "embarrassing" it. Here's an introduction to how Linux is made

When making custom Linux, install all the development environments in full
Development Tools

First, we're going to download the Linux kernel, and unzip

[[email protected] src] #tar XF linux-3.13.6.tar.xz

Creating Symbolic Links

[[email protected] src] #ln-sv linux-3.13.6 Linux

Cancel all the default options

[email protected] linux]# make Allnocinfig

The options we need when compiling the selected kernel

[email protected] linux]# make Menuconfig

Choose the following: Mark * Number Selection

1, *64-bit kernel Select 64-bit kernel support 2, general setup  ->      *local  version – append to kernel release     added as cshang  Linux-3 (fill in your own) version number, define your own 3, *enable loadable module support  ->     *module unloading Open Loading Module support 4, enable the block layer  ->     *BLOCK LAYER SG SUPPORT V4 allows the use of block-layer  5, processor type and  Features  -> processing types and features     *Symmetric multi-processing support      turn on multi-processor      Processor family  (Core 2/newer xeon)   ->        *Core 2/newer Xeon          support for Intel's Cpu    *multi-core scheduler support   (NEW)      supportMulti-core scheduling  6,  Bus options  (pci etc.)   ->    *PCI support     Support PCI Bus 7,  executable  file formats / emulations  ->    *kernel support  for ELF binaries    *Kernel support for scripts  starting with #!  the format of executable files on the kernel: elf binary, Shell script 8,  Device Drivers  -> device driver     SCSI DEVICE SUPPORT  ->    SCSI Drive          *SCSI device support         *SCSI DISK SUPPORT        SCSI hardware Drivers and disk drives      *Fusion MPT device support  ->          *fusion mpt scsihost drivers for spi        *fusion mpt logging facility     *usb support  ->        *support for  Host-side USB        *EHCI HCD  (usb 2.0)  support        *OHCI HCD  (usb 1.1)  support         *UHCI HCD  (Most intel and via)   suppor         USB enabled, with 2.0, 1.1 interface, including Intel's via     input device support  ->        *mouse  interface        *keyboards  ->         *Mice  ->         input device driver: Mouse interface, keyboard, Mouse     generic driver options  ->        *maintain a  devtmpfs filesystem to mount at /dev         *Automount devtmpfs at /dev, after the kernel mounted the  rootfs         when mounting the system, contains the file system of Dev, and when the kernel mounts the root filesystem           automatically mounts the dev file system to/dev          above this is what I didn't choose, Bothered me for a day and a half plus one night 9,  File systems  ->    *The Extended 4  ( EXT4)  filesystem     enable file system support for EXT4 10, *networking support  ->     networking options  ->        * unix domain sockets         inter-process communication between the same host, to open the back of the Nginx service needs         *tcp/ip networking            * ip: multicasting                              *ip: advanced  ROUTER               *IP:  policy routing                                                                       * ip: equal cost multipath                                                                    *ip: verbose route  monitoring         enable TCP/IP support  11, device drivers   ->    *Network device support  ->          *Network core driver support          *Ethernet driver support  ->             *Intel devices             *intel (R)  PRO/1000 Gigabit Ethernet support          &nbsP;  *intel (R)  PRO/1000 PCI-Express Gigabit Ethernet support              for unused NIC options, we can opt out of           above for loading network-related drivers at compile time

Compiling the kernel

[Email protected] linux]# Make-j 4

This is to open 4 threads at the same time compile
The compilation generates a Arch/x86/boot/bzimage file

Making the system for the target host
Fdisk/dev/sdb
SDB1 to 50M,SDB2 for 512M

Format the partition and mount it

[[email protected] ~]# mke2fs-t ext4/dev/sdb1[[email protected] ~]# mke2fs-t ext4/dev/sdb2[[email protected] ~]# mkdir /mnt/{boot,sysroot}[[email protected] ~]# mount/dev/sdb1/mnt/boot/[[email protected] ~]# mount/dev/sdb2/mnt/sysroot/

To generate the grub bootstrapper for the target host

[Email protected] ~]# grub-install–root-directory=/mnt//dev/sdb

Providing configuration files for grub boot

[Email protected] ~]# vim/mnt/boot/grub/grub.conftimeout=5default=0title C-shang ' s Mini Linux (3.13.6) root (hd0, 0) kernel/bzimage ro root=/dev/sda2 init=/sbin/init

Installing BusyBox as the target host provider, command

[Email protected] src]# Tar XF busybox-1.22.1.tar.bz2

Compile and install BusyBox with static installation

[[email protected] busybox-1.22.1]# make Menuconfigbusybox settings-> Build options-> *build busybox As a static binary (no shared libs) [[email protected] busybox-1.22.1]# make-j 4[[email protected] busybox-1.22.1]# make Install

The generated files are in the _install directory under the current directory

Copy the program files generated by BusyBox to the target host

[Email protected] busybox-1.22.1]# cp-a/usr/src/busybox-1.22.1/_install/*/mnt/sysroot/

Create a system directory for the target host

[[email protected] busybox-1.22.1]# Cd/mnt/sysroot/[[email protected] sysroot]# for i in ' ls/';d o mkdir $i;d One

Enables the directory host to support user login functions, user root and Luffy, password is Sch

Prepare a series of configuration files for the directory host, in the/mnt/sysroot directory

[Email protected] sysroot]# vim Etc/inittab::sysinit:/etc/rc.d/rc.sysinittty1::respawn:/sbin/getty 19200 tty1tty2:: Respawn:/sbin/getty 19200 tty2tty3::respawn:/sbin/getty 19200 tty3tty4::respawn:/sbin/getty 19200 tty4::ctrlaltde L::/sbin/reboot::shutdown:/bin/umount-a-R

Create a configuration file that automatically mounts the file system

[[email protected] sysroot]# vim etc/fstab/dev/sda2/ext4 defaults 0 0/dev/sda1/boot ext4  Defaults 0 0proc/proc proc defaults 0 0sysfs/sys sysfs defaults 0 0

To create a script that is called after the init program starts

[Email protected] sysroot]# mkdir etc/rc.d[[email protected] sysroot]# vim etc/rc.d/rc.sysinit#!/bin/sh#the script of th    E system Beginecho-e "\033[32mwelcome to C-shang ' s Mini linux\033[0m" Mount-n-o remount,rw/dev/sda2mount-amdev-s #自动创建设备文件 [[email protected] sysroot]# chmod +x etc/rc.d/rc.sysinit

Create an account file

[Email protected] sysroot]# vim etc/passwdroot:x:0:0::/root:/bin/shluffy:x:500:500::/home/luffy:/bin/sh

Create a password file for a user

[[email protected] sysroot]# OpenSSL passwd-1-salt ' OpenSSL rand-hex 4 ' Password: #输入sch $1$7f5be4e4$lyc99ncehov6 3fanukhtp/
[Email protected] sysroot]# vim etc/shadowroot:$1$4b2741bf$dx190cllodtsmr29/e6cf/:16733:0:99999:7:::luffy:$1$ 4b2741bf$dx190cllodtsmr29/e6cf/:16733:0:99999:7:::

The above format must be correct, because I write less part, leading to my certification can not pass, but through
troubleshooting, feel unable to login, the problem must be in the user's files on these, troubleshooting success

[Email protected] sysroot]# chmod go= Etc/shadow #更改权限

To add a group file to a user

[Email protected] sysroot]# vim etc/grouproot:x:0luffy:x:500

Create a home directory for normal users

[Email protected] sysroot]# mkdir Home/luffy

Finally, copy the Bzimage file generated by the kernel compilation to the directory system

[Email protected] ~]# cp/usr/src/linux/arch/x86/boot/bzimage/mnt/boot/

Create a new virtual machine and load the host's SDB hard drive up

In this way, a custom Linux system is completed
650) this.width=650; "src=" http://www.365lsy.com/wp-content/uploads/ckfinder/images/linux_1.jpg "style=" margin:0 px 0px 10px;padding:0px;border:0px;font-size:14px;vertical-align:baseline; "/>
650) this.width=650; "src=" http://www.365lsy.com/wp-content/uploads/ckfinder/images/linux_2.jpg "style=" margin:0 px 0px 10px;padding:0px;border:0px;font-size:14px;vertical-align:baseline; "/>

To this, the manual production of Linux is finished, is not some sense of accomplishment, the next step, we can also on the basis of the above, BusyBox, provide remote login capabilities.

This article is from the "Child Naked Fart" blog, please be sure to keep this source http://cshang.blog.51cto.com/6143980/1565671

Build a Linux operating system that belongs to you

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.