Summary of the invention
The technical problem to be solved in the present invention is; above-mentioned defective at prior art; a kind of method and device of adjusting disk partition under Windows is provided; provide a kind of under the prerequisite of the existing Windows of protection; adjust the reference position of subregion and the method for amount of capacity; and support Vista/Windows 7 up-to-date operating systems, provide users with the convenient.
The technical scheme that technical solution problem of the present invention is adopted is as follows:
A kind of method of adjusting disk partition under Windows, wherein, described method comprises the steps:
The operational order of disk partition size is adjusted in A, reception;
B, enter Windows Native pattern, load Windows system partitioning protection mechanism, and load disk sector read-write kernel and drive;
C, the controlled disk partition of judgement are transferred greatly or are turned down, forward step D when turning down to, directly the scope of NTFS subregion bunch occupied information are transferred greatly when accent is big, and jump to step e;
D, the file of controlled disk partition is traveled through, judge that controlled disk partition file content takies bunch whether in setting range; When what judge that controlled disk partition file content takies bunch is beyond setting range the time, and then mobile this document content is in setting range, and bunch occupied information of updating file content, enters step e;
E, according to adjusted disk partition size and document cluster occupied information, bunch occupied information of updating file system, and the startup boot sector of updating file system enters step F;
F, judge whether the start offset of adjusted disk partition variation has taken place,, forward step G to, otherwise forward step H to when variation has taken place for the start offset of adjusted disk partition;
G, according to adjusted disk partition offset variation situation, integral body is carried out in adjusted disk partition moves, adjusted skew is shifted in the skew before adjusting, and enters step H;
H, restart the Windows system once more.
The described method of adjusting disk partition under Windows, wherein, described disk partition comprises NTFS subregion, FAT32 subregion, exFAT subregion.
The described method of adjusting disk partition under Windows, wherein, the mobile this document content among the described step D also comprises with interior to setting range: drive mobile this document content in setting range by the sector read-write.
The described method of under Windows, adjusting disk partition, wherein, described step G further comprises:
G1, when the skew of adjusted disk partition has reduced by a sector, then increase earlier a sector, and the sector occupied information of updating file system at adjusted disk partition rear portion;
G2, all sectors that will increase a the disk partition behind the sector move forward a sector, then finish the adjustment state.
The described method of under Windows, adjusting disk partition, wherein, described Windows system partitioning protection mechanism; be used to protect the Windows system partitioning; drive by file system filter, the read-write operation that system under the Native environment carries out is tackled, and be redirected.
The described method of under Windows, adjusting disk partition, wherein, it is the driver of a kernel state that described disk sector read-write kernel drives, be used for content at move, when writing disk, by sending request for this Kernel Driver, the disk sector content that will write is realized the write operation of disk sector by this Kernel Driver.
A kind of device of adjusting disk partition under Windows wherein, comprising:
Receiver module is used to receive the operational order of adjusting the disk partition size;
Adjust the original upload module, be used to enter Windows Native pattern, load Windows system partitioning protection mechanism, and load the driving of disk sector read-write kernel;
First judge module is used to judge that controlled disk partition transfers greatly or turn down;
Turn processing module down, be used for when controlled disk partition is turned down, the file of controlled disk partition is traveled through, judge that controlled disk partition file content takies bunch whether in setting range; When what judge that controlled disk partition file content takies bunch is beyond setting range the time, and then mobile this document content is in setting range, and bunch occupied information of updating file content;
Update module is used for according to adjusted disk partition size and document cluster occupied information, bunch occupied information of updating file system; And the startup boot sector of updating file system.
The described device of under Windows, adjusting disk partition, wherein, it also comprises:
Second judge module is used to judge whether the start offset of adjusted disk partition variation has taken place;
Offset module is used for when the start offset of adjusted disk partition variation having taken place, and according to adjusted disk partition offset variation situation, integral body is carried out in adjusted disk partition move, and adjusted skew is shifted in the skew before adjusting;
Adjust the back and start module, be used for the subregion adjustment and finish, normally start Windows.
The described device of under Windows, adjusting disk partition, wherein, described disk partition comprises NTFS subregion, FAT32 subregion, exFAT subregion;
The described processing module of turning down further comprises:
Read-write driver element in sector is used for driving mobile this document content in setting range by the sector read-write.
The described device of under Windows, adjusting disk partition, wherein, described offset module further comprises:
Skew increases the unit, is used for when the skew of adjusted disk partition has reduced by a sector, then increases a the sector and the sector occupied information of updating file system earlier at adjusted disk partition rear portion;
The reach unit is used for all sectors of the disk partition behind a sector of increase are moved forward a sector, then finishes the adjustment state.
A kind of method and device of adjusting disk partition under Windows provided by the present invention is converted into the constant partition size adjustment of reference position by the partition size adjustment that reference position is changed, thereby realizes that district location changes the support of adjusting; Vista/Windows 7 times, realize write operation to disk sector by Kernel Driver; At the operation Windows partition; pass through protection mechanism; realize the protection of Windows system partitioning; guarantee the integrality of operating system; and can protect user's data effectively when subregion, it has increased new function to computing machine: can arbitrarily adjust the NTFS subregion under Windows, and have the function of the reference position that changes subregion; guaranteed the security of system behind the subregion, provided users with the convenient.
Embodiment
A kind of method and device of adjusting disk partition under Windows provided by the present invention, described disk partition comprises NTFS subregion, FAT32 subregion, exFAT subregion.For making purpose of the present invention, technical scheme and advantage clearer, clear and definite, below develop simultaneously with reference to accompanying drawing that the present invention is described in more detail for embodiment.Should be appreciated that specific embodiment described herein only in order to explanation the present invention, and be not used in qualification the present invention.
Wherein, subregion start offset position and amount of capacity adjustment, conclude and get up to have following several situation:
1, the constant partition size adjustment in subregion start offset position (be called for short skew or position), as shown in Figures 2 and 3, subregion C adjusts to the state of Fig. 3 by the state of Fig. 2, subregion have transfer big with turn two kinds of situations down, only showed the big situation of transferring here.
Wherein, the state of Fig. 2: disk has n sector, and the Sector Range of subregion C is [j, k], amounts to k-j+1 sector-size.
The state of Fig. 3: disk has n sector, and the Sector Range of subregion C is [j, k+b], (b〉0).
2, the partition size adjustment that changes of subregion start offset, as Fig. 2, Fig. 4, shown in Figure 5: subregion C adjusts to the state of Fig. 4 or the state of Fig. 5 by the state of Fig. 2, (subregion skew have transfer forward and transfer two kinds of situations backward, only show the situation of transferring forward here).
Wherein, the state of Fig. 2 is: disk has n sector, and the Sector Range of subregion C is [j, k].
The state of Fig. 4 is: disk has n sector, and the Sector Range of subregion C is [j-a, k], (a〉0).
The state of Fig. 5 is: disk has n sector, and the Sector Range of subregion C is [j-a, k+b], (a〉0, b〉0, j〉a).
The embodiment of the invention 1 provides a kind of NTFS partitioned method of adjusting under Windows, as shown in Figure 6, mainly may further comprise the steps:
The operational order of NTFS partition size is adjusted in the affirmation of step S110, reception user input; For example, when the user need adjust C dish subregion, to the storage space of 2 G of C dish subregion increasing, then input strengthens the operational order of 2 G accordingly to C dish subregion.
Step S120, restart the Windows system.After adjusting the instruction input of subregion, restart the Windows system, enter step S130.
Step S130, enter Windows Native pattern, load Windows system partitioning protection mechanism, and load disk sector read-write kernel and drive.
Wherein, the Native pattern is after Windows starts, a running status before the User login, and the adjustment of NTFS subregion operation is finished under this running status in the embodiment of the invention.The small number of programs of having only Windows under this state is in operation, and the read-write operation of disk seldom can significantly reduce the influence to subregion adjustment operation; Be similar to the zone inspections function that Windows carries.
About Windows system partitioning protection mechanism; in disk read-write drives; subregion adjustment operation of the present invention is to have finished under the Native environment; though the Native environment has only a small amount of process down; system partitioning is read and write; but can't the locking system subregion, the read-write of system partitioning is finished by driving.Therefore may have a kind of conflict: the sector of writing by driving during move also is the sector that system is write under the Native environment.If conflict takes place, can cause the damage of file content, and then destroy the Windows system partitioning, cause after the adjustment operation is finished, Windows system originally can't normally start.
For fear of the generation of this situation, adopt a kind of protection mechanism among the present invention, promptly Windows system partitioning protection mechanism is used to protect the Windows system partitioning.Drive by a file system filter, the read-write operation that system under the Native environment carries out is tackled, and be redirected, avoid itself and disk read-write to drive write operation and clash.Because under the Native environment, the read-write operation that system carries out is considerably less, so this redirected protection mechanism, system overhead is considerably less, also convenient the realization.
It is a program that is operated in the Windows kernel that file system filter drives.It is loaded operation when Windows starts, just carry out the function to the interception of Windows system partitioning read-write operation.Any read-write operation to the Windows system partitioning all can pass through the file system filter driver earlier, and file system filter drives can change the read-write operation behavior.For fear of above-mentioned read/write conflict, file system filter drives and all Windows can be changed other local read-write operations to our appointment to the read-write operation of certain sector on the system partitioning.This just guaranteed that each sector only has a program in read-write, avoid reading and writing the problem of concurrency conflict, also just guarantee the integrality of Windows system partitioning data.
Read-write drives about the disk sector among the embodiment; Begin from Windows Vista, Microsoft is for improving the security of Windows system, and Any Application carries out write operation to disk or subregion, and locking disk or subregion are monopolized write operation earlier.Under Windows running environment, Windows has a large amount of processes in operation, continual disk is carried out read-write operation, so restarts in the embodiment of the invention to have forwarded to finish under the Native and adjust operation.
And under Native running environment,, also also have a small amount of process in operation though environment is simple, system partitioning is carried out read-write operation, thereby also can't successfully lock and carry out write operation.Therefore, this embodiment has also realized loading a disk sector read-write driver, because kernel program has higher priority, not disk is read and write by the operating system restriction.So when the content of move, in the time of writing disk, will ask by sending to Kernel Driver in the embodiment of the invention, the disk sector content that will write is finished by this Kernel Driver, thereby realizes the successful write operation of disk sector.
The disk read-write driver also is a program that is operated in the Windows kernel.Its effect is to carry out the disk read-write operation.Behind Vista, Win7, any non-kernel program can't carry out write operation to disk under the condition of not monopolizing the locking disk, and kernel program then is not subjected to any restriction.The a small amount of system process of Windows is also carrying out read-write operation to disk under the Native, can't monopolize.Therefore, when the move content, all disk read-write operations all can allow disk read-write drive and achieve the goal on behalf of reading and writing.
File system filter driving and disk sector read-write driving one are worked like this, can read and write the Windows system partitioning, can avoid read/write conflict again.
Finish, load Windows system partitioning protection mechanism, and after loading the driving of disk sector read-write kernel, enter step S140.
Step S140, the controlled NTFS subregion of judgement are transferred greatly or are turned down, forward step S150 when turning down to, forward step S160 when accent is big to.
Step S150, when being that controlled NTFS subregion is turned down, then need the file of the NTFS subregion turned down is traveled through, so-called traversal (Traversal) is meant along certain bar search pattern, successively once visit is all done once and only done to each node in the tree.And judge that controlled NTFS partitioned file content takies bunch in setting range?
Wherein, bunch be the minimum unit of file system management allocation space, be the set of several sectors.One bunch sector number generally be 2 n power (n is a natural number, n 〉=0, and n<=10).Bunch can directly be interpreted as the sector.
When judge that controlled disk partition file content takies bunch be in setting range with interior then without the mobile disk partitioned file.And bunch be beyond setting range the time when what judge that controlled NTFS partitioned file content takies, then mobile this document content is in setting range, for example, when need are turned down C dish subregion, and this C coils that an original QQ file content takies bunch is beyond setting range, then can in setting range, search free sector, drive by the sector read-write and move this QQ file content in setting range.And bunch occupied information of updating file content, enter step S160.
Step S160, according to adjusted NTFS partition size and document cluster occupied information, bunch occupied information of updating file system; Promptly, directly the scope of NTFS subregion bunch occupied information is transferred greatly, then bunch occupied information of updating file system if transfer big NTFS subregion.
The startup boot sector of step S170, updating file system.
Step S180, the start offset of judging adjusted NTFS subregion taken place variation (reference position of promptly judging adjusted NTFS subregion with regulate before the skew of reference position of NTFS subregion variation has taken place?), when variation has taken place for the start offset of adjusted NTFS subregion, forward step S190 to, otherwise forward step S200 to;
Step S190, according to adjusted NTFS subregion offset variation situation, adjusted NTFS subregion is carried out integral body to be moved, adjusted skew is shifted in skew before adjust: for example, when the skew of adjusted NTFS subregion has reduced by a sector, then increase a sector earlier at adjusted NTFS subregion rear portion, and the sector occupied information of updating file system; All sectors that will increase a the NTFS subregion behind the sector then move forward a sector, then finish the adjustment state.Enter step S200.
Step S200, restart the Windows system once more, enter step S210;
Step S210, normally start Windows, the subregion adjustment is finished.
Below by a concrete Application Example the present invention is adjusted the NTFS partitioned method under Windows and is described in further details:
In this concrete Application Example, adjust preceding subregion state figure as shown in Figure 2, in the state of Fig. 2, disk has n sector, and the Sector Range of subregion C is [j, k], amounts to k-j+1 sector-size.Need adjust C dish position and size now simultaneously, to state shown in Figure 7: disk has n sector, and the Sector Range of subregion C is [j-a, k-b], (a〉0, b〉0, j〉a, k〉b).
Wherein, the variation of subregion C from state shown in Figure 2 to state shown in Figure 77, variation has taken place with size in subregion skew simultaneously.This enforcement will realize by following steps:
At first, can see from Fig. 2, Fig. 7, since from state shown in Figure 2 to state shown in Figure 7, the size of subregion C has reduced by b sector, Sector Range (k-b, k] after adjustment, just do not belong to the scope that takies of subregion C, and when being that controlled NTFS subregion is turned down, then need the file of the NTFS subregion turned down is traveled through.
So in the present embodiment since from state shown in Figure 2 to state shown in Figure 7, the size of subregion C has reduced by b sector, the file of subregion C is traveled through, judge whether sector that file takies belong to scope (k-b, k]; If, just in Sector Range [j, k-b], search free sector, with file content from Sector Range (k-b, k] move to Sector Range [j, k-b].In the process that moves, drive by the sector read-write.The sector occupied information of updating file after the move content; After file traversal is intact, the sector occupied information of updating file system.After all operations was finished, subregion C had become intermediateness as shown in Figure 8.
Wherein, subregion state shown in Figure 8 is: disk has n sector, and the Sector Range of subregion C is [j, k-b], (b〉0, k〉b).
Then, handle the subregion offset variation.In subregion state shown in Figure 7, the skew of subregion C has reduced by a sector at Fig. 2.In conjunction with the characteristics of new technology file system, on the basis of subregion state shown in Figure 88, increase a sector at subregion C rear portion shown in Figure 8 earlier in the embodiment of the invention.Become state as shown in Figure 9: disk has n sector, and the Sector Range of subregion C is [j, k-b+a], (a〉0, b〉0, k〉b).State shown in Figure 9 has increased the size of subregion C, without the move content, as long as the sector occupied information of updating file system.Promptly, directly the scope of NTFS subregion bunch occupied information is transferred greatly if transfer big NTFS subregion, then according to adjusted NTFS partition size and document cluster occupied information, bunch occupied information of updating file system.
At last, in order to adjust subregion skew, only need be on the basis of subregion state shown in Figure 9 in the invention process, all sectors of subregion C are moved forward a sector, can realize final adjustment state, the end-state of subregion C promptly shown in Figure 7.
The state of subregion C carries out size adjustment, reaches the variation that state 9 shown in Figure 9 is offset through state shown in Figure 8 from state shown in Figure 2, promptly is adjustable to the state of the described subregion C of final Fig. 7.In actual mechanical process, because subregion C state shown in Figure 9 just changes the size of subregion, without the move content, the map function of subregion C state shown in Figure 8 and subregion C state 9 shown in Figure 9 can be merged into an operation.
Therefore; the embodiment of the invention provides a kind of method of adjusting disk partition under Windows; provide a kind of under the prerequisite of the existing Windows of protection; adjust the reference position of subregion and the method for amount of capacity; and support Vista/Windows 7 up-to-date operating systems, provide users with the convenient.
Based on the method for adjusting disk partition under Windows of the foregoing description, the embodiment of the invention also provides a kind of device of adjusting disk partition under Windows, and as shown in figure 10, it comprises:
Receiver module 910, the operational order of NTFS partition size is adjusted in the affirmation that is used to receive user's input, and restarts the Windows system; Specifically as mentioned above.
Adjust original upload module 920, be used to restart the Windows system, enter Windows Native pattern, load Windows system partitioning protection mechanism, and load the driving of disk sector read-write kernel; Specifically as mentioned above.
First judge module 930 is used to judge that controlled NTFS subregion transfers greatly or turn down; Specifically as mentioned above.
Turn processing module 940 down, be used for when controlled NTFS subregion is turned down, the file of controlled NTFS subregion is traveled through, judge that controlled NTFS partitioned file content takies bunch whether in setting range; When what judge that controlled NTFS partitioned file content takies bunch is beyond setting range the time, and then mobile this document content is in setting range, and bunch occupied information of updating file content; Specifically as mentioned above.
Update module 950 is used for according to adjusted NTFS partition size and document cluster occupied information bunch occupied information of updating file system; And the startup boot sector of updating file system.
Second judge module 960 is used to judge whether the start offset of adjusted NTFS subregion variation has taken place; Specifically as mentioned above.
Offset module 970 is used for when the start offset of adjusted NTFS subregion variation having taken place, and according to adjusted NTFS subregion offset variation situation, adjusted NTFS subregion is carried out integral body move, and adjusted skew is shifted in the skew before adjusting; Specifically as mentioned above.
Adjust the back and start module 980, be used for the subregion adjustment and finish, normally start Windows, specifically as mentioned above.
As shown in figure 11, the described processing module 940 of turning down further comprises:
Read-write driver element 941 in sector is used for driving mobile this document content in setting range, specifically as mentioned above by the sector read-write.
As shown in figure 12, described offset module 970 further comprises:
Skew increases unit 971, is used for when the skew of adjusted NTFS subregion has reduced by a sector, then increases a the sector and the sector occupied information of updating file system earlier at adjusted NTFS subregion rear portion; Specifically as mentioned above.
Reach unit 972 is used for all sectors of the NTFS subregion behind a sector of increase are moved forward a sector, then finishes the adjustment state, specifically as mentioned above.
In sum, a kind of method and device of under Windows, adjusting disk partition provided by the present invention, be converted into the constant partition size adjustment of reference position by the partition size adjustment that reference position is changed, thereby realize that district location changes the support of adjusting; Vista/Windows 7 times, realize write operation to disk sector by Kernel Driver; At the operation Windows partition; pass through protection mechanism; realize the protection of Windows system partitioning; guarantee the integrality of operating system; and can protect user's data effectively when subregion, it has increased new function to computing machine: can arbitrarily adjust the NTFS subregion under Windows, and have the function of the reference position that changes subregion; guaranteed the security of system behind the subregion, provided users with the convenient.
Should be understood that application of the present invention is not limited to above-mentioned giving an example, for those of ordinary skills, can be improved according to the above description or conversion that all these improvement and conversion all should belong to the protection domain of claims of the present invention.