CN-116028411-B - Method for supporting LINUX kernel operating system to hot plug system disk
Abstract
The invention discloses a method for supporting hot plug of LINUX kernel operating system to system disk, a, checking consistency of movable storage equipment and system disk, b, if the unloaded movable storage equipment is consistent with the system disk, not releasing super block, suspending all running threads of kernel, waiting for equipment insertion, c, after the movable storage equipment is inserted, identifying equipment id of the mount equipment when mounting is completed and automatic mount is started, and comparing with the system disk id, d, if the id of the mount equipment is consistent with the id of the system disk, mapping the equipment onto the super block of the original system disk, activating all threads in kernel after completion of write-back synchronization of data, completing system recovery, after hot plug of the system disk, reinserting the pulled system disk can ensure that the system can continue normal use without restarting, and meanwhile, data of the system disk and data of other mounted disk can not be damaged and lost.
Inventors
- SHENG HONG
- Yan Bingan
- DU YI
- YAN JINGCHUN
Assignees
- 正数网络技术有限公司
Dates
- Publication Date
- 20260508
- Application Date
- 20221219
Claims (5)
- 1. A method for supporting hot plug of LINUX kernel operating system to system disk is characterized by comprising the following steps: a. checking consistency of the removable storage device and the system disk, and matching whether the unloading device is consistent with the system disk or not when the removable storage device is unloaded; b. if the unloaded movable storage equipment is consistent with the system disk, the super block is not released, all running threads of the kernel are suspended, equipment is waited for being inserted, and if the unloaded movable storage equipment is inconsistent with the system disk, the equipment is processed according to a normal flow; c. After the removable storage device is inserted, identifying the device id of the mount device when the mount is completed and automatic mount begins, and comparing with the system disk id; d. If the id of the mount device is consistent with the id of the system disk, mapping the mount device onto a super block of the original system disk, and activating all threads in a kernel after the write-back synchronization of data is completed to complete system recovery; When the system is started, an init thread is started, and reads/etc/fstab files, and after finishing the mounting of/etc/fstab files, re-reads/etc/fstab files, finds the uuid or label value corresponding to the root directory, polls the super block linked list, finds the super block matched with the uuid or label value, and records the object pointer, uuid or label value of the super block in a global variable object; In the kernel umount function, the id comparison is carried out on equipment to be unloaded, the kernel is prevented from unloading the system disk and releasing the super block, and simultaneously, the kernel thread is suspended, so that the data is ensured not to be written into the system disk, and a large number of I/O read-write errors are prevented.
- 2. The method for supporting hot plug of LINUX kernel operating system to system disk according to claim 1, wherein nameidate values are obtained through name, uuid values or label values of the device are obtained through nameidate values, and the uuid values are compared with the system disk id values in the global variable table.
- 3. The method for supporting hot plug of LINUX kernel operating system to system disk according to claim 1, wherein in kernel do_mount function, id number comparison is performed on the device to be mounted, if the device is reinserted, the mapping relationship between super block and device is directly restored, and simultaneously, one-time data write-back is completed, data loss is prevented, then all suspended kernel threads are started, and the running state of the system is restored.
- 4. A method for supporting hot plug of LINUX kernel operating system to system disk according to claim 3, wherein in kernel do_mount function, path value is obtained through dir_name, after nameidate is obtained through the value, uuid or label value of the device is obtained through nameidate value, and path value is compared with system disk id value in global variable table.
- 5. The method for supporting hot plug of LINUX kernel operating system to system disk according to claim 3, wherein the freeze parameter in the global variable table is set to 0 while the system operation state is restored.
Description
Method for supporting LINUX kernel operating system to hot plug system disk Technical Field The invention belongs to the technical field of operating system use, and particularly relates to a method for supporting hot plug of a LINUX kernel operating system to a system disk. Background Desktop systems with Linux as a kernel are increasingly popular with users. The removable storage device is used as a system disk to install an operating system, so that a user can conveniently and portably use a custom system or a security system, and the use scene of the custom system or the security system is also transited from a windows system to a Linux system by the user. In actual use, the Windows 10 operating system can be used for thermally unloading the system disk, the system is blocked after unloading, and the Windows system can be recovered to be normal after reinserting the system disk, so that the data cannot be lost. However, in the operating system using Linux as the kernel, the system is completely crashed, the system disk data is destroyed, and even if the system is restarted, the system cannot be started successfully. The operating system taking Linux as the kernel cannot be used for hot plug of the system disk, so that the system disk cannot be safely, stably and conveniently operated under the use scene taking the movable storage equipment as the system disk. Disclosure of Invention Aiming at the defects of the prior art, the invention aims to provide a method for supporting the hot plug of the LINUX kernel operating system to the system disk, after the hot plug of the system disk is carried out, the system disk which is plugged in and pulled out again can ensure that the system can continue to be used normally without restarting, and meanwhile, the data of the system disk and the data of other mounted disks cannot be damaged and lost. The invention provides the following technical scheme: A method for supporting LINUX kernel operation system to hot plug system disk includes the following steps: a. checking consistency of the removable storage device and the system disk, and matching whether the unloading device is consistent with the system disk or not when the removable storage device is unloaded; b. if the unloaded movable storage equipment is consistent with the system disk, the super block is not released, all running threads of the kernel are suspended, equipment is waited for being inserted, and if the unloaded movable storage equipment is inconsistent with the system disk, the equipment is processed according to a normal flow; c. After the removable storage device is inserted, identifying the device id of the mount device when the mount is completed and automatic mount begins, and comparing with the system disk id; d. If the id of the mount device is consistent with the id of the system disk, mapping the device onto a super block of the original system disk, activating all threads in the kernel after the write-back synchronization of the data is completed, and completing the system recovery, and if the id of the mount device is inconsistent with the id of the system disk, processing according to the normal flow. Preferably, when the system is started, the init thread is started, and reads/etc/fstab files, and after the mounting is completed, re-reads/etc/fstab files, finds the uuid or label value corresponding to the root directory, polls the superblock linked list, finds the superblock matched with the uuid or label value, and records the superblock object pointer, uuid or label value in a global variable object. Preferably, in the kernel count function, id comparison is performed on equipment to be unloaded, so that the kernel is prevented from unloading a system disk and releasing a super block, and simultaneously, a kernel thread is suspended, so that data is prevented from being written into the system disk, and a large number of I/O read-write errors are prevented. Preferably, the nameidate value is obtained by name, and the uuid value or label value of the device is obtained by nameidate value, and the value is compared with the system disk id value in the global variable table. Preferably, in the kernel do_mount function, id number comparison is performed on the device to be mounted, if the device is reinserted by the system disk, the mapping relationship between the super block and the device is directly restored, and meanwhile, one-time data write-back is completed, so that data loss is prevented, and then all suspended kernel threads are started to restore the running state of the system. Preferably, in the kernel do_mount function, the path value is obtained through dir_name, after nameidate is obtained through the path value, the uuid or label value of the device is obtained through nameidate value, and the value is compared with the system disk id value in the global variable table. Preferably, the freezing parameter in the global variable table is set to 0 while the system operati