1)Environment Preparation
Add a new disk in the shutdown state
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/47/7C/wKiom1P7IrXSPti2AAC8tLiDtV0411.jpg "title=" Build Your own Minilinux19.png "style=" Float:none; alt= "wkiom1p7irxspti2aac8tlidtv0411.jpg"/>
Partition the newly added disk and Mount it to the specified directory
[[EMAIL PROTECTED] ~]# FDISK -L /DEV/SDB DISK /DEV/SDB: 5368 MB, 5368709120 bytes255 heads, 63 sectors/track, 652 cylindersunits = cylinders of 16065 * 512 = 8225280 bytesSector size ( logical/physical): 512 bytes / 512 bytesi/o size (minimum/optimal): 512 bytes / 512 bytesdisk identifier: 0xc65c5fd3 device boot start end Blocks Id System/dev/sdb1 1 14 112423+ 83 linux/dev/sdb2 15 79 522112+ 83 linux[[email protected] ~]# mke2fs -t ext4 /dev/sdb1[[email protected] ~]# mke2fs -t ext4 /dev/sdb2[[email protected] ~]# mount /dev/sdb1 /mnt/boot/[[email protected] ~]# mount /dev/sdb2 /mnt/sysroot/#安装grub到/dev/sdb[[email protected] ~]# grub-install --root-directory=/mnt/ /dev/sdb download Kernel source and extract to/usr/src[[email protected ] src]# tar xf ~/linux-3.13.6.tar.xz -c /usr/src/[[email protected] Src]# ln -s linux-3.13.6/ linux
2)Compile the source code :
#去掉除必须外所有编译选项 [[Email protected] linux]# make allnoconfig[[email protected] linux ]# make menuconfig#============================================================= #选择编译64位的内核 [*] 64-bit kernel# Select the minor version number to make it easy to differentiate between general setup ---> (mini-v1) local version - append to kernel release #次版本号 [*]system v ipc #支持进程间通信 #选择CPU类型Processor type and featuresProcessor family (Core 2/newer xeon) ---># Choose to support multi-core and multiprocessor processor type and features --->[*] Symmetric Multi-processing support[*] multi-core scheduler support (NEW) #支持PCI总线Bus options (pci etc.) ---Dynamic loading and unloading of >[*] pci support# support modules [*] enable loadable module support ---> [*] forced module loading [*] module unloading[*] Forced module unloading #支持ELF可执行文件和 #! Opening file executable file formats / emulations --->[*] kernel support for elf binaries[*] Write ELF core dumps with partial segments (NEW) < *> kernel support for scripts starting with #! #支持TCP/IP protocol [*] Networking support ---> #支持网络功能 networking options --->[*] TCP/IP networking# supports TCP/IP protocol #支持scsi接口设备Device Drivers --->SCSI device support ---><*> SCSI device support<*> SCSI disk support #设备设置Device Drivers --->[*] Fusion MPT device support ---> <*> fusion mpt scsihost drivers for SPI [*] Fusion MPT logging facility #USB接口驱动Device drivers --->[*] USB support ---><*> Support for host-side usb <*> xhci hcd (USB 3.0) support<*> EHCI HCD (usb 2.0) support<*> ohci hcd  (usb 1.1) support<*> UHCI HCD (Most intel and via) support #输入设备驱动Device Drivers --->input device support ---> <*> Mouse interface [*] Keyboards ---><*> AT keyboard (NEW) [*] Mice ---> <*> PS/2 mouse (NEW) #网卡驱动 [*] network device support ---> [*] ethernet driver support (NEW) ---> [*] Intel devices #尽量去除不需要的网卡驱动 <*> intel (R) PRO/1000 Gigabit Ethernet support <*> intel (R) pro/1000 PCI-Express Gigabit Ethernet support #自动挂载设备文件到/dev directory device drivers --->Generic Driver Options ---> [*] maintain a devtmpfs filesystem to mount at /dev [*] automount devtmpfs at /dev, after the kernel mounted the rootfs # File System Selection File systems ---> <*> The Extended 4 (ext4 ) filesystem #=============================================================[[email protected] linux]# make -j 4[[email protected] linux]# make -j4 bzimage# used to develop the number of threads used [[email protected] linux]# cp arch/x86/boot/bzimage /mnt/boot/
3)create a must folder and install BusyBox
[Email protected] src]# tar xf busybox-1.22.1.tar.bz2 [[email protected] src]# CD Busybox-1.22.1[[email protected] Busybo x-1.22.1]# make Menuconfig #以静态编译方式编译Build Options---> [*] Build BusyBox as a static binary (no shared libs) [[Emai L protected] busybox-1.22.1]# make && make Install[[email protected] busybox-1.22.1]# cp-a _install/*/mnt/sysroo t/#新已经可以正常进入
650) this.width=650; "Src=" http://s3.51cto.com/wyfs02/M01/47/7D/ Wkiol1p7i87ifzqwaaccqkyedbm796.jpg "title=" to build their own minilinux3981.png "style=" Float:none; "alt=" Wkiol1p7i87ifzqwaaccqkyedbm796.jpg "/>
#编辑使开机可以自动挂载 [[email protected] rc.d]# vim rc.sysinit #!/bin/sh#mkdir /dev/ shmmount -n -t ext4 /dev/sdb2 /mount -n -t ext4 /dev/sda1 / Bootmount -n -t proc proc /procmount -n -t sys sys /sysmount -n -t tmpfs tmpfs /dev/shm mount -a [[email protected] rc.d ]# vim rc.sysinit #!/bin/sh#mount -n -o remount,rw -t ext4 /dev/sdb2 /mount -n -t ext4 /dev/sda1 /bootmount -n -t proc proc /procmount -n -t sys sys /sys mount -aecho -e "Welcome to \033[36mmini os\033[0m v2 by wh " [[email protected] ~]# vim /mnt/sysroot/etc/fstab /dev/sda2 / ext4 defaults 0 0 /dev/sda1 /boot ext4 defaults 0 0 tmpfs /dev/shm tmpfs defaults 0 0devpts /dev/pts devpts defaults 0 0sysfs /sys sysfs defaults 0 0proc /proc proc defaults 0 0 #提供用户和密码 [[ Email protected] etc]# cat passwdroot:x:0:0:root:/root:/bin/sh[[email protected] etc]# cat shadow Root:$1$sdgsag$3aeidl7kbstunb7joeodx.:16303:0:99999:7::: [[email protected] ~]# openssl passwd -salt "Sdgsag" -1password: $1$sdgsag$3aeidl7kbstunb7joeodx.
# can already be certified
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/47/7D/wKioL1P7I8_gIJnwAAGV0aB2rrk902.jpg "title=" Build Your own Minilinux5220.png "style=" Float:none; alt= "wkiol1p7i8_gijnwaagv0ab2rrk902.jpg"/>
# NIC can also load properly
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/47/7D/wKioL1P7I9ChuVUpAAEjrcwFjCc532.jpg "title=" Build Your own Minilinux5233.png "style=" Float:none; alt= "wkiol1p7i9chuvupaaejrcwfjcc532.jpg"/>
4)installing dropbear to enable ssh connection
[[Email protected] ~]# tar XF dropbear-2013.58.tar.bz2-c/usr/src/[[email protected] ~]# cd/usr/src/#编译并安装 [[Email Protec Ted] dropbear-2013.58]#/configure--prefix=/usr/local/dropbear[[email protected] dropbear-2013.58]# make PROGRAMS= " Dropbear dbclient dropbearkey Dropbearconvert SCP "[[email protected] dropbear-2013.58]# make programs=" dropbear Dbclient dropbearkey dropbearconvert SCP "install# copy library files and commands to/mnt/sysroot/using the following script
# Generate key
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/47/7D/wKioL1P7I9SRaZ4iAAEqQQmQ8og213.jpg "title=" Build Your own Minilinux5664.png "style=" Float:none; alt= "wkiol1p7i9sraz4iaaeqqqmq8og213.jpg"/>
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/47/7C/wKiom1P7Ir6TscbrAAFHZrNfm4c471.jpg "title=" Build Your own Minilinux5666.png "style=" Float:none; alt= "wkiom1p7ir6tscbraafhzrnfm4c471.jpg"/>
# Landing Success
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/47/7D/wKioL1P7I9bQqMnKAABo_fKw22U110.jpg "title=" Build Your own Minilinux5674.png "style=" Float:none; alt= "wkiol1p7i9bqqmnkaabo_fkw22u110.jpg"/>
5)Deploying nginx sites
[Email protected] nginx-1.4.7]#/configure--prefix=/usr/local/nginx--user=nginx--group=nginx--without-pcre-- Without-http_rewrite_module[[email protected] nginx-1.4.7]# make && make Install[[email protected] nginx]# cp-r /usr/local/nginx//mnt/sysroot/usr/local/#添加用户信息和组信息到以下目录 [[email protected] nginx]# VIM/MNT/SYSROOT/ETC/PASSWD Nginx:x:0:0:root:/home/nginx:/bin/sh[[email protected] nginx]# Vim/mnt/sysroot/etc/shadow nginx:$1$sdgsag$ 3aeidl7kbstunb7joeodx.:16303:0:99999:7:::
Access Success :
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/47/7C/wKiom1P7IsHS5JMgAAFog1g9Aog298.jpg "title=" Build Your own Minilinux6158.png "style=" Float:none; alt= "wkiom1p7ishs5jmgaafog1g9aog298.jpg"/>
This article is from the "faint" blog, please be sure to keep this source http://dddbk.blog.51cto.com/6837943/1544880
Build Your own Minilinux