Specific implementation mode
To keep the purpose, technical scheme and advantage of disclosure embodiment clearer, below in conjunction with attached drawing to this public affairsThe technical solution opened is clearly and completely described, it is clear that and described embodiment is a part of embodiment of the disclosure,Rather than whole embodiment.Based on the embodiment in the disclosure, those of ordinary skill in the art are not making creationProperty labour under the premise of the every other embodiment that is obtained, belong to the range of disclosure protection.
It should be noted that above-mentioned each method embodiment is described in a progressive manner, each embodiment emphasisWhat is illustrated is all the difference with other embodiment, and identical similar part is mutually referring to i.e. between each embodimentIt can.
As shown in Figure 1, being the operating system making and installation environment schematic diagram that disclosure embodiment is related to, the operation systemSystem refers to internal memory operation system, and terminal 11 is connect with External memory equipment 12.When operating system makes, executed using the terminalThe associated documents of operating system are stored in the External memory equipment by manufacturing process, from the External memory equipment after completingStart, operating system is on the memory of the terminal.
It is herein CentOS (Community Enterprise Operating System, enterprise of community with operating systemOperating system) 6.8 versions for, sketch internal memory operation system installation process and start-up course, it is as follows:
Erection stage, by External memory equipment, such as SD card (Secure Digital Memory Card, secure digitalStorage card), it is divided into 3 subregions:Boot partition, boot partition (boot subregions) and main system subregion (rootfs subregions), thenIt guides file and legacy guiding files to install to boot partition EFI, operating system nucleus (kernel) is installed to bootSubregion.Include mainly initramfs-2.6.32-642.el6.x86_64.img and vmlinuz- in operating system nucleus2.6.32-642.el6.x86_64 wherein initramfs-2.6.32-642.el6.x86_64.img is first starting system mirror image.Decompress root file system rootfs.tar.gz to rootfs subregions.After guiding file installation, grub.cfg can be generated in SD card and is matchedFile is set, which can indicate the position of kernel file (kernel and first starting system).
Startup stage starts in the selection of the interfaces BIOS from SD card after restarting system.It is guided by EFI or legacy, according toIn configuration file grub.cfg configuration information load boot subregions under vmlinuz-2.6.32-642.el6.x86_64 andInitramfs-2.6.32-642.el6.x86_64.img, and then just starting system is run, complete the first starting system of switching root pointsThe startup of internal memory operation system is realized to the task of real root subregions in area.
The making of above-mentioned internal memory operation system and Starting mode, to the space size and partition size of External memory equipmentIt is required that relatively high, when operating system is larger, the size of SD card subregion is not enough to store, and operating system can not start.It is based onThis, proposes a kind of method, apparatus and realization device of start-up operation system in disclosure embodiment, it is possible to reduce occupancy is depositedThe memory space of equipment is stored up, operating system operation completely is in memory.
For ease of understanding present embodiment, first to a kind of start-up operation system disclosed in disclosure embodimentThe method of system describes in detail.
The method for the start-up operation system that disclosure embodiment provides, is applied to terminal, which is connected with outside and depositsEquipment is stored up, External memory equipment is previously stored with the guiding file, kernel and compressed root file system of operating system.The endEnd can be personal computer, server, mobile terminal etc. have memory and can with the intelligent terminal of running memory operating system,The External memory equipment is such as can be SD card, USB flash drive, mobile hard disk, CD.
Before the External memory equipment start-up operation system, need to carry out activation system in advance in the External memory equipmentInstallation, guiding file, kernel and root file system are saved after installation is complete in the External memory equipment.Wherein, root fileSystem is stored in a manner of compressed file in the External memory equipment.
A kind of flow diagram of the method for start-up operation system as shown in Figure 2, this approach includes the following steps:
Step S202 loads kernel according to guiding file.
Guiding file is installed in the erection stage of operating system, the boot partition of External memory equipment, guiding textPart is used for when terminal selection starts from the External memory equipment, and guiding load has been stored in interior in the External memory equipmentCore.In os starting, if terminal selection starts from External memory equipment, guided by guiding file, according to configurationThe information preserved in file determines the save location of kernel, to be loaded.
Step S204, the virtual disk files for decompressing root file system to the memory of terminal by kernel press from both sides.
The root file system is stored in the main system point of the External memory equipment in a manner of by compressed compressed fileQu Zhong.In os starting, the virtual magnetic that the compressed file solution of the root file system is first depressed into the memory of terminal is neededDisk file.Virtual disk files folder is a catalogue using memory virtual out, and the file in the catalogue is all to preserveIn memory, rather than on disk.Virtual disk files folder is the path of tmpfs (temporary file system).In root file systemAfter system solution is depressed into virtual disk files folder, just there is a complete file system in memory.
Due to stored on External memory equipment be root file system compressed file, occupy memory space it is small,The dependence to the space size of the External memory equipment and the limitation of the subregion to the External memory equipment can be reduced.
Step S206 sets virtual disk files folder position to main system subregion.
After the virtual disk files folder that root file system solution is depressed into memory by kernel, need virtual disk textPart folder position is set as main system subregion, that is, switches main system subregion to the virtual disk files and press from both sides.Startup can be changedThe variable of script thus switches to real main system subregion, i.e. the virtual disk files press from both sides position.For example, can incite somebody to actionThe root variables in init files in kernel are revised as virtual disk files folder position, and virtual disk files are pressed from both sidesIt is set as Shared Folders.
Step S208, into the above-mentioned root file system of main system partition running.
Enter root file system in the main system subregion and runs, which is to operate in the file system of memory, fromAnd it realizes operating system and starts in memory.Kernel source code need not be compiled in above process, so that it may to support memory to graspMake the installation and startup of system, it is easy to operate.
The method for the start-up operation system that disclosure embodiment provides, it is pre- in the External memory equipment being connect with terminalIt is first stored with guiding file, kernel and the root file system of operating system, which is stored in a manner of compressed fileIn the External memory equipment;When terminal starts from External memory equipment, which is depressed into the virtual magnetic of memoryDisk file, then set virtual disk files folder position to main system subregion, into main system partition running root textPart system, to realize that operating system starts in memory, it is possible to reduce occupy the memory space of External memory equipment, operation systemSystem operation completely in memory, and need not compile kernel.
Since internal memory operation system can not can deposit after a loss of power by information preservation in the memory of terminal in outsideIt stores up on the basis of dividing boot partition, boot partition and main system subregion in equipment, configuration subregion can also be divided, the configuration pointArea is used to preserve the operation information of operating system, which had both included the information that system generates or inputted or set including userThe information set.Accordingly, the above method can also include the following steps:The operation information of operating system is recorded to configuring subregion,Wherein, operation information includes:Log information during operating system and/or the specify information received from user side.
The log information, can be memory operation operating system during record operation log and debugging log (orClaim error log), it can conveniently check the operation conditions of system;The specify information can be setting information input by user etc.,Such as booting is required for the information etc. of input every time, re-enters or is arranged when without being switched on every time, it is possible to reduceThe operation of user.
Above-mentioned configuration subregion both could be provided as automatically saving the path of operation information, prompt to use when can also shut down every timeWhether family preserves operation information to the path.If selection is set as automatically saving the path of operation information, the above method also wrapsIt includes:It, will be in configuration subregion carry to operating system after operating system.
In view of root file system is stored in a manner of compressed file in the External memory equipment, interfere in order to preventThe operating of system can create a new file as specified folder, the compressed package of root file system is stored in thisSpecified folder, the step that the virtual disk files for decompressing root file system to the memory of terminal by kernel in the above method press from both sidesSuddenly, it can execute in the following manner:
(1) store path that root file system is obtained by kernel, obtains specified folder position.In opening for kernelFind main system subregion in dynamic script, and by the specified folder of its carry to first starting system.
(2) virtual disk files for copying root file system to the memory of terminal from specified folder position press from both sides.It shouldVirtual disk files folder can be memory /paths dev/shm.
(3) local decompression root file system.The root file system is decompressed in memory, to which memory obtains complete fileSystem.Compression by root file system and decompression can make root file system occupy less memory space, can also allowFile transmission is more convenient.
Illustrate the method for the start-up operation system that disclosure embodiment provides by taking CentOS6.8 as an example below, outside is depositedStorage equipment is illustrated by taking SD card as an example.The flow diagram of installation shown in Figure 3 and the method for start-up operation system,In show from the flow for being installed to startup, include the following steps:
Step S302, terminal carry out subregion to SD card in advance.
In erection stage, SD card is divided into 4 subregions, mainly boot partition, startup (boot) subregion, configuration point by terminalArea and main system (rootfs) subregion.Wherein, configuration subregion is used to preserve the operation information of operating system.
Step S304 replicates kernel file to boot subregions, and installs kernel.
EFI guiding files are installed after subregion and legacy guides file, kernel (kernel) to be installed to boot subregions,Include mainly initramfs-2.6.32-642.el6.x86_64.img and vmlinuz-2.6.32- in kernelThe not first starting system mirror image of 642.el6.x86_64, wherein initramfs-2.6.32-642.el6.x86_64.img.
Step S306 replicates rootfs.tar.gz to rootfs subregions.
The rootfs.tar.gz is the compression that root file system is packaged by tar programs and is generated by gzip program compactionsFile.It is compressed it should be noted that can also be packaged by extended formatting, such as tar programs are packaged, are beaten by tar programsWrap and compressed by bzip2 program compactions or zip etc..
Step S308, restarts system, and at the interfaces BIOS, selection starts from SD card.
It is the installation process of internal memory operation system before this step, is the startup of internal memory operation system from this stepJourney.
Step S310 judges guidance mode for EFI guiding or legacy guiding.It is guided if it is EFI, executes stepS312;It is guided if it is legacy, executes step S314.
Step S312 executes the grub.cfg under EFI.
Step S314 executes the grub.cfg under legacy.
It after system reboot, is guided by EFI or legacy, according under the configuration load boot subregions in grub.cfgVmlinuz-2.6.32-642.el6.x86_64 and initramfs-2.6.32-642.el6.x86_64.img, whereinInitramfs-2.6.32-642.el6.x86_64.img is first starting system, and it includes init files and mount_rootFile starts internal memory operation system and is mainly completed in both of these documents.
Step S316 runs init scripts into first starting system.
Step S318, by the rootfs subregions carry of SD card to first starting system.
Find SD card rootfs subregions in init scripts, and by the particular file folder under its carry to first starting system.ForThe operating for preventing interference system, can create a file, such as be named as/test, can be looked for at/test after carryTo compressed file rootfs.tar.gz.
Step S320, by rootfs.tar.gz unzip to memory /dev/shm files.
By compressed file rootfs.tar.gz unzip to memory /dev/shm files, this document folder is tmpfs firstPosition in starting system, there are one complete file system in memory at this time.
Step S322, it is to be somebody's turn to do/dev/shm files to specify main system subregion.
Step S324, in mount_root scripts, carry to real main system subregion.
In above-mentioned two step, the root variables in init scripts can be revised as block:/ dev/shm, and repairThe order for changing the mount root in mount_root scripts is mount--bind " $ { root#block:" " $ NEWROOT ",The order is to switch the order of real rootfs subregions, is revised as/dev/shm, is achieved that internal memory operation systemStart.
Step S326, into root file system.The system is the file system run in memory, so far start-up courseTerminate.
After the completion of start-up course, terminal enters internal memory operation system, can be by configuration subregion carry to internal memory operation systemIn system, permanent configuration information is needed for preserving, the flexibility of internal memory operation system can be increased, user is facilitated to makeWith.
The method for the start-up operation system that disclosure embodiment provides, root file system are stored in a manner of compressed fileIn the External memory equipment;When terminal starts from External memory equipment, which is depressed into the virtual magnetic of memoryDisk file, then set virtual disk files folder position to main system subregion, into main system partition running root textPart system, to realize that operating system starts in memory.Root file system is compressed, it is possible to reduce memory spaceIt occupies;In start-up course, root file system is unziped in memory, realizes the operating system of operation in memory completely;Kernel, which need not be compiled, also can make the internal memory operation system for operating in memory completely.
On the basis of the above embodiment, the disclosure is embodiment further provides a kind of device of start-up operation system,Applied to terminal, terminal is connected with External memory equipment, and External memory equipment is previously stored with the guiding file, interior of operating systemCore and compressed root file system.
A kind of structure diagram of the device of start-up operation system as shown in Figure 4, the device include:Load-on module 41, solutionDie block 42, main system subregion setup module 43 and starting module 44, the function of modules are as follows:
Load-on module 41, for loading kernel according to guiding file;
Decompression module 42, the virtual disk files for decompressing root file system to the memory of terminal by kernel press from both sides;
Main system subregion setup module 43, for setting virtual disk files folder position to main system subregion;
Starting module 44, for entering main system partition running root file system.
The device for the start-up operation system that disclosure embodiment provides, it is pre- in the External memory equipment being connect with terminalIt is first stored with guiding file, kernel and the root file system of operating system, which is stored in a manner of compressed fileIn the External memory equipment;When terminal starts from External memory equipment, which is depressed into the virtual magnetic of memoryDisk file, then set virtual disk files folder position to main system subregion, into main system partition running root textPart system, to realize that operating system starts in memory, it is possible to reduce occupy the memory space of External memory equipment, operation systemSystem operation completely in memory, and need not compile kernel.
Being divided in advance on External memory equipment has configuration subregion, Fig. 5 to show the device of another start-up operation systemStructural schematic diagram, above-mentioned apparatus further includes:Logging modle 51, for recording the operation information of operating system to configuring subregion.The operation information includes:Log information during operating system and/or the specify information received from user side.
Fig. 6 shows that the structural schematic diagram of the device of another start-up operation system, above-mentioned apparatus further include:Carry module61, for that after operating system, will configure in subregion carry to operating system.
Compressed root file system is stored in the specified folder of External memory equipment, and above-mentioned decompression module 42 is also usedIn:The store path that root file system is obtained by kernel, obtains specified folder position;Specified folder positionThe virtual disk files for copying root file system to the memory of terminal press from both sides;Local decompression root file system.
Above-mentioned main system subregion setup module 43 is additionally operable to:Root variables in init files in kernel are revised as voidQuasi- disk file presss from both sides position, and virtual disk files sandwiched is set to Shared Folders.
The device for the start-up operation system that disclosure embodiment provides, the start-up operation system provided with the above embodimentThe method technical characteristic having the same of system reaches identical technique effect so can also solve identical technical problem.
Embodiment further provides a kind of realization device of start-up operation system, one kind shown in Figure 7 to open for the disclosureThe structural schematic diagram of the realization device of dynamic operating system, the realization device of the start-up operation system includes processor 700 and machineReadable storage medium storing program for executing 701, machine readable storage medium 701 are stored with the machine-executable instruction that can be executed by processor 700,The method that processor 700 executes machine-executable instruction to realize the above embodiment offer.
The realization device of start-up operation system shown in Fig. 7 further includes bus 702 and communication interface 703, processor 700,Communication interface 703 and machine readable storage medium 701 are connected by bus 702.
Wherein, machine readable storage medium 701 may include high-speed random access memory (RAM, Random AccessMemory), it is also possible to further include non-labile memory (non-volatile memory), a for example, at least disk is depositedReservoir.By at least one communication interface 703 (can be wired or wireless) realize the system network element with it is at least one otherCommunication connection between network element can use internet, wide area network, local network, Metropolitan Area Network (MAN) etc..Bus 702 can be that ISA is totalLine, pci bus or eisa bus etc..The bus can be divided into address bus, data/address bus, controlling bus etc..For ease of tableShow, only indicated with a four-headed arrow in Fig. 7, it is not intended that an only bus or a type of bus.
Processor 700 may be a kind of IC chip, the processing capacity with signal.It is above-mentioned during realizationEach step of method can be completed by the integrated logic circuit of the hardware in processor 700 or the instruction of software form.OnThe processor 700 stated can be general processor, including central processing unit (Central Processing Unit, abbreviationCPU), network processing unit (Network Processor, abbreviation NP) etc.;It can also be digital signal processor (DigitalSignal Processing, abbreviation DSP), application-specific integrated circuit (Application Specific IntegratedCircuit, abbreviation ASIC), ready-made programmable gate array (Field-Programmable Gate Array, abbreviation FPGA) orPerson other programmable logic device, discrete gate or transistor logic, discrete hardware components.It may be implemented or execute sheetDisclosed each method, step and logic diagram in disclosed embodiment.General processor can be microprocessor or this atIt can also be any conventional processor etc. to manage device.The step of method in conjunction with disclosed in disclosure embodiment, can direct bodyBe now that hardware decoding processor executes completion, or in decoding processor hardware and software module combine and execute completion.It is softPart module can be located at random access memory, and flash memory, read-only memory, programmable read only memory or electrically erasable programmable are depositedIn the storage medium of this fields such as reservoir, register maturation.The storage medium is located at machine readable storage medium 701, processorInformation in 700 read machine readable storage medium storing program for executing 701, in conjunction with its hardware complete aforementioned embodiments method the step of.
Further, embodiment further provides a kind of machine readable storage medium, the machine readable storage mediums for the disclosureIt is stored with machine-executable instruction, when being called and being executed by processor, machine-executable instruction promotes machine-executable instructionProcessor realizes the method that the above embodiment provides.
It is apparent to those skilled in the art that for convenience and simplicity of description, the system of foregoing descriptionWith the specific work process of device, the corresponding process in preceding method embodiment can be referred to, details are not described herein.
Finally it should be noted that:Embodiment of above, the only specific implementation mode of the disclosure, to illustrate the disclosureTechnical solution, rather than its limitations, the protection domain of the disclosure are not limited thereto, although with reference to aforementioned embodiments to this public affairsIt opens and is described in detail, it should be understood by those skilled in the art that:Any one skilled in the art is in this public affairsIt opens in the technical scope of exposure, still can modify or can be thought easily to the technical solution recorded in aforementioned embodimentsTo variation or equivalent replacement of some of the technical features;And these modifications, variation or replacement, do not make correspondingThe essence of technical solution is detached from the spirit and scope of disclosure embodiment technical solution, should all cover the protection model in the disclosureWithin enclosing.Therefore, the protection domain of the disclosure should be subject to the protection scope in claims.