Build your own Linux distribution on a USB disk __linux

Source: Internet
Author: User

from:http://blog.163.com/ninja_wk/blog/static/989155620073584237317/

Build your own Linux distribution on a USB disk

Objective

I've always wanted to be a Linux drive that starts and runs on a U disk. Recently spent some kung fu, initially made a basic can run such a system, now recorded, one for their future reference, and the other is to learn together with you; third, for this forum to add a bit of popularity.

1, my production environment;

First of all, the hardware environment, said only with the system can be related to the production: my u disk is a relatively early NETAC 64M disk, motherboard chip when an early version of SIS. I think the new motherboard and the new USB drive should now have better hardware compatibility than my hardware. I first the BIOS inside the boot media set to USB-HDD, the other three kinds of USB boot in my this time can not be successfully started.

My software environment, or my operating system, is Sarge.

2. My Basic Ideas

It is true to do a more complete practical system, preferably in the existing Linux distribution based on the processing and modification to do, such as Morphix, Knoppix, DSL and other based on reprocessing, but I do the main purpose of this system to meet their own curiosity, Also as a way of learning, so I started from more basic steps, including my own build the kernel, make the root directory system, their own configuration and so on---of course, it is best to write all the source code from their own most basic start, but that is not possible.

3, the production process;

3.1, compile the kernel;

The concrete compilation process does not say, the data is everywhere, in here the key is the attention in order to enable the U disk to start when can find own root directory system, needs to play a patch. Details about this patch are visible:

http://www.lammerts.org/software/kernelpatches/

Since this patch is 2.4.22 for the kernel, I have specifically downloaded the 2.4.22 version of the source code---I don't know if the patch works for other versions of the 2.4 kernel, and the patches for the 2.6 cores are different.

Then unpack--patch--compile--get bzimage, don't mention.

3.2, the production of root directory system;

There are also a lot of articles on the root system, and I'm not going to repeat it here, it's worth noting:

3.21, as the current use of the U disk, space is much looser than floppy disk, so I did not use BusyBox, but from my own work Sarge System Bin sbin lib directory directly copy what is needed.

3.22, generally we are using INITRD to start Linux in two phases, by INITRD to mount a U disk File system. Don't know why, I don't like this way. It has been proved that it is feasible to specify the root file system directly from grub or syslinux.

3.23, now my root directory almost no configuration files, even Inittab fstab and so on, and then improve it.

3.3, processing u disk;

First to use Fdisk cfdisk on U disk partitions, I put my u disk divided into two areas, the first 10M boot zone, the second is the 50M root zone, note that the boot partition is set to bootable---in DOS called Activation Bar.

Then I'm going to build the file system because I'm familiar with syslinux more than grub, so I use:

#mkdosfs/dev/sda1

#mke2fs/dev/sda2

Establish the boot partition as a FAT file system and establish the root partition as the Ext2 file system---Grub should not be so troublesome, so I'll study how to use GRUB to load the kernel on a USB drive.

And then we have to do this to the U disk syslinux processing:

#syslinux/DEV/SDA

Copy the relevant files to the U disk, after hanging the corresponding file system, the previous compiled kernel bzimage copied to the sda1, while the root file system to copy their own production to sda2.

Finally, write a syslinux configuration file and copy it into SDA1. (In fact, there are only three files in the sda1, one is the kernel; one is syslinux system files; one is the syslinux.cfg below)

#nano syslinux.cfg

Title Myusb

Kernel Bzimage

Root/dev/sda2

The production is completed, now start the computer can smoothly into my USB drive---Although the kernel in the start-up time will also report the root file system can not be found, but after a few toss, it found and successfully executed Init, now on the computer appears:

init#

It means you can use the USB U disk Linux system.

But this system can not do anything, need to create a lot of configuration files, such as the current system with the Nano vi editing files are always reported "Error opening terminal" Error and exit, need to replicate the original system/etc/terminfo/l/ Linux files to work correctly.

I was going to make a small C language learning system that could run gcc+rhide---just like using a floppy disk, copy on the DOS+TURBOC 1.0 can learn C language everywhere, but now things look so much more complicated, now to install GCC is very troublesome, but also need constant exploration.

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.