Summary of the invention
The invention provides a kind of method and device of erasing disk, can in the process performing magnetic disk erasing, available protecting disk partition information, and then the data security of protection user.
The invention provides following scheme:
A method for erasing disk, comprising:
When needs perform erase operation to disk current bay, obtain the partition information of disk current bay and its next subregion;
According to described partition information, judge whether there is a point area overlapping between current bay and its next subregion;
According to judged result, determine the erase operation for disk current bay.
Wherein, the partition information of described acquisition disk current bay and its next subregion comprises:
Obtain the physical sector number of the end sector at place, current bay, and the physical sector number of the initial sector at next subregion place;
Described according to described partition information, judge that whether there is a point area overlapping between current bay and its next subregion comprises:
Judge whether the physical sector number of the end sector at place, current bay is greater than the physical sector number of the initial sector at its next subregion place, if so, then there is a point area overlapping between current bay and its next subregion.
Wherein, described according to judged result, determine that the erase operation for disk current bay comprises:
If there is a point area overlapping between current bay and next subregion, then determine the overlapping region between current bay and next subregion;
When performing erase operation to current bay, skipping described overlapping region, only wiping the region in current bay except described overlapping region.
Wherein, described according to judged result, determine that the erase operation for disk current bay comprises:
If there is a point area overlapping between current bay and next subregion, skip current bay, only erase operation is carried out to other subregions except current bay.
Wherein, the described erase operation to disk current bay comprises:
When needs carry out erase operation to disk current bay, by writing random number in erase area, carry out erasing disk.
A device for erasing disk, comprising:
Partition information acquiring unit, for when needs perform erase operation to disk current bay, obtains the partition information of disk current bay and its next subregion;
Judging unit, for according to described partition information, judges whether there is a point area overlapping between current bay and its next subregion;
Erase unit, for according to judged result, determines the erase operation for disk current bay.
Wherein, described partition information acquiring unit is used for:
Obtain the physical sector number of the end sector at place, current bay, and the physical sector number of the initial sector at next subregion place;
Described judging unit specifically for:
Judge whether the physical sector number of the end sector at place, current bay is greater than the physical sector number of the initial sector at its next subregion place, if so, then there is a point area overlapping between current bay and its next subregion.
Wherein, described erase unit comprises:
Subelement is determined in overlapping region, when dividing area overlapping for existing between current bay and next subregion, determines the overlapping region between current bay and next subregion;
First deletes subelement, for when performing erase operation to current bay, skips described overlapping region, only wipes the region in current bay except described overlapping region.
Wherein, described erase unit comprises:
Second deletes subelement, when dividing area overlapping for existing between current bay and next subregion, skipping current bay, only carrying out erase operation to other subregions except current bay.
Wherein, described erase unit specifically for:
When needs carry out erase operation to disk current bay, by writing random number in erase area, carry out erasing disk.
According to specific embodiment provided by the invention, the invention discloses following technique effect:
By the present invention, before performing concrete magnetic disk erasing operation, first can judge the phenomenon that whether there is point area overlapping between disk partition, and according to judged result, determine the erase operation for disk current bay.Therefore, in the process of erasing disk, can available protecting disk partition information, and then protect the data security of user.
Embodiment
Below in conjunction with the accompanying drawing in the embodiment of the present invention, be clearly and completely described the technical scheme in the embodiment of the present invention, obviously, described embodiment is only the present invention's part embodiment, instead of whole embodiments.Based on the embodiment in the present invention, the every other embodiment that those of ordinary skill in the art obtain, all belongs to the scope of protection of the invention.
First it should be noted that, the main memory device depositing information in computing machine is hard disk, but hard disk can not directly use, and must split hard disk, and the hard disk areas of a piece a piece that is divided into, this disk areas is just called disk partition.In traditional disk management, a hard disk is divided into two large class subregions: main partition and extended partition.Main partition is can installing operating system, can carry out the subregion of computer starting.Main partition is independently, and be also first subregion of hard disk, the C dish seen in practical application is exactly main partition usually.4 main partitions can only be there are at most in a hard disk.If a hard disk needs the disk piecemeal more than more than 4, so just need to use extended partition.If use extended partition, so at most can only 3 main partitions and 1 extended partition on a physical hard disk.Extended partition can not directly use, it has to pass through the logical partition (such as D dish, E dish, F dish etc.) be partitioned into for the second time one by one, then just can use, also be, file can be stored in certain logical partition, when this file checked by needs, search under the drive that this logical partition of arriving is corresponding.
Wherein, in 0 sector 0 magnetic track of disk, there is partition table, in this partition table, marked the start address in each main partition, end address, and the partition information such as the start address of extended partition.The original position in each main partition is preserved DBR(and is generally taken 63 sectors, certainly also may be other numbers), and MFT(Master File Table, MFT) or FAT(File Allocation Table, file configuration table) file table etc., if these data are destroyed, corresponding main partition can be caused to open.
In addition, each logical partition of extended partition (generally comprises partition table and MFT etc. by partition information section, the total sector number of this part disk taken normally is fixed, such as in certain system, take 63 sectors altogether) and data segment two parts composition, wherein, partition table is usually located at the reference position of each logical partition, and for the partition information of the partition information and next subregion of preserving current logic subregion, data segment is for preserving concrete data.The wherein start address of first logical partition and the start address of extended partition, other follow-up partition informations, can take number and push away in the sector of address and each subregion thus.Logical partition is that chain sheet form is kept in disk, if hard disk lost partition table, data just cannot read in order and write, and cause operating.
And the present inventor is realizing finding in process of the present invention, why when using magnetic disk erasing device to wipe the data in disk, there will be the phenomenon that subregion is lost, between the subregion that a kind of possible reason is just disk, there is the phenomenon of point area overlapping.So-called point area overlapping refers to the partition table of a certain logical partition (being such as B subregion), is written in the data segment of earlier logic subregion (being such as A subregion), now, once A partition data is fully written, then the partition table of B subregion will inevitably be given and cover.As mentioned before, because logical partition is that chain sheet form is kept in disk, when subregion is lost above, subregion below will all be lost, and therefore, the phenomenon of this point of area overlapping can cause the loss of logical partition, and then causes the loss of user data.Especially now the volume of game and audio/video file etc. is increasing, and a disk partition is often fully written, and like this, once there is a point area overlapping, then the situation that subregion is lost will get more and more.Such as, the partition table of first logical partition to be kept at before it in main partition (namely the reference position of first logical partition is less than the end position in last main partition), such subregion will be overlapping, when last main partition is write completely, the partition table of first logical partition will be capped, and such first logical partition will be lost.And have recorded the start information of second logical partition in the partition table of first logical partition, therefore, after first logical partition is lost, second logical partition is also lost thereupon, by that analogy, as long as first logical partition is lost, logical partition below will all be lost.
As for the reason causing point area overlapping, wherein one may be: after computer uses a period of time, and systems grow is slow, now keeps away system of unavoidably will resetting, and is limited to the complicacy of computer refitting and consuming time, and it is more and more universal that GHOST does system.So-called GHOST, be actually a kind of hard disk backup reduction instrument, it takes the mode backup-and-restore data of mirror image system partitioning or file.But, due to present online various forms of GHOST software and system image file, much lack of standardization, bring risk to custom system.Wherein risk is exactly the problem causing point area overlapping, also, there is conflict, thus cause a point area overlapping between the partition information that GHOST carries and the partition information of original subscriber.In addition, some are the use of the subregion software of BUG, also may cause the overlap of subregion.
On above analysis foundation, embodiments provide a kind of method of erasing disk, see Fig. 1, the method comprises the following steps:
S101: when needs perform erase operation to disk current bay, obtain the partition information of disk current bay and its next subregion;
S102: according to described partition information, judges whether there is a point area overlapping between current bay and its next subregion;
In actual applications, operation can be manually booted according to user, determine whether to need to go to perform erase operation to disk.Such as, when user needs to perform erase operation to certain disk partition, just can start magnetic disk erasing instrument, and indicate it to perform erase operation to this disk partition of specifying, now, just be equivalent to needs and erase operation is performed to this subregion.Certainly, user also can select to wipe multiple subregion, certainly, when specific implementation, when user selects multiple subregion to carry out erase operation, also can be broken down into the subtask of the erase operations to single disk partition.Therefore, needing described in this step performs erase operation to disk current bay and includes: user selects single disk partition, sends erasing instruction; Or user selects multiple subregion to send erasing instruction, be decomposed into multiple subtasks of single disk partition being carried out to erase operation thus.
It should be noted that, after the technology of disk application extended partition, when subregion is determined, the number of sectors saving each main partition of this physical disk and the address of extended partition and take in the partition table of its 0 magnetic track 0 sector of physical disk, therefore, by reading the information of physical disk 0 magnetic track 0 sector, the address in main partition and the start address of extended partition can be got.Therefore, when needing the partition information obtaining main partition and extended partition, just can obtain from the partition table of disk 0 magnetic track 0 sector.
Simultaneously, the start address of extended partition is just equivalent to the start address of first logical partition, and the partition table of first logical partition is just kept in the initial sector of first logical partition, therefore, just can obtain the partition table of first logical partition, and the partition information got wherein, the start address of other follow-up each logical partitions, the sector of each subregion that can record in the start address of this first logical partition and partition table thereof takies the parameters such as number and pushes away.Here it should be noted that, as mentioned before, it is the partition information not only describing current bay in partition table due to each logical partition, also describe the partition information of next subregion, therefore, understanding conveniently, when needing the partition information obtaining disk logical partition, both can obtain from the partition table of this subregion self, can obtain from the partition table of a upper subregion again (certainly, except first logical partition).
But, in the logical partition of extended partition, have EBR(Extended Boot Record in the sector, starting position of each logical partition).EBR with MBR is different, and it does not have guidance code, but saves two partition tables: first partition table is that current bay is removed this subregion DBR(DBR and generally taken 63 sectors, also have 2048 or other values) outside the initial sector of data field and the sector number that takies; Second partition table is the initial sector number of next subregion and the sector number (comprising DBR and data field) taken.
Two partition tables (if having more than three logical partitions) are comprised again: first the partition table initial sector that have recorded data field except this subregion DBR and the sector number taken, the initial sector that have recorded the 3rd extended partition in second partition table and the sector number taken in the reference position of next subregion.
The like, the partition table in logical partition is preserved with chain sheet form.The start address of logical partition is actual can be obtained in the partition table of a logical partition from it.
Such as, the initial sector of this extended partition, place, logical partition is got in the initial sector of first logical partition A, and its end position adds the sector number shared by it for initial sector.The start address of second subregion list item record and the sector number that takies in partition table in the start address fetch logic subregion A of second logical partition B.Certain logical partition Y below takies the basis for estimation of sector: be as the criterion with the initial sector of second subregion list item record in the partition table in logical partition X above and the sector number taken.
The sector number adding shared by it when the position, initial sector of a certain logical partition A is greater than logical partition B(A and B after it in same extended partition) the position at place, initial sector, a point area overlapping will be caused.
Such as: initial sector, A logical partition is 1000 sectors, it takies 2000 sectors, and initial sector, B logical partition, in 2920 sectors, takies 1000 sectors.Terminating sector in such A logical partition should be 3000 sectors, and B initial sector, logical partition is 2920, and the end sector of A is greater than B and starts sector, and they have the overlap of 80 sectors.The partition table of B subregion, DBR and some other data (MFT may be had in NTFS, in FAT form, FAT table may be had) may be record in these 80 sectors.When A logical partition is write completely, data will be write in these 80 sectors, then, partition table in B subregion, DBR and other data will be destroyed, cause B subregion and subregion below thereof all to be lost, thus cause the data on these subregions all to lose, cause damage with user.
Therefore, specifically when obtaining the partition information of disk current bay and its next subregion, the physical sector number of the end sector at place, current bay can be obtained, and the physical sector number of the initial sector at next subregion place; Like this, just whether can be greater than the physical sector number of the initial sector at its next subregion place by the physical sector number of the end sector judging place, current bay, if so, then there is a point area overlapping between current bay and its next subregion.
Concrete, if when current bay and next subregion thereof are the logical partition in extended partition, the partition information of described acquisition disk current bay and its next subregion comprises: the partition information obtaining the first logical partition and the second logical partition in the following manner: the partition information marked in the partition table according to a upper subregion of described first logical partition, determines the physical sector number at the end position place of described first logical partition; The partition information marked in partition table according to described first logical partition, determines the physical sector number at the reference position place of described second logical partition; Then, judge whether the physical sector number at the end position place of described first logical partition is greater than the physical sector number at the reference position place of described second logical partition, if so, then there is a point area overlapping between described first logical partition and described second logical partition.
Wherein, the partition information recorded in partition table according to a upper subregion of the first logical partition, when determining the physical sector number at the end position place of described first logical partition, be specifically as follows: the partition table inquiring about a upper subregion of described first logical partition, the initial sector off-set value therefrom obtaining the first logical partition and the total sector number taken; According to total sector number that initial sector off-set value and this logical partition of this first logical partition take, obtain the end sector offset value of this first logic sector; The physical sector number at the end position place at this place, the first logical partition is obtained according to the end sector offset value of this first logic sector and the start address of extended partition.
The partition information recorded in partition table according to described first logical partition, when determining the physical sector number at reference position place of the second logical partition, be specifically as follows: the partition table inquiring about described first logical partition, therefrom obtain the initial sector off-set value of described second logical partition; The physical sector number at the reference position place of this second logical partition is obtained according to the initial sector off-set value of this second logic sector and the start address of extended partition.
If current bay is main partition, its next subregion be main partition or extended partition time, then specifically when obtaining the partition information of disk current bay and its next subregion, it can be the partition information according to marking in the partition table in disk 0 magnetic track 0 sector, determine the physical sector number at the end position place of described current bay, and the physical sector number at the reference position place of next subregion; And then, whether be greater than the physical sector number at the reference position place of next subregion by the physical sector number at the end position place judging current bay, if so, then there is a point area overlapping between current bay and next subregion.
It should be noted that, during specific implementation, except utilizing the sector number of initial sector and terminating, except reference position that the sector number of sector carrys out presentation logic subregion and end position, other information can also be utilized to represent, such as, start byte, end byte etc.Or, because " side-play amount " recorded in partition table is all the start addresses relative to extended partition, therefore.Calculate initial sector if disregarded and terminate the physical sector number of sector, but between " side-play amount " that utilize initial sector and terminate sector come between decision logic sector, whether to there is a point area overlapping and be also fine, repeat no more here.
It should be noted that in addition, in the art, the logical partition under DOS partition scheme is the one of disk partition, and other disk partition type respectively has its relevant information acquisition methods, does not repeat them here.
S103: according to judged result, determines the erase operation for disk current bay.
During specific implementation, if judge the phenomenon that there is point area overlapping between subregion, specifically can there is multiple implementation when performing the erase operation to disk partition.Such as, wherein under a kind of implementation, as long as can be there is a point area overlapping between certain subregion A and subregion B, and subregion A be a upper subregion of subregion B, then direct being skipped by subregion A is not wiped, and only performs erase operation to the subregion that there is not point area overlapping between other and next subregion.
Or, under another kind of implementation, if there is a point area overlapping between certain subregion A and its next subregion B, also erase operation can also be performed to subregion A, just need to skip do not wipe there occurs overlapping part with subregion B, after erasing can be avoided, cause the loss of subregion B.In this manner, during specific implementation, first can determine that namely the overlapping region between current bay with next subregion (also determines two subregions specifically exist on which sector overlapping, such as, overlapping region in previous example between subregion A and subregion B is exactly the 97th to the 99th sector), then when performing erase operation to current bay, skipping this overlapping region, only wiping the region in current bay except this overlapping region.
Here it should be noted that, effect due to magnetic disk erasing instrument is exactly prevent deleted data in disk to be resumed, therefore, in traditional magnetic disk erasing device, when giving tacit consent to, all refer to the remaining space (data field that is except the data field at existing file place, the data field that especially deleted document is corresponding) of erasing.So in embodiments of the present invention, so-called " region in current bay beyond overlapping region " just refers to the remaining space of current bay, the region except overlapping region.Certainly, in actual applications, if user needs totally to wipe disk, also be, data field together with existing non-deleted file place is deleted, also be fine, in this case, " region in current bay beyond overlapping region " in the embodiment of the present invention just can refer to the region in whole current bay except overlapping region.
When carrying out concrete erase operation, can by will the region of erasing be needed once or repeatedly to write random number, all set to 0 or the mode such as 1 of putting realizes.Wherein, if wipe together with existing file, then when wiping existing file or file, first can make carbon copies file with random data by certain number of times, again data field being reset as required.Then random file or folder to be renamed certain number of times, from MFT or FAT file table, do not find source document by raw filename like this, then change file size into 0.And then MFT or FAT file table file index information is reset, file is destroyed in the characteristic of MFT or FAT file table, adds the difficulty of recovery.Finally delete this file again, thus ensure the personal secrets of user.If the remaining space of erasing disk, the data of stochastic generation just directly can be used in disk, according to the number of times that user selects, write temporary file, until write the full region needing erasing, needing the region of erasing all to cover, and then delete these temporary files.Like this, the data of the file deleted, will all be made carbon copies, and can not be resumed again.
Wherein, FAT form because the file of maximum support 4GB size, so the area size of wiping as required, may generate multiple temporary file during erasing.Such as: suppose that the region needing erasing is 10GB, then may generate 3 files: the file of the file of two 4GB and a 2GB.And for NTFS form, because support large files, the maximum 64GB that supports, the temporary file quantity therefore write can be lacked relatively.
In addition, the method for the erasing disk described in the embodiment of the present invention, both for the erase operation that user selects single disk partition to carry out, had also been applicable to the bulk erasure operation that user selects multiple disk partition to carry out.Why like this; because when user selects multiple disk partition to carry out the operation of bulk erasure; no matter be that order performs single magnetic disk erasing; or perform the erasing of multiple disk; all can be broken down into the subtask of the erase operations to single disk partition; therefore, above-mentioned situation all belongs to protection scope of the present invention.
Corresponding with the magnetic disk erasing method that the embodiment of the present invention provides, the embodiment of the present invention additionally provides a kind of device of erasing disk, and see Fig. 2, this device can comprise:
Partition information acquiring unit 201, for when needs perform erase operation to disk current bay, obtains the partition information of disk current bay and its next subregion;
Judging unit 202, for according to described partition information, judges whether there is a point area overlapping between current bay and its next subregion;
Erase unit 203, for according to judged result, determines the erase operation for disk current bay.
During specific implementation, partition information acquiring unit specifically for:
Obtain the physical sector number of the end sector at place, current bay, and the physical sector number of the initial sector at next subregion place;
Described judging unit specifically for:
Judge whether the physical sector number of the end sector at place, current bay is greater than the physical sector number of the initial sector at its next subregion place, if so, then there is a point area overlapping between current bay and its next subregion.
If there is a point area overlapping between current bay and next subregion, then, under a kind of implementation, erase unit 203 can comprise:
Subelement is determined in overlapping region, when dividing area overlapping for existing between current bay and next subregion, determines the overlapping region between current bay and next subregion;
First deletes subelement, for when performing erase operation to current bay, skips described overlapping region, only wipes the region in current bay except described overlapping region.
Or under another kind of implementation, erase unit 203 also can comprise:
Second deletes subelement, when dividing area overlapping for existing between current bay and next subregion, skipping current bay, only carrying out erase operation to other subregions except current bay.
Wherein, erase unit 203 specifically for:
When needs carry out erase operation to disk current bay, by writing random number in erase area, carry out erasing disk.
The magnetic disk erasing device provided by the embodiment of the present invention, before performing concrete magnetic disk erasing operation, first can be judged the phenomenon that whether there is point area overlapping between disk partition, and according to judged result, determines the erase operation for disk current bay.Therefore, in the process of erasing disk, can available protecting disk partition information, and then protect the data security of user.
As seen through the above description of the embodiments, those skilled in the art can be well understood to the mode that the present invention can add required general hardware platform by software and realizes.Based on such understanding, technical scheme of the present invention can embody with the form of software product the part that prior art contributes in essence in other words, this computer software product can be stored in storage medium, as ROM/RAM, magnetic disc, CD etc., comprising some instructions in order to make a computer equipment (can be personal computer, server, or the network equipment etc.) perform the method described in some part of each embodiment of the present invention or embodiment.
Each embodiment in this instructions all adopts the mode of going forward one by one to describe, between each embodiment identical similar part mutually see, what each embodiment stressed is the difference with other embodiments.Especially, for device or system embodiment, because it is substantially similar to embodiment of the method, so describe fairly simple, relevant part illustrates see the part of embodiment of the method.Apparatus and system embodiment described above is only schematic, the wherein said unit illustrated as separating component or can may not be and physically separates, parts as unit display can be or may not be physical location, namely can be positioned at a place, or also can be distributed in multiple network element.Some or all of module wherein can be selected according to the actual needs to realize the object of the present embodiment scheme.Those of ordinary skill in the art, when not paying creative work, are namely appreciated that and implement.
Above to method and the device of erasing disk provided by the present invention, be described in detail, apply specific case herein to set forth principle of the present invention and embodiment, the explanation of above embodiment just understands method of the present invention and core concept thereof for helping; Meanwhile, for one of ordinary skill in the art, according to thought of the present invention, all will change in specific embodiments and applications.In sum, this description should not be construed as limitation of the present invention.