A software upgrade method, computing device and readable storage medium

By adopting the software upgrade method of cascading file mode in computing devices, the problems of high resource consumption and inconvenient fallback in the existing technology are solved, and the software is flexible upgrade and fallback are realized, and the user experience is improved.

CN114003258BActive Publication Date: 2024-11-08WUHAN SHENZHIDU TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111280506.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-10-29
Publication Date
2024-11-08
Estimated Expiration
2041-10-29

AI Technical Summary

Technical Problem

Existing software upgrade methods, such as the installation of the specified version and the A/B system, have problems such as high resource consumption and insufficient lightness. Especially when the upgrade fails, the system cannot be effectively protected, resulting in poor user experience.

Method used

Using the software upgrade method based on the cascading file mode, by creating virtual disk device files, the upgraded data is stored in the upper data layer, and after success, it is merged to the lower data layer to achieve persistent storage of the software; when it fails, it will automatically fall back to The original version avoids reinstalling the system.

Benefits of technology

This method realizes persistent storage of the software version after successful upgrade, and flexibly falls back when it fails, improves user experience, and reduces resource consumption, avoids the need to separate backup systems, and is more efficient than A/B systems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114003258B_ABST
    Figure CN114003258B_ABST
Patent Text Reader

Abstract

The present invention discloses a software upgrade method, a computing device and a readable storage medium. The method of the present invention is executed in a computing device resident with an operating system, and includes: creating a virtual disk device file. Starting the operating system in a cascade file mode, wherein a first file copy of the virtual disk device file is made and set as a storage medium of an upper data layer in the cascade file mode. Performing a software upgrade. After the upgrade is completed, the first file copy is copied to the virtual disk device file. Restarting in the cascade file mode, wherein a second file copy of the virtual disk device file is made and set as a storage medium of an upper data layer. After restarting, detecting whether the upgrade is successful. If successful, the lower data layer in the cascade file mode is set to be readable and writable, and the lower data layer is modified to save the upgraded version of the software; if unsuccessful, starting the system in a normal mode to roll back to the version before the software upgrade. The present invention can flexibly implement software upgrade or rollback.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computers, and in particular to a software upgrading method, a computing device and a readable storage medium. Background Art

[0002] Software upgrade refers to the update of software from a lower version to a higher version. Since higher versions often fix some bugs in lower versions, the upgraded software version generally has better performance than the original version, which can provide users with a better experience. However, software upgrades often fail during software upgrades, affecting the user experience. Based on this, rollback software upgrade methods have emerged. Rollback software upgrade methods mean that after a system upgrades a certain software package, if the upgraded version is found to be unavailable, it can be rolled back to the previous version.

[0003] Currently, there are two main methods for rolling back software upgrades. Specified version installation: When you need to roll back to a previous version, reinstall the specified previous version. Adopting A / B system: There are two systems on the device. The currently running system is called A system (main system), and the other backup system is called B system (backup system). When upgrading the system, first back up the data on the A system disk to the B system, and then upgrade it. After the upgrade is complete, restart. If the A system can start normally at this time, it means the upgrade is successful; if it cannot start normally, it will automatically switch to the B system for use, which is equivalent to rolling back to the state before the upgrade.

[0004] However, both of the above solutions have certain disadvantages. Specifically, since the specified version installation has no protection mechanism, it is equivalent to directly modifying the system. Therefore, if the upgrade fails using this solution and the system is damaged and cannot be started, there is no way to roll back and the system can only be reinstalled. The A / B system solution requires two systems to be installed on the machine, and each time the upgrade is performed, no matter how much or how little the system changes, the entire disk data of the current system needs to be backed up to the disk of another system. Therefore, using this solution is not only resource-consuming, but also time-consuming and not portable.

[0005] Based on this, a new software upgrade method is urgently needed to solve the above technical problems. Summary of the invention

[0006] To this end, the present invention provides a software upgrade method, a computing device and a readable storage medium, in an effort to solve or at least alleviate the above problems.

[0007] According to one aspect of the present invention, a software upgrade method is provided, which is executed in a computing device on which an operating system resides, the method comprising: creating a virtual disk device file; starting the operating system in a cascade file mode, wherein in the cascade file mode, a lower data layer in which data is read-only and an upper data layer in which data is readable and writable are constructed in the operating system, a first file copy of the virtual disk device file is made, and the first file copy is set as a data storage medium of the upper data layer; performing a software upgrade in the operating system of the computing device; after the software upgrade is completed, copying the first file copy as a virtual disk device file; restarting the operating system in the cascade file mode, wherein a second file copy of the virtual disk device file is made, and the second file copy is set as a data storage medium of the upper data layer; detecting whether the software upgrade is successful; if the software upgrade is successful, setting the lower data layer as data readable and writable, and modifying the data in the lower data layer based on the data in the upper data layer to obtain a version of the operating system after the software upgrade, and starting the operating system after the software upgrade in a normal mode; if the software upgrade is unsuccessful, starting the operating system in a normal mode to roll back to the version of the operating system before the software upgrade.

[0008] Optionally, in the software upgrade method according to the present invention, the step of creating a virtual disk device file includes: creating a virtual disk device file in the same format as the root partition under the root partition of the operating system.

[0009] Optionally, in the software upgrade method according to the present invention, the steps of constructing a lower data layer with read-only data and an upper data layer with readable and writable data in the operating system include: using the directory mounted by the root partition of the operating system as the lower data layer; creating a temporary file system partition, and mounting the temporary file system partition to an associated directory of the temporary file system directory of the operating system to use the temporary file system partition as the upper data layer.

[0010] Optionally, in the software upgrade method according to the present invention, the step of making a first file copy of the virtual disk device file and setting the first file copy as the data storage medium of the upper data layer includes: copying the virtual disk device file to generate a first file copy; copying the first file copy to an associated directory so that the first file copy serves as the data storage medium of the upper data layer.

[0011] Optionally, in the software upgrade method according to the present invention, the associated directory is a temporary file system directory or a subdirectory of the temporary file system directory.

[0012] Optionally, in the software upgrade method according to the present invention, the step of performing software upgrade in the operating system of the computing device includes: placing software upgrade data into the upper data layer; placing original software data into the lower data layer; and executing software upgrade.

[0013] Optionally, in the software upgrade method according to the present invention, the upgrade data includes original data and modified data of the software, and the step of modifying the data in the lower data layer based on the data in the upper data layer to obtain the operating system version after the software upgrade includes: overwriting the data in the lower data layer with the data in the upper data layer to obtain the operating system version after the software upgrade.

[0014] Optionally, in the software upgrade method according to the present invention, the upgrade data is the modification data of the software, and the step of modifying the data in the lower data layer based on the data in the upper data layer to obtain the operating system version after the software upgrade includes: merging the data in the upper data layer into the lower data layer to obtain the operating system version after the software upgrade.

[0015] Optionally, in the software upgrade method according to the present invention, the overlay file mode is overlayroot mode.

[0016] According to another aspect of the present invention, a computing device is provided, comprising: at least one processor; and a memory storing program instructions, wherein the program instructions are configured to be suitable for execution by the at least one processor, and the program instructions include instructions for executing the software upgrade method according to the present invention.

[0017] According to another aspect of the present invention, a readable storage medium storing program instructions is provided. When the program instructions are read and executed by a computing device, the computing device executes the software upgrade method according to the present invention.

[0018] According to the solution of the present invention, a virtual disk device file is created, and after the software is upgraded, the upgraded version data is stored in the virtual disk device file, so that the upgraded version data of the software can be saved. In this way, when the software is successfully upgraded, the upgraded software version can be obtained by modifying the data in the lower data layer based on the upgraded version data saved above, and can be persisted. When the software upgrade fails, the operating system is started in normal mode to implement software rollback. It can be seen that the solution of the present invention can flexibly permanently save or delete the upgraded version data when upgrading the software, so that the software upgrade or rollback can be flexibly implemented, which improves the user experience.

[0019] Compared with the installation of the specified version, the solution of the present invention performs all modifications on the upper data layer, and the rollback after the upgrade fails is very thorough and safe. Compared with the A / B system, it is no longer necessary to allocate a separate disk to install the backup system, which reduces the consumption of resources. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] To achieve the above and related purposes, certain illustrative aspects are described herein in conjunction with the following description and accompanying drawings, which indicate various ways in which the principles disclosed herein can be practiced, and all aspects and their equivalents are intended to fall within the scope of the claimed subject matter. The above and other purposes, features and advantages of the present disclosure will become more apparent by reading the following detailed description in conjunction with the accompanying drawings. Throughout the present disclosure, the same reference numerals generally refer to the same parts or elements.

[0021] Figure 1 A structural block diagram of a computing device 100 according to an embodiment of the present invention is shown;

[0022] Figure 2 A flowchart of a software upgrade method 200 according to an embodiment of the present invention is shown;

[0023] Figure 3 A basic structural diagram of overlayfs according to an embodiment of the present invention is shown;

[0024] Figure 4 A schematic diagram showing a flowchart of a software upgrade method 400 according to yet another embodiment of the present invention. DETAILED DESCRIPTION

[0025] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.

[0026] When software developers write software, they often need to upgrade the software after it is released due to factors such as incomplete considerations by the developers, imperfect software functions, additions and deletions of software functions, etc. However, after the software is upgraded, there may be problems such as version inconsistency, which makes the upgraded software unable to run and cannot be restored to the previous version.

[0027] To solve the above problems, a rollback software upgrade solution is proposed, that is, after the software upgrade fails, it can be rolled back to the version before the upgrade to ensure that the software can be used normally. Common rollback software upgrade solutions include specified version installation, A / B system installation, etc. However, these methods have more or less some disadvantages. For example, since the specified version installation has no protection mechanism, it is equivalent to directly modifying the system. Therefore, if this solution fails to upgrade and the system is damaged and cannot be started, there is no way to roll back and the system can only be reinstalled. The A / B system solution requires two systems to be installed on the machine, and each time the system is upgraded, no matter how much or how little the system is modified, the entire disk data of the current system needs to be backed up to the disk of another system. Therefore, using this solution not only consumes resources, but also is very time-consuming and not portable.

[0028] Based on this, the solution of the present invention is proposed. An embodiment of the present invention provides a software upgrade method, which can be executed in a computing device. Figure 1 FIG. 1 shows a block diagram of a computing device 100 according to an embodiment of the present invention. It should be noted that: Figure 1 The computing device 100 shown is only an example. In practice, the computing device used to implement the software upgrade method of the present invention can be any type of device, and its hardware configuration can be different from the above. Figure 1 The computing device 100 shown is the same as Figure 1 The computing device 100 shown is different. In practice, the computing device used to implement the software upgrade method of the present invention can be Figure 1 The hardware components of the computing device 100 shown are increased or deleted, and the present invention does not limit the specific hardware configuration of the computing device.

[0029] like Figure 1 As shown, in a basic configuration 102, computing device 100 typically includes system memory 106 and one or more processors 104. A memory bus 108 may be used for communication between processor 104 and system memory 106.

[0030] Depending on the desired configuration, the processor 104 can be any type of processor, including but not limited to: a microprocessor (μP), a microcontroller (μC), a digital information processor (DSP), or any combination thereof. The processor 104 can include one or more levels of cache such as a first-level cache 110 and a second-level cache 112, a processor core 114, and registers 116. An example processor core 114 can include an arithmetic logic unit (ALU), a floating point unit (FPU), a digital signal processing core (DSP core), or any combination thereof. An example memory controller 118 can be used with the processor 104, or in some implementations, the memory controller 118 can be an internal part of the processor 104.

[0031] Depending on the desired configuration, the system memory 106 can be any type of memory, including but not limited to: volatile memory (such as RAM), non-volatile memory (such as ROM, flash memory, etc.) or any combination thereof. The physical memory in the computing device generally refers to the volatile memory RAM, and the data in the disk needs to be loaded into the physical memory before it can be read by the processor 104. The system memory 106 may include an operating system 120, one or more applications 122, and program data 124. In some embodiments, the application 122 may be arranged to execute instructions on the operating system by one or more processors 104 using program data 124. The operating system 120 may be, for example, Linux, Windows, etc., which includes program instructions for processing basic system services and performing tasks that depend on hardware. The application 122 includes program instructions for implementing various user-desired functions, and the application 122 may be, for example, a browser, instant messaging software, a software development tool (such as an integrated development environment IDE, a compiler, etc.), etc., but is not limited thereto. When the application 122 is installed in the computing device 100, a driver module may be added to the operating system 120.

[0032] When the computing device 100 starts running, the processor 104 reads and executes the program instructions of the operating system 120 from the system memory 106. The application 122 runs on the operating system 120 and uses the interfaces provided by the operating system 120 and the underlying hardware to implement various functions desired by the user. When the user starts the application 122, the application 122 is loaded into the system memory 106, and the processor 104 reads and executes the program instructions of the application 122 from the system memory 106.

[0033] Computing device 100 also includes a storage device 132 including a removable storage 136 and a non-removable storage 138 , both of which are connected to storage interface bus 134 .

[0034] The computing device 100 may also include an interface bus 140 that facilitates communication from various interface devices (e.g., output devices 142, peripheral interfaces 144, and communication devices 146) to the basic configuration 102 via the bus / interface controller 130. Example output devices 142 include a graphics processing unit 148 and an audio processing unit 150. They can be configured to facilitate communication with various external devices such as a display or speakers via one or more A / V ports 152. Example peripheral interfaces 144 may include a serial interface controller 154 and a parallel interface controller 156, which may be configured to facilitate communication with external devices such as input devices (e.g., keyboards, mice, pens, voice input devices, touch input devices) or other peripherals (e.g., printers, scanners, etc.) via one or more I / O ports 158. Example communication devices 146 may include a network controller 160, which may be arranged to facilitate communication with one or more other computing devices 162 via a network communication link via one or more communication ports 164.

[0035] A network communication link can be an example of a communication medium. Communication media can generally be embodied as computer-readable instructions, data structures, program modules in a modulated data signal such as a carrier wave or other transmission mechanism, and can include any information delivery medium. A "modulated data signal" can be a signal in which one or more of its data sets or its changes can be carried out in a manner that encodes information in the signal. As non-limiting examples, communication media can include wired media such as a wired network or a dedicated line network, and various wireless media such as sound, radio frequency (RF), microwave, infrared (IR) or other wireless media. The term computer-readable medium used herein can include both storage media and communication media.

[0036] In the computing device 100 according to the present invention, the application 122 includes instructions for executing the software upgrade method 200 of the present invention, and the instructions can instruct the processor 104 to execute the software upgrade method of the present invention. Those skilled in the art can understand that, in addition to the instructions for executing the software upgrade method 200, the application 122 can also include other applications 126 for implementing other functions.

[0037] Figure 2 A flowchart of a software upgrade method 200 according to an embodiment of the present invention is shown. The method 200 is suitable for upgrading a software on a computing device (eg Figure 1 The computing device 200 is shown in the figure. An operating system resides in the computing device, wherein the operating system may be a Linux operating system, or other operating systems, which is not specifically limited in the present invention.

[0038] The purpose of the method 200 of the present invention is to implement a software upgrade method based on cascading technology, specifically, a software upgrade method based on overlayroot technology. Among them, overlayroot is a special application of the overlayfs file system. Overlayfs is a stacking file system that relies on and is built on other file systems. It does not directly participate in the division of the disk space structure. It only "merges" different directories and files in the original file system and then presents them to the user. Therefore, for the user, the content under the root directory of the overlay file system comes from the "collection" of different directories specified when mounting. See Figure 3 , Figure 3 A basic structural diagram of overlayfs according to an embodiment of the present invention is shown.

[0039] Among them, the lower data layer A / lower data layer B directory and the upper data layer directory are different directories from the underlying file system, which can be specified by the user. They contain the files and directories that the user wants to merge, and the mount directory is the mount point. When the file system is mounted, the contents from the lower data layer and the upper data layer directories will be seen in the mount directory at the same time, and the user cannot (does not need to) perceive which of these files are from the lower data layer and which are from the upper data layer. The user only sees an ordinary file system root directory (the lower data layer can have multiple or only one).

[0040] Although overlayfs merges directories at different levels, the upper data layer and the lower data layers are not completely equivalent and have a hierarchical relationship. First, when the upper data layer and the lower data layer have files with the same name, the files in the lower data layer will be hidden, and users can only see the files from the upper data layer. Then, the lower data layers also have the same hierarchical relationship, and the upper layer shields the files with the same name in the lower layer. In addition, if there are directories with the same name, continue to merge. Figure 3 As shown in , folder 2 in the lower data layer A will be overwritten by folder 2 in the upper data layer.

[0041] The upper data layer in each layer of directory is a readable and writable directory. When the user writes data to one of the files from the upper data layer by mounting the directory, the data will be directly written to the original file under the upper data layer. The same applies to deleting files. The lower data layers are read-only. After overlayfs is mounted, no matter how the files or directories corresponding to the lower data layers in the mounted directory are operated, the contents of the lower data layers will not be changed. Since the lower data layer is read-only, when the user wants to add or modify the content of the files from the lower data layer, overlayfs will first copy a copy of the files in the lower data layer to the upper data layer. Subsequent write and modify operations will be performed in the lower data layer copy file under the upper data layer, and the original files of the lower data layer will be hidden.

[0042] overlayroot actually modifies the mount point of overlayfs (from the original root partition mount point to the non-root partition mount point) to add a protection layer on the entire root partition, which is a bit like the Ps layer. After that, any root partition modification operations on the system are performed on the protection layer (the replaced mount directory) and will not modify the original root partition content. When overlayroot exits, this protection layer is removed and the root partition is restored to its original appearance. This protection layer is the upper data layer.

[0043] Therefore, when using overlayroot technology to implement software upgrades, the upgrade data is stored in the upper data layer, and the original data of the software (current version data) is stored in the mount directory mounted by the lower data layer. In this way, when the software is upgraded, the original data of the software will not be changed, and all upgrade work is performed in the upper data layer. When the software upgrade fails, the software can be rolled back through the original data.

[0044] like Figure 2 As shown, the software upgrading method 200 of the present invention starts at step S210.

[0045] In step S210, a virtual disk device file is created. According to one embodiment of the present invention, a virtual disk device file can be created as a storage medium for the upper data layer of overlayroot. However, when the created virtual disk device file is used as the storage medium for the upper data layer, the created virtual disk device file needs to be consistent with the format of the default storage medium of the upper data layer so that the data in the upper data layer can be stored in the virtual disk device file. Specifically, in some embodiments, a virtual disk device file with the same format as the root partition is created under the root partition of the operating system.

[0046] In a specific example, a virtual disk device file can be created by using the overlayroot enable function. The main functions of this function are: first, using the dd command to create a virtual disk file under the root partition; second, modifying the overlayroot configuration file, changing overlayroot="":" to overlayroot="device:dev=" / dev / loop0, recurse="0", indicating that overlayroot is enabled and the storage medium of the upper data layer is the / dev / loop0 device.

[0047] According to one embodiment of the present invention, the exemplary code of the overlayroot enable function is as follows:

[0048]

[0049] It should be noted that the creation of the virtual disk device file is performed during the start-up phase of overlayroot. At this stage, overlayroot has not yet been mounted. The virtual disk device file is created under the root partition of the operating system, and the path is not limited. After the virtual disk device file is created, restart the operating system.

[0050] In step S220, the operating system is started in the overlay file mode, wherein in the overlay file mode, a lower data layer with read-only data and an upper data layer with readable and writable data are constructed in the operating system. A first file copy of the virtual disk device file is made, and the first file copy is set as the data storage medium of the upper data layer. Preferably, the overlay file mode used in this embodiment is the overlayroot mode.

[0051] Booting the operating system in cascade file mode is completed in two stages.

[0052] In the first stage, a lower data layer with read-only data and an upper data layer with readable and writable data are constructed in the operating system.

[0053] Specifically, on the one hand, the directory mounted by the root partition of the operating system is used as the lower data layer. In this embodiment, the directory mounted by the root partition of the operating system is used as the lower data layer, so that all data of the operating system are used as data in the lower data layer. The original data of the software (i.e., the version data before the software upgrade) naturally belongs to the lower data layer.

[0054] On the other hand, a temporary file system partition is created, and the temporary file system partition is mounted to a directory associated with a temporary file system directory of the operating system, so that the temporary file system partition is used as an upper data layer.

[0055] It should be noted that a partition is a logical block of space allocated from the entire disk. Depending on how the system was configured during installation, there may be one or more partitions on the disk. For example, a new hard disk is like a rough house. Before you put things (such as furniture) in it, it needs to have a certain structure and walls inside. Partitions are the first layer of the disk. Once the disk is logically divided into partitions, you can think of it as a house with rooms. Each partition (room) has a certain size, which can be changed by moving it, but it will cause some disruption, just like moving things to make room. After the partition (room) is created, it can be formatted with the file system of choice. After the file system is determined, the partition can be filled with data in the form of files and folders (furniture). In addition, "mount" is a term that refers to when a file system is made available to the system.

[0056] In some embodiments, the associated directory is a temporary file system directory or a subdirectory of a temporary file system directory. The temporary file system directory is a first-level directory of the root directory of the operating system, generally referring to the / run directory. Taking " / A / b" as an example, A refers to the first-level directory of the root directory, and b refers to the second-level directory of the root directory (at the same time, b is the first-level directory of the A directory, and b is also called a subdirectory of the A directory).

[0057] It should be noted that / run is a directory of the operating system itself, which can be used to store temporary data when the system is running. Therefore, the / run directory can be used to mount the created tmpfs partition (i.e., temporary file system partition or memory file system partition). However, after testing two versions, it was found that the capacity of this directory is related to the size of the machine memory, with a ratio of about 10 to 1. With 8G memory, the / run directory space is approximately close to 800M. If the physical memory is 4G, the / run directory space is approximately close to 400M (these are the rules observed in the test). In this way, for computing devices with smaller memory, when the data in the upper data layer is large, the / run directory will be full, which will cause the subsequent overlayroot mounting to fail and the system to have problems. Therefore, in order to solve this problem, you can create a subdirectory / run / overlayroot under the / run directory and mount tmpfs to this subdirectory, which can avoid system problems caused by insufficient / run storage capacity.

[0058] In the second stage, a first file copy of the virtual disk device file is made, and the first file copy is set as a data storage medium of the upper data layer.

[0059] Specifically, first, the virtual disk device file is copied to generate a first file copy.

[0060] Then, the first file copy is copied to the associated directory, so that the first file copy serves as a data storage medium of the upper data layer.

[0061] In a specific example, when the operating system is started in cascading mode, the overlayroot pre-mount script, the overlayroot mount script, and the overlayroot post-mount script are executed in sequence.

[0062] The main task of the overlayroot pre-mount script is to first determine whether the overlayroot configuration file is equipped with the storage medium of the data layer, and when the storage medium device is / dev / loop0, create a tmpfs partition and mount it to the / run / overlayroot directory. Then, copy the virtual disk device file of the root partition to / run / overlayroot to generate the first file copy. Finally, use the losetup command under overlayroot to set the first file copy to the loop device ( / dev / loop0). Since the overlayroot start function has associated the upper data layer with / dev / loop0, executing the overlayroot mount script at this time can overlay the first file copy on the original root partition. In this way, the first file copy is set as the storage medium of the upper data layer.

[0063] According to one embodiment of the present invention, the exemplary code of the overlayroot pre-mount script is as follows:

[0064] #! / bin / sh

[0065] case "$1" in

[0066] #no pre-reqs

[0067] prereqs)echo "";exit 0;;

[0068] esac

[0069] PATH= / usr / sbin: / usr / bin: / sbin: / bin

[0070] MYTAG="my"

[0071] ROOTMNT=${rootmnt}

[0072] LOOP_DEV=" / dev / loop0"

[0073] isEnableOverlayRoot=$(grep"^overlayroot="${ROOTMNT} / etc / overlayroot.conf|awk-F\"'{print$2}')||isEnableOverlayRoot=

[0074] if[-z"${isEnableOverlayRoot}"];then

[0075] echo"Overlayroot is not enable"

[0076] else

[0077] overlayroot_device=$(echo$isEnableOverlayRoot|awk-F\:'{print$2}'|\

[0078] awk-F\,'{print$1}'|awk-F\='{print$2}')

[0079] if["$overlayroot_device"="$LOOP_DEV"];then

[0080] mkdir / run / overlayroot

[0081] mount-t tmpfs-o size=1G tmpfs / run / overlayroot

[0082] cp${ROOTMNT} / usr / lib / deepin-graphics-driver-manager / working-dir / overlayroot.img\ / run / overlayroot

[0083] [-e"${LOOP_DEV}"]||mknod${LOOP_DEV}b 7 0

[0084] losetup${LOOP_DEV} / run / overlayroot / overlayroot.img

[0085] fi

[0086] fi

[0087] exit 0

[0088] The overlayroot mount script's main task is to first change the mount point of the root partition to the / media / root_ro directory, then mount the upper (i.e., upper data layer) storage device ( / dev / loop0) specified in the overlayroot configuration file to the / media / root_rw directory, and finally mount overlayroot.

[0089] According to one embodiment of the present invention, the exemplary code of the overlayroot mounting script is as follows:

[0090] mount -t overlay -o\

[0091] lowerdir= / media / root-ro,\

[0092] upper= / media / root-rw / overlay,\

[0093] workdir= / media / root-rw / overlay-workdir overlayroot /

[0094] The overlayroot post-mount script is executed after overlayroot is mounted. Specifically, it restores the overlayroot configuration file and shuts down overlayroot. The purpose of shutting down overlayroot at this time is to prevent the system from failing to start after overlayroot is mounted. After overlayroot is mounted, the overlayroot post-mount script is executed. If a startup failure occurs, the user only needs to press the restart button to exit overlayroot, and the system can be restored to the state before the upgrade.

[0095] According to one embodiment of the present invention, the exemplary code of the overlayroot post-mount script is as follows:

[0096] #! / bin / sh

[0097] case "$1" in

[0098] #no pre-reqs

[0099] prereqs)echo "";exit 0;;

[0100] esac

[0101] PATH= / usr / sbin: / usr / bin: / sbin: / bin

[0102] MYTAG="my"

[0103] ROOTMNT=${rootmnt}

[0104] sed-i's:overlayroot=".*":overlayroot="":'${ROOTMNT} / etc / overlayroot.conf

[0105] It should be noted that the overlayroot pre-mount script, overlayroot mount script, and overlayroot post-mount script are all completed in the initrd stage (specifically the init-bottom stage) of system startup, at which the system has not yet completely started. In addition, it is necessary to check whether the system can start normally. If the system cannot start normally, overlayroot can be exited by restarting the system.

[0106] In step S230, software upgrade is performed in the operating system of the computing device. Specifically, the software upgrade data is placed in the upper data layer. The original data of the software is placed in the lower data layer. The software upgrade is performed.

[0107] It should be noted that although the overlayroot post-mount script was executed and overlayroot was closed before the software upgrade, the operating system was not restarted. Therefore, when the software upgrade was performed, it was still in overlayroot mode.

[0108] In step S240, after the software upgrade is completed, the first file copy is copied to the virtual disk device file. The first file copy is used as a storage medium of the upper data layer, and the updated data of the software is stored in the first file copy. The first file copy is copied to the virtual disk device file, that is, the first file copy in the current state replaces the virtual disk device file under the root partition. This ensures that all data generated in the upper data layer during the software upgrade process can be saved to the virtual disk device file.

[0109] In a specific example, the first file copy can be copied to the virtual disk device file through the overlayroot_save() function. The main work of this function is to first perform sync to synchronize the upper data layer to the first file copy, and then copy the data in the first file copy from the tmpfs partition to the virtual disk device file of the root partition. The exemplary code of this function is as follows:

[0110] overlayroot_save(){

[0111] POSTOS=`cat / proc / mounts|awk'{if($2==" / media / root-ro")print$1}'`

[0112] mount-o remount,rw$POSTOS / media / root-ro

[0113] sync

[0114] cp-f / run / overlayroot / overlayroot.img

[0115] ${OVERLAY_LOWDIR} / ${OVERLAYROOT_IMAGE}

[0116] }

[0117] In step S250, the operating system is restarted in the cascade file mode, wherein a second file copy of the virtual disk device file is made and the second file copy is set as a data storage medium of the upper data layer.

[0118] It should be noted that after the software upgrade is completed, the operating system needs to be restarted to make the upgraded software effective. In addition, although the software upgrade data has been saved to the virtual disk device, the upgrade data has not yet been merged with the original data. If it is started in normal mode at this time, the running software is still the version before the upgrade. Therefore, it is necessary to restart the operating system in cascade file mode after the software upgrade is completed.

[0119] It should also be noted that, in this embodiment, when the operating system is started in cascade file mode, the first file copy will be automatically deleted. At this time, the virtual disk device file storing the software upgrade data needs to be copied to make the second file copy.

[0120] In step S260, it is detected whether the software upgrade is successful. The software upgrade can be detected by checking whether the system is running normally. Of course, corresponding testing tools can also be used to detect whether the software upgrade is successful. The present invention does not limit this.

[0121] In step S270, if the software upgrade is successful, the lower data layer is set to be readable and writable, and the data in the lower data layer is modified based on the data in the upper data layer to obtain the operating system version after the software upgrade, and the operating system after the software upgrade is started in normal mode. Since the lower data layer is read-only by default (the purpose is to protect the data in the lower data layer from being changed during the software upgrade), before modifying the data in the lower data layer, the lower data layer needs to be set to be readable and writable.

[0122] It should be noted that in existing software upgrades, the upgrade package data may only include the modified data of the software, that is, only incremental data. It may also include original data and modified data, that is, the software upgrade package is already the upgraded software data. It is easy to understand that although the software upgrade package is already the upgraded software data, the upgrade package may not be able to run in the operating system of the current computing device. Once the operation fails, the software still needs to be rolled back to the original version.

[0123] In some embodiments, if the upgrade data includes original data and modified data of the software, the step of modifying the data in the lower data layer based on the data in the upper data layer to obtain the operating system version after the software upgrade includes:

[0124] Overwrite the data in the lower data layer with the data in the upper data layer to obtain the operating system version after the software upgrade. The so-called overwriting is to replace the original data in the lower data layer with the upgraded data in the upper data layer. Specifically, the original data of the software in the lower data layer can be deleted, and then the upgraded data in the upper data layer can be copied to the lower data layer. When copying, be sure to bring along the software's upgraded data permissions, path and other file attributes. Then turn off the overlayroot mode and start the operating system in normal mode to get the upgraded operating system version.

[0125] In a specific example, the overlayroot mode can be turned off by calling the overlayroot close function. This function is opposite to the overlayroot open function. First, the overlayroot modification is restored, and then the virtual disk file is deleted. The exemplary code of this function is as follows:

[0126] overlayroot_disable(){

[0127] if[[-n"${isInOverlayRoot}"]]; then

[0128] overlayroot-chrootsed-i's:overlayroot=".*":overlayroot="":'${OVERLAYROOT_CONF}

[0129] [-e"${OVERLAYROOT_IMAGE}"]&&overlayroot-chrootrm-f

[0130] ${OVERLAYROOT_IMAGE}

[0131] else

[0132] sed-i's:overlayroot=".*":overlayroot="":'${OVERLAYROOT_CONF}

[0133] [-e"${OVERLAYROOT_IMAGE}"]&&rm-f${OVERLAYROOT_IMAGE}

[0134] fi

[0135] }

[0136] In some embodiments, when the upgrade data is only the modified data of the software (i.e., the incremental data of the software upgrade version data and the version data before the upgrade), the step of modifying the data in the lower data layer based on the data in the upper data layer to obtain the operating system version after the software upgrade includes:

[0137] Merge the data in the upper data layer with the data in the lower data layer to obtain the operating system version after the software upgrade. The so-called merge is to merge the data in the upper data layer into the lower data layer, that is, to merge the software upgrade data (modified data) and the original data together. For example, the merge function overlayroot_merge() can be used to merge the data in the upper data layer into the lower data layer. Among them, there is a character device type file (type c) in the upper layer file. When the user wants to delete a file or directory on the system, and this file or directory comes from the lower layer, since the lower layer is a read-only layer and cannot be modified directly, a character device file with the same name will be created in the upper layer to shield the lower file or directory. Then, from the system level, the effect is equivalent to deleting the file or directory. Therefore, when encountering a character device file, you need to delete the corresponding file or directory with the same name in the lower bottom-level directory. For files other than character device type files, they are created when the system creates files, so the processing of these files only needs to be copied to the lower layer directory at the same level. Similarly, file attributes such as permissions and paths should be brought together when copying. It should also be noted that in order to save disk space, after the data in the upper data layer is merged into the data in the lower data layer, the virtual disk device file can also be deleted.

[0138] According to one embodiment of the present invention, the exemplary code of the merging function overlayroot_merge() is as follows:

[0139] overlayroot_merge(){

[0140] POSTOS=`cat / proc / mounts|awk'{if($2==" / media / root-ro")print$1}'`

[0141] mount-o remount,rw$POSTOS / media / root-ro

[0142] type_list=("c""f""b""l""s")

[0143] for t in${type_list[@]}

[0144] do

[0145] file_list=$(find / media / root-rw / overlay-type${t}|cut-d / -f5-)

[0146] for file in${file_list}

[0147] do

[0148] case${t}in

[0149] "c")

[0150] [-e" / media / root-ro / ${file}"]&&rm-rf / media / root-ro / ${file} ;;

[0152] "f"|"b"|"l"|"s")

[0153] cp-af / media / root-rw / overlay / ${file} / media / root-ro / ${file} ;;

[0155] *)

[0156] echo"invaild file type" ;;

[0158] esac

[0159] done

[0160] done

[0161] update-initramfs-u

[0162] }

[0163] }

[0164] In step S280, if the software upgrade is unsuccessful, the operating system is started in normal mode to roll back to the operating system version before the software upgrade. In order to save disk space, when the software upgrade is unsuccessful, the virtual disk device file can also be deleted.

[0165] In order to better illustrate the complete implementation process of the present invention, the present invention provides a specific example. Figure 4 As shown, Figure 4 FIG. 4 is a schematic diagram showing a flow chart of a method 400 for performing software upgrade using overlayroot according to an embodiment of the present invention. Figure 4 As shown, the software upgrading method 400 of the present invention starts with step S401.

[0166] In step S401, the overlayroot configuration file is modified to enable overlayroot, and a virtual disk device file is created under the root partition. Then, step S402 is executed.

[0167] Among them, the creation of the virtual disk device file and the modification of the overlayroot configuration file can be completed through the overlayroot enable function. The main tasks of this function are: first, use the dd command to create a virtual disk file under the root partition; second, modify the overlayroot configuration file, and change overlayroot=":" to overlayroot="device:dev=" / dev / loop0, recurse="0", indicating that overlayroot is enabled, and the storage medium of the upper layer is the / dev / loop0 device. For the specific process of this step, please refer to the description of the above step S210, which will not be repeated here.

[0168] In step S402, the operating system is restarted. Then, step S403 is executed.

[0169] It should be noted that in step S401, the configuration file is modified to enable overlayroot, and to truly enable overlayroot, the operating system needs to be restarted.

[0170] In step S403, it is determined whether overlayroot is enabled. If overlayroot is not enabled, step S404 is executed; if overlayroot is enabled, step S405 is executed.

[0171] In step S404, overlayroot is exited, that is, overlayroot is not mounted, and the operating system is started in normal mode.

[0172] In step S405, a tmpfs partition and a / run / overlayroot directory are created, the created tmpfs partition is mounted to the / run / overlayroot directory, and the virtual disk device file under the root partition is copied to the / run / overlayroot directory, and the virtual disk device file under the / run / overlayroot directory is set to / dev / loop0 using the losetup tool. Then, step S406 is executed.

[0173] Since the above step S401 has associated the upper layer with / dev / loop0 in the overlayroot configuration file, after the virtual disk device file is set to / dev / loop0, the virtual disk device file becomes the storage medium for the upper layer data. Regarding the creation of the tmpfs partition and the / run / overlayroot directory, the copying of the virtual disk device file, and the setting of / dev / loop0 in this step, please refer to the description of the overlayroot pre-mounting script in the above embodiment, which will not be repeated here.

[0174] In step S406, overlayroot is mounted, and then step S407 is executed.

[0175] When mounting overlayroot, the main thing is to change the mount point of the root partition to the / media / root_ro directory, then mount the upper storage device ( / dev / loop0) specified in the overlayroot configuration file to the / media / root_rw directory, and finally mount overlayroot. Specifically, please refer to the description of the overlayroot mount script in the above embodiment, which will not be repeated here.

[0176] In step S407, the configuration file of overlayroot is modified to close overlayroot. Then, step S408 is executed.

[0177] Among them, the purpose of closing overlayroot is to prevent startup failure when starting the system after mounting overlayroot. After modifying the overlayroot configuration file to close overlayroot, if a startup failure occurs, the user only needs to press the restart button to exit overlayroot, so that the system can be restored to the state before the upgrade. Specifically, please refer to the description of the overlayroot post-mounting script in the above embodiment, which will not be repeated here. In addition, it should be noted that steps 405 to 407 are all completed in the initrd stage (specifically the init-bottom stage) of system startup.

[0178] In step S408, it is detected whether the system can be started normally. If yes, step S409 is executed, if not, the system returns to step S402 (because the overlayroot configuration file has been modified in step S407 to close overlayroot, when returning to step S402 to restart the operating system, it will be determined that overlayroot is not turned on when executing step S403, and then the system will enter step S404, exit overlayroot, and start the operating system in normal mode).

[0179] In step S409, it is determined whether the software has been upgraded. If not (it means that the software has not been upgraded yet, that is, it is the first time to upgrade the software), step S410 is executed. If yes, step S411 is executed.

[0180] In step S410, software upgrade is performed. Subsequently, step S412 is performed.

[0181] In step S411, it is detected whether the software is upgraded successfully. If yes, step S413 is executed. If no, step S414 is executed.

[0182] In step S412, the virtual disk device file is copied from the / tmpfs partition back to the root partition, and the overlayroot configuration file is modified to enable overlayroot. Then, the process returns to step S402.

[0183] Copy the virtual disk device file from the / tmpfs partition back to the root partition, that is, overwrite the original virtual device file of the lower layer root partition with the virtual device file in the / run / overlayroot / directory to save the upper layer data of overlayroot. In order for the upgraded software to take effect, the operating system needs to be restarted. Therefore, after saving the upper layer data of overlayroot, it is necessary to return to step S402. Since the overlayroot configuration file has been modified to close overlayroot in step S407, in order to ensure that overlayroot is still turned on after restarting the operating system, the overlayroot configuration file needs to be modified again to turn on overlayroot.

[0184] In step S413, the upper layer data is merged into the lower layer. Then, step S414 is executed.

[0185] Among them, the specific process of merging the upper layer data into the lower layer can be found in the description of step S270 in the above embodiment, and will not be repeated here.

[0186] In step S414, the virtual disk device file under the root partition is deleted, and the process returns to step S402.

[0187] Among them, if this step is entered directly from step S411, it means that the software upgrade is not successful. At this time, after returning to step S402 to restart the operating system, overlayroot will be automatically exited and roll back to the operating system version before the upgrade. If this step is entered from step S413, it means that the software has been upgraded successfully and the upper layer data has been merged to the lower layer. At this time, after returning to step S402 to restart the operating system, overlayroot will be automatically exited and it will still be the upgraded operating system. In addition, deleting the virtual disk device file under the root partition is only for cleaning up the operating system's disk. Even if the virtual disk device file is not deleted, it will have no effect on the software upgrade or rollback. In other words, when the software is not upgraded successfully, you can directly return to step S402 to roll back to the operating system version before the upgrade; after merging the upper layer data to the lower layer, you can also directly return to step S402 to start the operating system version after the software upgrade.

[0188] According to the software upgrade method of the present invention, a virtual disk device file is created, and after the software is upgraded, the upgraded version data is stored in the virtual disk device file, so that the software upgraded version data can be saved. In this way, when the software is successfully upgraded, the upgraded software version can be obtained by modifying the data in the lower data layer based on the upgraded version data saved above, and persistent storage can be achieved. When the software upgrade fails, the operating system is started in normal mode to achieve software rollback. It can be seen that the software upgrade method of the present invention can flexibly permanently save or delete the upgraded version data when upgrading the software, so that the software upgrade or rollback can be flexibly achieved, which improves the user experience.

[0189] Compared with the installation of the specified version, the solution of the present invention performs all modifications on the upper data layer, and the rollback after the upgrade fails is very thorough and safe. In addition, the solution does not need to allocate a separate disk to install the backup system, and can only save the difference data, while the A / B system not only needs to allocate a separate disk to install the backup system, but also needs to synchronize all the data on the two disks at the end regardless of the amount of upgrade and modification content, which is very resource-consuming. Therefore, compared with the A / B system, the solution consumes very little resources.

[0190] The various techniques described herein may be implemented in combination with hardware or software, or a combination thereof. Thus, the method and apparatus of the present invention, or some aspects or parts of the method and apparatus of the present invention may be in the form of program codes (i.e., instructions) embedded in a tangible medium, such as a removable hard disk, a USB flash drive, a floppy disk, a CD-ROM, or any other machine-readable storage medium, wherein when the program is loaded into a machine such as a computer and executed by the machine, the machine becomes a device for practicing the present invention.

[0191] In the case where the program code is executed on a programmable computer, the computing device generally includes a processor, a storage medium readable by the processor (including volatile and non-volatile memory and / or storage elements), at least one input device, and at least one output device. The memory is configured to store the program code; the processor is configured to execute the software upgrade method of the present invention according to the instructions in the program code stored in the memory.

[0192] By way of example and not limitation, readable media include readable storage media and communication media. Readable storage media stores information such as computer readable instructions, data structures, program modules or other data. Communication media generally embody computer readable instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transmission mechanism, and include any information transfer medium. Any combination of the above is also included within the scope of readable media.

[0193] In the description provided herein, algorithms and displays are not inherently related to any particular computer, virtual system or other device. Various general purpose systems can also be used together with the examples of the present invention. According to the above description, it is obvious that the structure required for constructing such systems. In addition, the present invention is not directed to any specific programming language either. It should be understood that various programming languages ​​can be utilized to implement the content of the present invention described herein, and the above description of specific languages ​​is for the purpose of disclosing the best mode of the present invention.

[0194] In the description provided herein, a large number of specific details are described. However, it is understood that embodiments of the present invention can be practiced without these specific details. In some instances, well-known methods, structures and techniques are not shown in detail so as not to obscure the understanding of this description.

[0195] It should be understood that in order to streamline the present disclosure and aid in understanding one or more of the various inventive aspects, in the above description of exemplary embodiments of the present invention, various features of the present invention are sometimes grouped together into a single embodiment, figure, or description thereof. However, this method of disclosure should not be interpreted as reflecting an intention that the claimed invention requires more features than are expressly recited in each claim.

[0196] Those skilled in the art will appreciate that the modules or units or components of the devices in the examples disclosed herein may be arranged in the devices described in the embodiment, or alternatively may be located in one or more devices different from the devices in the examples. The modules in the foregoing examples may be combined into one module or may be divided into multiple submodules.

[0197] Those skilled in the art will appreciate that the modules in the devices in the embodiments may be adaptively changed and arranged in one or more devices different from the embodiments. The modules or units or components in the embodiments may be combined into one module or unit or component, and in addition they may be divided into a plurality of submodules or subunits or subcomponents. Except that at least some of such features and / or processes or units are mutually exclusive, all features disclosed in this specification (including the accompanying claims, abstracts and drawings) and all processes or units of any method or device disclosed in this manner may be combined in any combination. Unless otherwise expressly stated, each feature disclosed in this specification (including the accompanying claims, abstracts and drawings) may be replaced by an alternative feature providing the same, equivalent or similar purpose.

[0198] Furthermore, those skilled in the art will appreciate that although some embodiments described herein include certain features included in other embodiments but not other features, the combination of features from different embodiments is meant to be within the scope of the present invention and to form different embodiments.

[0199] In addition, some of the embodiments are described herein as methods or combinations of method elements that can be implemented by a processor of a computer system or by other devices that perform the functions. Therefore, a processor with necessary instructions for implementing the method or method elements forms a device for implementing the method or method elements. In addition, the elements described herein of the device embodiments are examples of devices for implementing the functions performed by the elements for the purpose of implementing the invention.

[0200] As used herein, unless otherwise specified, the use of ordinal numbers "first," "second," "third," etc. to describe common objects merely indicates that different instances of similar objects are involved, and is not intended to imply that the objects so described must have a given order in time, space, order, or in any other manner.

[0201] Although the present invention has been described according to a limited number of embodiments, it will be apparent to those skilled in the art, with the benefit of the above description, that other embodiments may be envisioned within the scope of the invention thus described. In addition, it should be noted that the language used in this specification is selected primarily for readability and teaching purposes, rather than for explaining or defining the subject matter of the present invention. Therefore, many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the appended claims. The disclosure of the present invention is illustrative, not restrictive, with respect to the scope of the present invention, which is defined by the appended claims.

Claims

1. A software upgrade method, suitable for execution in a computing device having an operating system resident thereon, the method comprising: Create a virtual disk device file; Starting the operating system in a cascade file mode, wherein in the cascade file mode, a lower data layer in which data is read-only and an upper data layer in which data is readable and writable are constructed in the operating system, a first file copy of the virtual disk device file is made, and the first file copy is set as a data storage medium of the upper data layer; performing a software upgrade in an operating system of the computing device; After the software upgrade is completed, copying the first file copy to the virtual disk device file; Restarting the operating system in the cascade file mode, wherein a second file copy of the virtual disk device file is made, and the second file copy is set as a data storage medium of the upper data layer; Detecting whether the software upgrade is successful; If the software upgrade is successful, the lower data layer is set to be readable and writable, and the data in the lower data layer is modified based on the data in the upper data layer to obtain the operating system version after the software upgrade, and the operating system after the software upgrade is started in normal mode; If the software upgrade is unsuccessful, the operating system is started in a normal mode to roll back to the operating system version before the software upgrade.

2. The method of claim 1, wherein: The steps of creating a virtual disk device file include: A virtual disk device file having the same format as that of the root partition is created under the root partition of the operating system.

3. The method according to claim 1 or 2, wherein: The steps of constructing a lower data layer in which data is read-only and an upper data layer in which data is readable and writable in the operating system include: Using the directory mounted by the root partition of the operating system as the lower data layer; A temporary file system partition is created, and the temporary file system partition is mounted to an associated directory of a temporary file system directory of the operating system, so as to use the temporary file system partition as the upper data layer.

4. The method of claim 3, wherein: The steps of making a first file copy of the virtual disk device file and setting the first file copy as the data storage medium of the upper data layer include: Copying the virtual disk device file to generate the first file copy; The first file copy is copied to the associated directory, so that the first file copy serves as a data storage medium of the upper data layer.

5. The method of claim 3, wherein: The associated directory is the temporary file system directory or a subdirectory of the temporary file system directory.

6. The method according to claim 1 or 2, wherein: The steps of performing software upgrade in the operating system of the computing device include: Placing the upgrade data of the software into the upper data layer; Placing the original data of the software into the lower data layer; Perform a software upgrade.

7. The method of claim 6, wherein: The upgrade data includes the original data and modified data of the software, and The step of modifying the data in the lower data layer based on the data in the upper data layer to obtain the operating system version after the software upgrade comprises: The data in the upper data layer is overwritten with the data in the lower data layer to obtain the operating system version after the software upgrade.

8. The method of claim 6, wherein: The upgrade data is the modification data of the software, and The step of modifying the data in the lower data layer based on the data in the upper data layer to obtain the operating system version after the software upgrade comprises: The data in the upper data layer is merged into the lower data layer to obtain the operating system version after the software upgrade.

9. The method according to claim 1 or 2, wherein: The overlay file mode is the overlayroot mode.

10. A computing device comprising: at least one processor; as well as A memory storing program instructions, wherein the program instructions are configured to be executed by the at least one processor, and the program instructions include instructions for executing the method according to any one of claims 1 to 9.

11. A readable storage medium storing program instructions, when the program instructions are read and executed by a computing device, the computing device executes the method according to any one of claims 1 to 9.