Home > OS >  Linux customize their need
Linux customize their need

Time:12-17

Linux, with its open source ideas and start the speed for the majority of technical personnel, this article mainly tells through its packaging of the kernel as well as to the default setting of the program, to implement custom a themselves need OS system, and can realize automatically boot loading card, and configure the IP address for the network card, this paper does not involve the kernel compilation, kernel compilation content will be launched in the subsequent, please look!

This article is through hosting - & gt; Implemented in the form of the target,

1, add a 20 g harddisk for your virtual machine, and set the disk to a single file system, and named smallcentos. VMDK

Check the host machine drives now information


/root @ localhost ~ # fdisk - l/dev/sd [a-z]
Disk/dev/sda: 128.8 GB, 128849018880 bytes
255 heads, the 63 sectors/track, 15665 cylinders
Units=cylinders of 16065 * 512=8225280 bytes
Sector size (logical/physical) : 512 bytes/512 bytes
I/O size (minimum/optimal) : 512 bytes/512 bytes
Disk identifier: 0 x0001c38d
Device Boot Start End Blocks Id System
/dev/sda1 * 12620480083 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 267859629145608 e Linux LVM
Disk/dev/SDB: 21.5 GB, 21474836480 bytes
255 heads, the 63 sectors/track, 2610 cylinders
Units=cylinders of 16065 * 512=8225280 bytes
Sector size (logical/physical) : 512 bytes/512 bytes
I/O size (minimum/optimal) : 512 bytes/512 bytes
Disk identifier: 0 x00000000
The newly added hard disk is identified for SDB, target host will start by loading the SDB

2, create two basic in SDB 100 m, 512 m partition and file system format into corruption format

1
/root @ localhost ~ # echo - e "n, np, n1 \ n \ n + 100 m, nn, np, n2 + 512 m \ \ n \ n nw" | fdisk/dev/SDB
Formatting a new partition

1
2
/root @ localhost ~ # mke2fs - t corruption/dev/sdb1
/root @ localhost ~ # mke2fs - t corruption/dev/sdb2
3. The partition of the newly created separately mounted to/MNT/boot and/MNT/sysroot

1
2
3
[root @ localhost MNT] # mount
/dev/sdb1 on/MNT/boot type corruption (rw)
/dev/sdb2 on/MNT/sysroot type corruption (rw)
4. Install grub to specified partition


[root @ localhost MNT] # grub - install - root - directory=/MNT/dev/SDB
Probing devices to guess BIOS drives. This may take a long time.
The Installation finished. No error reported.
This isthe contents of the device map/MNT/boot/grub/device map.
Check ifthisiscorrect or not. If any of the lines isincorrect,
Fix it and re - run the script ` grub - install. '
(fd0)/dev/fd0
(hd0)/dev/sda
(hd1)/dev/SDB
5. Copy the/boot directory grub and initrd file to/MNT/boot directory (will start copying files to customize system)

1
2
[root @ localhost grub] # cp/boot/called - 2.6.32-358. El6. X86_64/MNT/boot/wangfengvmlinz
[root @ localhost grub] # cp/boot/initramfs - 2.6.32-358. El6. X86_64. Img/MNT/boot/wangfenginitramfs img
6. Create Linux need some basic documents (need on a custom system)

1
[root @ localhost grub] # mkdir - pv/MNT/sysroot/{the/etc/rc. D, usr, var, proc, sys, dev, lib, lib64, bin, sbin, boot, SRC, MNT, media, home, root}
7. Migration on the host a binary executable files and libraries to the target machine on your hard disk, such as ls, cat, mkdir, mount, reboot, useradd and passwd, ifconfig, IP, such as ping,

Here is no longer redundant, behind will attach a script is implemented

In order to prevent the kernel panic, need to bash to create a soft link sh

8. In/boot/grub for the target directory to create grub. Conf, implemented boot self-check, the following

The default=0

Timeout=10

Hiddenmenu

The title wangfengLinux

Root (hd0, 0)

Kernel/wangfengvmlinuz ro root=/dev/sda2 selinux=0 init=/sbin/init

The initrd/wangfenginitramfs img

9. In order to be able to realize the startup network card, network card needs to be a host computer configuration files are copied to the target machine, can pass lsmod view the current system of all modules, can use modinfo module name to view the module details

1
2
/root @ localhost ~ # lsmod | grep e1000 - & gt; To check the card information
E1000 1706460


/root @ localhost ~ # modinfo e1000
Filename:/lib/modules/2.6.32-358. The el6. X86_64/kernel/drivers/net/e1000 e1000. Ko - & gt; The location of the module for the network card
Version: 7.3.21 - k8 - for a
License: the GPL
Description: Intel (R) PRO/1000 network Driver
Author: Intel Corporation, & lt; [email protected] & gt;
1 d4f1e82bb99ea36d320b1b srcversion:
Alias: pci: v00008086d00002E6Esv * I * * * sd * BC sc
Alias: pci: v00008086d000010B5sv * I * * * sd * BC sc
Alias: pci: v00008086d00001099sv * I * * * sd * BC sc
Alias: pci: v00008086d0000108Asv * I * * * sd * BC sc
Alias: pci: v00008086d0000107Csv * I * * * sd * BC sc
Alias: pci: v00008086d0000107Bsv * I * * * sd * BC sc
Alias: pci: v00008086d0000107Asv * I * * * sd * BC sc
Alias: pci: v00008086d00001079sv * I * * * sd * BC sc
Alias: pci: v00008086d00001078sv * I * * * sd * BC sc
1
2
/root @ localhost ~ # mkdir -p/MNT/sysroot/lib/modules
/root @ localhost ~ # cp/lib/modules/2.6.32-358. The el6. X86_64/kernel/drivers/net/e1000 e1000. Ko/MNT/sysroot/lib/modules/e1000. Ko
10. In order to make the system to boot automatically mount some initialization file system and some service, needs on the target machine/sbin/directory to create the init file has implementation requirements, the following

#!/bin/bash

Echo - e "Welcome to [32 m Wangfeng \ 033\033 [0 m Linux"

The mount - n - t proc/proc proc

The mount - n - t sysfs sysfs/sys

Insmod/lib/modules/e1000. Ko

The ifconfig lo 127.0.0.1/8

The ifconfig eth0 192.168.1.200/24

The route to the add -.net 0.0.0.0 gw 192.168.1.253

/bin/bash

From https://blog.csdn.net/weixin_33747129/article/details/92648501? Utm_medium=distribute. Pc_relevant. None - task - blog - BlogCommendFromMachineLearnPai2-4. Control& null
  • Related