Linux boot disk

Source: Internet
Author: User
Tags tmp file domain name server disk usage
Linux
In some cases, we need a Linux system that can be started as long as a floppy disk, such as a router. But what should we do? That is to say, we need to put both the kernel and filesystem on a 3.5 'disk. Let's break down filesystem into the following parts.

1./bin directory file

The bin directory is usually a directory for storing some basic command files of the system. To ensure that your system can be started normally and complete necessary functions, You need to place the following files in the/bin directory:

Ksh ---> shell is indispensable.

More --> you must know that there is no type command in Linux.

Dmesg-> although you are familiar with your system hardware, it is much more convenient to have it.

PS ----> checking system processes is a good habit of administrators.

Login-> do not log on to other users. Besides, it is also the composition of the underlying system.

Sync --> Update the disk block, which is very good.

Mount-> unless you do not need the file system, you do not need it.

Umount-> unmount the file system.

Kill --> kill processes that are useless or stop responding.

Setterm-> modify terminal parameters.

Hostname-> displays the name of the current machine.

Telnet-> remote login, your Linux will not do anything else!

Ping --> check the network connection status.

FTP ---> although nothing can be left, it is also good to leave it.

Tar ---> Backup is very important! Even if your system has only one soft drive!

Killall-> shutdown will be used by the system.

Chmod-> Modify file attributes.

Chown-> modify the object ownership

CP ---> copy the file. It can be used to fix the system!

Dd ---> it is said that many administrators are commonly used, but I have never used it! Because I rarely copy media.

DF ---> View disk usage.

Du ---> View the space occupied by the specified path.

Ls ---> you will never use it once!

Mkdir-> Directory creation is common, even if there is only one disk!

MV ---> command for moving files.

Rm ---> delete an object. What if there are too many objects? Rely on it!

Ln ---> link file, of course, useful!

Dircolors --> set the directory color when you use a color display.

Cut --> send some lines of the file to the standard output device.

Cat --> send the standard input to a file or the file to the standard input

Stty --> very important terminal commands!

Gzip --> package and PackageProgram

Domainname --> View the domain name.

Link some things.

Date @->/sbin/clock
Less @-> more
Sh @-> KSh
Gunzip @-> Gzip
Zcat @-> Gzip
Bash @-> Sh
Tcsh @-> Sh

2. files under the/etc directory

The etc directory is the directory where system configuration information is stored, and some system initialization files are also placed.

Mtab --> mounted table: List of mounted filesystems.

Kernel --> system kernel.

Issue --> the prompt information of login.

Profile --> the batch file that is executed when a global user logs on to bash.

Psdevtab --> files related to the kernel image.

Inittab --> initialization list, which is used when the system is started.

Passwd --> User Password Database.

Motd --> message of the information displayed when the today user login.

Fstab --> the filesystem to be automatically mounted at startup.

Hosts --> DNS file from domain name to IP address.

Resolv. conf --> the local IP address and Domain Name Server address configuration file.

Termcap --> terminal character ing file.

Services --> the service project that is loaded when the system starts.

RPC --> RPC resource interpretation file.

Protocols --> system protocol description file.

Networks --> defines the configuration file of the local IP address and subnet.

Mtools --> mtools parameter file.

Hosts. Deny --> set the target machine to be unable to telnet to this host.

Opposite hosts. Allow --> to hosts. Deny, set the destination address for which you can telnet.

Exports --> NFS system file.

Dir_colors --> set the system color of the ANSI-color terminal.

Hostname --> Domain Name of the local machine.

Inetd. conf --> inetd process configuration file.

LD. So. cache --> system lib cache information.

Shells --> record of the available shell in the system.

Host. conf --> local network configuration.

Magic --> files in the system.

Utmp --> records of the current login user.

Group --> User Group parameter record.

LD. So. conf --> record the directory where some Lib is located.

Fastboot --> A file generated by the shutdown command. The file will be checked when the system restarts.

3./files in the sbin directory

Some System Extension commands are placed in this directory:

Swapoff @-> Swapon --> connect swapoff to the Swapon command

Telinit @-> init --> connect telinit to the init command

Reboot @-> halt --> connect reboot to the halt command

Addswap --> to add a swap partition, edit an addswap script by yourself.

Chkhd --> check the hard disk

Clock --> determine the set time

Swapon --> open swap Partition

Update --> bdflush daemon

Mkswap --> Format the swap Partition

Agetty --> terminal guard

Init --> system initialization command

Shutdown --> shut down the system

Halt --> system shutdown

Killall5 --> clear all processes

Ifconfig --> network configuration program

Route --> route setting command

Bdflushd --> open the buffer and write it back to the disk.

4. Files in the/usr directory

User Directory, which contains some programs and configuration data that users often need.

Spool @-> ../var/adm --> connect to/var/adm

TMP @-> ../var/adm --> connect to/var/adm

ADM @-> ../var/adm --> connect to/var/adm

/Usr/bin directory, USER command file directory

Who --> query the current Login User

Superformat --> advanced formatting Tool

Loadkeys --> load the keyboard shot table

Joe --> an excellent editor

Uptime --> View the running time of the system from startup to now

Finger --> query user information

Mcheck --> check the DOS system floppy disk

Tput --> initialize terminal or query terminal information

Traceroute --> check the route path

Host-> check the current host configuration information

Split --> split files

Sleep --> delay specified time

Setfont --> Set Font

Grep --> line query command, often used with pipelines

Reset --> Reset System Parameters

The usr/sbin directory contains the advanced commands you need, but we didn't use them. Check the disk space and let's put it on your own.

Some application configuration files are stored in the/usr/local directory.

Usr/local/lib directory

Lynx. cfg --> configuration file of the lynx Browser

Usr/lib directory

Es. map --> keyboard ing File

T. fnt --> font file

5. Files in the/lib directory

Some library files of the system are stored in this directory, which is not explained here.

Libgpm. So @-> libgpm. so.1
Libdl. So @-> libdl. so.1
Ld-linux.so.1
Libtermcap. so.2
Libm. so.5
Libc. so.5
Libdl. so.1
Libgpm. so.1
Libtermcap. so.2
Libcurses. so.1
LD. So

6./dev directory, system device file directory, customized according to standard devices.

7./var directory, mainly for system parameters and configuration.

Var/adm/
Utmp --> empty file, tmp file prepared for uucp
Cron --> empty file, tmp file during kernel Loading
/Var/spool/locks directory to place temporary files and process number files of some running programs.

8. Other directories are empty, including:

/Dosa
/Dosc
/Iomega
/Tmp @->/dosc/onedisk
/Root

9. The addswap Command Script is stored in/sbin.

If ["$1" = ""];
Then
$ Mide = 10000
If
Dd If =/dev/Zero of =/tmp/Linux. swp bs = 1 k count = $ MIDA
Mkswap-C/tmp/Linux. SWP 2>/dev/null
Sync 2>/dev/null
Swapon/tmp/Linux. SWP 2>/dev/null
MIDA = 'cat/proc/meminfo | grep swaptotal | cut-b16-19'
Echo $ MIDA 'kb actiu' arxiu = 'ls/dosc/| grep. swp'

The basic file system of the system is described. The following describes how to create an old (one disk Linux) system.

After introducing the structure of the main directories and files, we have a better understanding of odl. Now you can find a Linux tool to crop it, put the necessary things on a floppy disk, and then use it to start your system into Linux. Then, when you put in some required software, such as Linux router or other small application software, it becomes a small router, proxy server, and your little toys, you can use it to access the Internet, read news, read emails, and browse. This is an unimaginable thing. It cannot be implemented on a m floppy disk.

The detailed process of odl creation is very complicated. The basic idea is to prepare a ready-to-boot Kernel on a floppy disk, and then upload the customized File System to the remaining space of the disk, when starting, read the previous one to boot the system, then read the later one, mount the system to a ramdisk, decompress the customized file system, and release it to ramdisk. In this way, the entire disk system has both kernel and filesystem. Naturally, you can use a single disk to start the entire Linux system. Due to space limitations, we will not describe the entire process in detail, but will focus on the most critical part of the process, this section describes how to customize the file system and enable the system to start the two parts without Lilo. (For files in other directories, follow the file system structure you started to create ).

The procedure for customizing a file system is as follows:

Dd If =/dev/Zero of = device BS = 1 k count = 3000 (allocate a piece of memory for ramdisk)
Mke2fs-M 0-I 2000 device (format ramdisk)
Mount-T ext2 device/mnt (mounted to the/mnt directory)
CP-DPR/dev/mnt (copy the hardware devices under/dev/to/mnt/Dev)
Mkdir/mnt/etc (create the odl system configuration file directory)
Write the/mnt/etc/rc. d file with the following content:
#! /Bin/sh
/Bin/Mount-AV
/Bin/hostname silver
Write the/mnt/etc/fstab file with the following content:
/Dev/ram0/ext2 defaults
/Dev/fd0/ext2 defaults
/Proc defaults
Write the/mnt/etc/inittab file with the following content:
ID: 2: initdefault:
Si: ysinit:/etc/rc
1: 2345: respawn:/sbin/Getty 38400 tty1
2: 23: respawn:/sbin/Getty 38400 tty2
Umount/mnt (unmount ramdisk)
Dd If = device BS = 1 K | gzip-V9> root.gz write the content on ramdiskinto root.gz
Enable the system to start without lilo
Mke2fs-I 8192-M 0/dev/fd0 kernel_blocks
(Kernel_blocks indicates the disk space occupied by the kernel)
Mount/dev/fd0/mnt
Rm-RF/mnt/lost + found
Mkdir/mnt/boot
Mkdir/mnt/dev (create some basic file directories required for startup)
CP-r/dev/{null, fd0}/mnt/dev
(Copy the two required devices null and fd0 to the boot disk)
CP/boot. B/mnt/boot (create a boot image file)
CP bdlilo. conf kernel/mnt (kernel is the kernel file required by old)
Lilo-v-C bdlilo. conf-R/mnt (write lilo information to old)
The content of its dblilo. conf is as follows (which can be modified as needed ):
Boot =/dev/fd0
Install =/boot. B
Map =/boot/Map
Read-write
Backup =/dev/null
Compact
Image = Kernel
Label = bootdisk
Root =/dev/fd0
Dd If = kernel of =/dev/fd0 BS = 1 K
(Write the kernel to the first 1024 bytes of the system so that the old floppy disk can start the system)
Dd if=rootfs.gz of =/dev/fd0 BS = 1 K seek = kernel_blocks
(Upload the original custom file system to the remaining disk space)

Now, you can directly start the system with this disk. 'If you have configured the network system, the network can also be automatically started through it. If you are not familiar with Linux and it is still difficult to customize a system, you can download all old system image files at http://linux.apostols.org/guru/wen/1.x/stone.img. Use the rawrite.exe program to write the downloaded file to a m floppy disk under DOS. This disk can start the system and bring you into the magical Linux World.

It is worth noting that this image file is made by a German, and its terminal keyboard is not a standard US keyboard, so we need to modify its keyboard definition.

After the system is started, there is an es under/usr/lib. map file. We need to modify it. You can copy a default file under RedHat. kmap file, and then run/bin/loadkeys default. kmap: the keyboard can be used normally.
--------------------------------------------------------------------------------

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.