How to Create a floppy Linux
Copyright: The copyright of this article is owned by Yue Guang. It can be freely transmitted and reproduced without commercial purposes. Any action in this article shall be approved by the author for commercial purposes. Contact Information: ygxy@msn.com
The purpose of making a Linux floppy disk (that is, placing a Linux system on a floppy disk) is to gain a deep understanding of the Linux structure. You can use a floppy disk to start the machine to repair the system and rescue data !! : The Linux and Linux boot disks on a floppy disk are different. The latter only places the core on a floppy disk and directs the Linux system on the hard disk. The former is a Linux system on a floppy disk.
The successful preparation of a useful floppy Linux is as follows:
1) Compile a kernel that is small enough and has certain functions.
2) use busybox and compile it as appropriate.
3) create required directories and files (such as/dev, hda, and inittab)
4) configure the boot program grub
5) Properly organize the above three points on a floppy disk.
This article describes how to create a Linux disk in the above sequence.
(Busybox is a tiny program that allows the system to provide ls, Ash, RM, CP, init, and other services. It only has a small busybox file, using ls, RM, init connects him and runs the corresponding services by executing these connections)
Prepare: Create the/tmp/Floppy directory to store temporary files.
I.) Compile the kernel
Make mrproper
Copy ../src/configs/i386-BOOT (similar file) to ../src/. config
Make menuconfig
(It is best to remove all * in the second item to remove the support for the module. You must set the remaining ramdisk options for the core support.) Note :!! If the network function is completely removed, compilation may fail (this is the case for the 2.4.20-8 kernel), but some of them can be removed .)
Make Dep
Make clean
Make bzimage
../Src/ARCH/i386/boot/bzimage is the kernel
The compiled kernel should not exceed 1 MB
Ii.) Compile busybox
The busybox source code can be found on the RedHat website (FTP // ftp.redhat.com/pub/redhat/linux/9/en/ OS/I #/srpms). Assume that the source code directory after installation is/./src/busybox
Modify the/../src/busybox/config. h file and add the file before the unused function //
Modify the/../src/busybox/MAKEFILE file and set dostatic = true
Run:
Make
(The size of the file named busybox should be around 650k)
Make prefix =/tmp/Floppy install
(In this case, the directory and file required for Linux Startup are in the/tmp/Floppy directory)
Iii.) create required directories and files for the System
1. In the/tmp/Floppy directory
Mkdir proc MNT etc Dev
Create the inittab file and RC. s file in the etc directory (use VI)
Run:
Chmod 777 inittab
Chmod 777 RC. s
The inittab content is:
: Sysinit:/etc/rc. s
: Askfirst:/bin/sh
The RC. s file contains the following content:
#! /Bin/sh
Mount-T proc/proc
2. Create a device file in the dev directory.
The device files to be created include console, hda, hda1, hda2, hda3... (depends on the number of hard disk partitions), HDB, HDC, HDD, tty, tty0, tty1, fd0, null, loop0, ram0, tty5
The corresponding files can be found in/dev but cannot be copied. You must create the file yourself:
The mknod command syntax is as follows:
Mknod file name type major minor
Type major minor can be searched under/dev by LS-l (the first digit of the permission string is "type ")
For example, to create a console file, run the following command under/tmp/floppy/dev:
Mknod console C 5 1
Iv.) Configure grub and organize the floppy disk.
1. Take an empty disk formatted as ext2. Create the boot/GRUB directory on it.
Copy/boot/GRUB/stage1 and stage2 to the boot/GRUB disk.
Run:
Grub
Root (fd0)
Setup (fd0)
Quit
So far, grub has been installed successfully!
Create the grub. conf file in the boot/GRUB directory of the floppy disk.
Content:
Default = 0
Timeout = 10
Title Linux
Root (fd0)
Kernel/bzimage
Initrd/image.gz
Grub configured successfully!
Copy bzimage to the root directory of the disk.
2.
CD/tmp
Dd If =/dev/Zero of = image BS = 1 k count = 2048
Losetup/dev/loop0 Image
Mke2fs-M 0/dev/loop0
Mount-T ext2/dev/loop0/mnt
CP-r floppy/*/mnt
Umount/mnt
Losetup-D/dev/loop0
Sync
Dd If = image | gzip-9> image.gz
Copy beiimage.gz to the disk root directory.
So far, the Linux disk has been created! Restart and use a floppy disk to boot your own Linux OS!