CN101673242A - Method and device for formatting hard disk - Google Patents
Method and device for formatting hard disk Download PDFInfo
- Publication number
- CN101673242A CN101673242A CN200810212884A CN200810212884A CN101673242A CN 101673242 A CN101673242 A CN 101673242A CN 200810212884 A CN200810212884 A CN 200810212884A CN 200810212884 A CN200810212884 A CN 200810212884A CN 101673242 A CN101673242 A CN 101673242A
- Authority
- CN
- China
- Prior art keywords
- sector
- format
- definition
- hard disk
- sector number
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Landscapes
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The invention discloses a method and a device for formatting a hard disk, which are applied to a FAT file system. The method comprises the following steps: defining FAT file system boot-sectors in anoperating system kernel, setting the number of the cluster of sectors to be represented by two bytes, and setting the number of the reserved sectors to be represented by one byte; defining a formatting tool according to the defined FAT file system boot-sectors; and utilizing the defined formatting tool to format the hard disk. The technical scheme provided by the invention can reduce the number ofFAT table entries and save a system maintenance space.
Description
Technical field
The present invention relates to field of computer technology, relate in particular to a kind of formatting hard disk method and apparatus.
Background technology
File configuration table (File Allocation Table, abbreviate FAT as) be a kind of file system, this document system is applied to disc operating system (DOS) (the Disk OperationSystem of Microsoft at first, abbreviate DOS as), this document system also is applied to the Microsft Windows operating system of non-NT kernel simultaneously, and, because the FAT file system is relatively simple for structure, be easy to use and expand, therefore, also have utilization more extensive in built-in field.
Hard disk just can be formatted into different file system after subregion instruments such as using FDISK carries out subregion.After adopting the FAT file system that hard disk is formatd, hard disk is divided into several sections as shown in Figure 1: leader record (DOS Boot Record abbreviates DBR as) district, FAT1, FAT2, directory area, data field.Wherein,
The DBR district is the leader record district of FAT file system, usually the 0th sector that takies subregion is totally 512 bytes, by jump instruction, manufacturer sign and operating system version number, Basic Input or Output System (BIOS) parameter region (BIOS Parameter Block, abbreviate BPB as), the expansion BPB, operating system (Operating System, abbreviating OS as) several sections such as boot and end mark form, and wherein BPB has specified the logic sector size of file system.In the FAT file system, several sectors that the data field is continuous are called cluster, as the base unit of file storage, have also indicated the sector number (number of sectors of promptly forming cluster) of cluster among the BPB.
The FAT partition table is positioned at after the DBR, be used for data field on the recording disc bunch operating position.The FAT partition table has two: FAT1, and FAT2, both contents are identical, and FAT2 is the backup of FAT1, is used for the recovery of file system.The storage condition of a file in the FAT file system is to indicate by the list item in the FAT partition table, one bunch of a list item corresponding data district, file points to the position of first list item, and this list item is stored the index of next list item, one-level one-level chain goes down like this, i.e. chain type storage.
Directory area storage be the information of catalogue and file, after the FAT partition table, be used for the essential information of log file, comprise file size, modification time, the position of first FAT list item of current access limit and file.
The data field then is the place of actual storage file content.
File system with the FAT32 form is an example, the size of a logic sector, and effective value is 512,1024,2048,4096, the sector number number of cluster is 1,2,4 ..., 256, be 256 to the maximum.Like this, the maximum storage capacity of cluster is 4096*256 byte, i.e. 1M.For video data file, video data file may reach 4G or more than, if cluster can be stored the data of 1M, then a video data file need be stored on 4000 bunches, these bunches are to indicate by the FAT list item, therefore, a video data file needs 4000 fat list items to indicate.If the disk space that uses is very big, such as hundreds of or thousands of G, FAT list item number can be a lot, increased the space that system maintenance needs; And the memory location of file data also relatively disperses, and the addressing time of hard disc magnetic head reading of data is longer, causes the decrease in efficiency of access data.
Summary of the invention
In view of this, the present invention proposes a kind of formatting hard disk method and apparatus, in order to solving in the prior art, and cause the FAT list item number in the hard disk a lot, thereby increased the problem in the space of system maintenance because the sector number of cluster is less.
According to an aspect of the present invention, provide a kind of formatting hard disk method, this method is applied to the FAT file system.
Formatting hard disk method according to the present invention comprises: the FAT file system boot sector in the defining operation system kernel, and the sector number of cluster is set to by two byte representations, and the reserve sector number is set to by a byte representation; According to the FAT file system boot sector of definition, definition format chemical industry tool; Utilize the format instrument disk format of definition.
According to another aspect of the present invention, provide a kind of formatting hard disk device.
Formatting hard disk device according to the present invention comprises: first definition module, second definition module and formatting module.Wherein, first definition module is used for the FAT file system boot sector of defining operation system kernel, and the sector number of cluster is set to by two byte representations, and the reserve sector number is set to by a byte representation; Second definition module is used for the FAT file system boot sector according to the definition of first definition module, definition format chemical industry tool; Formatting module is used to utilize the format instrument of second definition module definition.
By above-mentioned at least one scheme of the present invention, sector number by the cluster in the FAT file system boot sector is set to increase the sector number of cluster by two byte representations, has improved the storage capacity of cluster, thereby reduced the number of FAT list item, saved the space of system maintenance.
Other features and advantages of the present invention will be set forth in the following description, and, partly from instructions, become apparent, perhaps understand by implementing the present invention.Purpose of the present invention and other advantages can realize and obtain by specifically noted structure in the instructions of being write, claims and accompanying drawing.
Description of drawings
Accompanying drawing is used to provide further understanding of the present invention, and constitutes the part of instructions, is used from explanation the present invention with embodiments of the invention one, is not construed as limiting the invention.In the accompanying drawings:
Fig. 1 is the synoptic diagram of the partition structure of hard disk in the FAT file system;
Fig. 2 is the process flow diagram according to the formatting hard disk method of the embodiment of the invention;
Fig. 3 is the process flow diagram of the concrete enforcement of the embodiment of the invention;
Fig. 4 A is the structured flowchart according to the formatting hard disk device of the embodiment of the invention;
Fig. 4 B is the structured flowchart of formatting hard disk device according to the preferred embodiment of the invention.
Embodiment
Functional description
As mentioned above, at in the present FAT system since the sector number of cluster very little, and cause a big file (bigger file promptly takes up room) to indicate with a large amount of FAT list items, thereby increased the problem in the space of system maintenance, the embodiment of the invention has proposed a kind of formatting hard disk scheme, this scheme is by the FAT file system boot sector in the defining operation system kernel, the sector number of cluster is set to by two byte representations, and the reserve sector number is set to by a byte representation, and according to above-mentioned definition, definition format chemical industry journey, utilize this format instrument form hard disk then, thereby make this hard disk to have reduced by a FAT list item that big file is required with the form storage file of bulk bunch.
Below in conjunction with accompanying drawing the preferred embodiments of the present invention are described, should be appreciated that preferred embodiment described herein only is used for description and interpretation the present invention, and be not used in qualification the present invention.
According to the embodiment of the invention, a kind of formatting hard disk method at first is provided, this method is applied to the FAT file system.
Fig. 2 is the process flow diagram according to the formatting hard disk method of the embodiment of the invention, as shown in Figure 2, mainly comprises following processing (step S201-step S205) according to the formatting hard disk method of the embodiment of the invention:
Step S201: the FAT file system boot sector in the defining operation system kernel, the sector number of cluster is set to by two byte representations, and the reserve sector number is set to by a byte representation;
Step S203: according to the described FAT file system boot sector of definition, definition format chemical industry tool;
Step S205: the described format instrument disk format that utilizes definition.
Below further describe each details of above-mentioned processing.
(1) step S201
In present FAT file system, the sector number of cluster is by 1 byte representation in the boot sector structure, and the reserve sector number is by 2 byte representations.But in practice, the reserve sector number is generally 32, therefore use 1 byte just can represent, and the size of cluster will realize more than the 2M, must 2 bytes represent, reaches above sector number to represent 512.
Behind the FAT file system boot sector in defining operating system nucleus, can discern the boot sector of definition in order to make goal systems, the operating system content that needs the upgrading goal systems, reload the file system read module, make goal systems can support 2M and reading with the big or small file of putting on an arrow.
(2) step S203
For the FAT file system boot sector of above-mentioned definition being write hard disk, must define corresponding format instrument, in specific implementation process, definition format chemical industry tool can may further comprise the steps:
Step 1: be written to the boot sector of hard disk in the definition format chemical industry tool, the sector number of cluster is set to by two byte representations in the boot sector of format instrument, and the reserve sector number is set to by a byte representation.
Step 2: format in the boot sector of instrument with bunch the relevant variable of size be set to by two byte representations; Such as, revise the account form of FAT list item etc., will be referred to two byte representations that are revised as of bunch size.
Step 3: the input parameter to form chemical industry tool is configured, and makes the support of format instrument specify the cluster sector greater than 256 parameter.
(3) step S205
Utilize the format instrument that defines among the step S203 that hard disk is formatd in this step, after format was finished, this method further comprises: the guiding DBR district at hard disk write guidance information corresponding with the boot sector of above-mentioned definition and root directory information.
And, in application program (being read-write program), before the reading and writing of files system, need with the stack arrangement of process the size corresponding with input parameter, read the bulk clustered file so that application program can be correct.Such as, when utilizing format instrument disk format, if input parameter is 512, promptly specifying the cluster sector number is 512, and sector-size is 4096, and then the size of every bunch of this FAT file system is 2M, and then the stack arrangement with process is 2M.
By the said method that the embodiment of the invention provides, can realize the FAT file system of the above bulk of 2M bunch, the quantity of FAT list item in the time that file storage can being reduced.
In order to further describe the embodiment of said method, be example with bunch size that under embedded Linux operating system, realizes 2M below, the embodiment of the said method that the embodiment of the invention is provided describes.
Fig. 3 is the process flow diagram of the concrete enforcement of present embodiment, and as shown in Figure 3, the concrete enforcement of this embodiment mainly may further comprise the steps:
Step S301: the variable of expression cluster sector number in the structure of expression DBR boot sector in the linux kernel is revised as 2 byte representations, and the variable of expression reserve sector number is revised as 1 byte representation.
Particularly, the structure of expression DBR boot sector is fat_boot_sector in linux kernel, sector_size variable in this structure is represented a sector-size of this document system, usually the sector is 512 bytes, but maximal value is because the restriction of operating system can not surpass 4096, and the cluster_size variable indicates each bunch what sectors to be made of, the reserved argument table is shown in after the DBR district, needs the sector number that keeps.
Because in actual applications, generally keep 32 sectors, it is the information of FAT list item that the 33rd sector begins.Therefore, with the reserved variable by representing to be revised as by an octet by two octets, the cluster_size variable is represented by representing to be revised as by two octets by an octet, cluster_size variable maximum occurrences is 65535 like this, be that the cluster maximum can be made up of 65535 sectors, and the reserve sector of FAT file system is generally 32, the reserved variable is set to can normally represent by a byte representation, can influence other one-piece constructions of FAT file system.
After revising the boot sector structure, the method of handling this structure is also needed to carry out corresponding modification, if relate to the problem of syllable sequence, should increase the conversion operations of syllable sequence to cluster_size, remove the syllable sequence conversion operations of reserved variable.
Step S303: the linux kernel on the upgrading operation system, reload the file system read module, so that this operating system can be supported 2M and reading with the big or small file of putting on an arrow.
Step S305: according to the method among the step S301, revise boot sector dependency structure and processing in the format instrument, so that the format instrument can accept to specify the cluster sector number greater than 256 parameter.
Use the file system of above-mentioned definition, need using form chemical industry tool to carry out the format manipulation of hard disk, therefore, need to revise boot sector dependency structure and processing in the format instrument, every bunch of sector number in the boot sector structure in the format instrument is adjusted into two byte representations from a byte representation, the reserve sector number is adjusted into a byte representation from two byte representations, simultaneously, the account form of modification FAT list item etc.
Input parameter to form chemical industry tool is configured, and the size that make bunch is 2M, if sector-size is 4096, then specifying the cluster sector number is 512, thereby bunch size that has realized this FAT file system is 2M.
Step S307: utilize above-mentioned format instrument that hard disk is formatd.
Step S309: use above-mentioned format instrument to write file system guidance information and root object information in the 0th sector of fdisk.
Step S311: when application program is used this document system,, call the interface that the linux kernel provides, the storehouse size of process is changed into 2M, so that application program can correctly read file at the place that begins of program.
According to the embodiment of the invention, also provide a kind of formatting hard disk device.
Fig. 4 A is the structured flowchart according to the formatting hard disk device of the embodiment of the invention, Fig. 4 B is the structured flowchart of formatting hard disk device according to the preferred embodiment of the invention, shown in Fig. 4 A, comprise according to the formatting hard disk device of the embodiment of the invention: first definition module 41, second definition module 43 and formatting module 45.Below further combined with accompanying drawing above-mentioned each module is described.
First definition module 41 is used for the FAT file system boot sector of defining operation system kernel, and the sector number of cluster is set to by two byte representations, and the reserve sector number is set to by a byte representation;
Second definition module 43 is connected with first definition module 41, is used for the FAT file system boot sector according to 41 definition of first definition module, definition format chemical industry tool;
Formatting module 45 is connected with second definition module 43, is used to utilize the described format instrument of described second definition module definition.
Particularly, shown in Fig. 4 B, second definition module 43 can comprise: first is provided with submodule 431, second is provided with submodule 433 and the 3rd submodule 435 is set.Wherein,
First is provided with submodule 431 is used for the boot sector that definition format chemical industry tool is written to hard disk, and the sector number of cluster is set to by two byte representations in the boot sector of format instrument, and the reserve sector number is set to by a byte representation; Second be provided with boot sector that submodule 433 is used for the instrument that formats with bunch the relevant variable of size be set to by two byte representations; The 3rd is provided with submodule 435 is used for the input parameter of form chemical industry tool is configured, and makes the support of format instrument specify the cluster sector greater than 256 parameter.
Further, shown in Fig. 4 B, the formatting hard disk device of present embodiment also comprises: stack arrangement module 47, the stack arrangement that is used for the process of read-write program is the size corresponding with input parameter.
Further, shown in Fig. 4 B, the formatting hard disk device of present embodiment also comprises: update module 49, be used for sector number and reserve sector number according to 41 settings of first definition module, and upgrade operating system nucleus.
According to the said apparatus of the embodiment of the invention, size that can cluster is set to 2M and above size.
As mentioned above, by the present invention, variable by expression cluster sector number in the boot sector in operating system nucleus and the form chemical industry tool is set to by two byte representations, every bunch size can be promoted to more than 2M reaches, the quantity of FAT list item in the time of can reducing file storage, reduced the space that system maintenance needs, and, since bunch size increased, storage for big file (as video data file), the memory location of file data is more concentrated, can reduce the addressing time of hard disc magnetic head reading of data, improves the efficient of access data.
The above is the preferred embodiments of the present invention only, is not limited to the present invention, and for a person skilled in the art, the present invention can have various changes and variation.Within the spirit and principles in the present invention all, any modification of being done, be equal to replacement, improvement etc., all should be included within protection scope of the present invention.
Claims (9)
1. a formatting hard disk method is applied to file configuration table FAT file system, it is characterized in that, comprising:
FAT file system boot sector in the defining operation system kernel, the sector number of cluster is set to by two byte representations, and the reserve sector number is set to by a byte representation;
According to the described FAT file system boot sector of definition, definition format chemical industry tool;
Utilize the described format instrument disk format of definition.
2. method according to claim 1 is characterized in that, defines in described operating system nucleus after the FAT file system boot sector, and described method also comprises:
Upgrade described operating system nucleus according to the described sector number and the described reserve sector number that are provided with.
3. method according to claim 1 is characterized in that, the processing of described definition format chemical industry tool specifically comprises:
Define the boot sector that is written to hard disk in the described format instrument, the sector number of cluster is set to by two byte representations in the boot sector of described format instrument, and the reserve sector number is set to by a byte representation;
In the boot sector of described format instrument with bunch the relevant variable of size be set to by two byte representations;
Input parameter to described format instrument is configured, and makes described format instrument support specify the cluster sector greater than 256 parameter.
4. method according to claim 3 is characterized in that, behind the described hard disk of format, described method also comprises:
Leader record district in the FAT of hard disk file system writes corresponding guidance information and root directory information.
5. method according to claim 3 is characterized in that, after the described hard disk of format, before the use read-write program reading and writing of files system, described method also comprises:
With the stack arrangement of the process of described read-write program is the size corresponding with described input parameter.
6. a formatting hard disk device is characterized in that, comprising:
First definition module is used for the FAT file system boot sector of defining operation system kernel, and the sector number of cluster is set to by two byte representations, and the reserve sector number is set to by a byte representation;
Second definition module is used for the described FAT file system boot sector according to described first definition module definition, definition format chemical industry tool;
Formatting module is used to the described format instrument that utilizes described second definition module to define.
7. device according to claim 6 is characterized in that, described second definition module comprises:
First is provided with submodule, be used for defining the boot sector that described format instrument is written to hard disk, the sector number of cluster is set to by two byte representations in the boot sector of described format instrument, and the reserve sector number is set to by a byte representation;
Second is provided with submodule, the boot sector that is used for described format instrument with bunch the relevant variable of size be set to by two byte representations;
The 3rd is provided with submodule, is used for the input parameter of described format instrument is configured, and makes described format instrument support specify the cluster sector greater than 256 parameter.
8. device according to claim 7 is characterized in that, described device also comprises: the stack arrangement module, the stack arrangement that is used for the process of described read-write program is the size corresponding with described input parameter.
9. device according to claim 6 is characterized in that, described device also comprises: update module, be used for described sector number and described reserve sector number according to described first definition module setting, and upgrade described operating system nucleus.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN200810212884A CN101673242A (en) | 2008-09-10 | 2008-09-10 | Method and device for formatting hard disk |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN200810212884A CN101673242A (en) | 2008-09-10 | 2008-09-10 | Method and device for formatting hard disk |
Publications (1)
Publication Number | Publication Date |
---|---|
CN101673242A true CN101673242A (en) | 2010-03-17 |
Family
ID=42020473
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN200810212884A Pending CN101673242A (en) | 2008-09-10 | 2008-09-10 | Method and device for formatting hard disk |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN101673242A (en) |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102117316A (en) * | 2010-12-31 | 2011-07-06 | 华为数字技术有限公司 | FAT (file allocation table) file system formatting method and device |
CN103198850A (en) * | 2013-03-20 | 2013-07-10 | 广东欧珀移动通信有限公司 | Method and device of intelligent formatting of internal hard disk of Android equipment |
CN104991746A (en) * | 2015-07-27 | 2015-10-21 | 深圳市蓝天威视科技有限公司 | Method and system for storing and reading record data in FAT hard disk |
CN105446772A (en) * | 2015-11-16 | 2016-03-30 | 青岛海信移动通信技术股份有限公司 | System upgrading method and apparatus |
-
2008
- 2008-09-10 CN CN200810212884A patent/CN101673242A/en active Pending
Cited By (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102117316A (en) * | 2010-12-31 | 2011-07-06 | 华为数字技术有限公司 | FAT (file allocation table) file system formatting method and device |
CN102117316B (en) * | 2010-12-31 | 2012-11-21 | 华为数字技术有限公司 | FAT (file allocation table) file system formatting method and device |
CN103198850A (en) * | 2013-03-20 | 2013-07-10 | 广东欧珀移动通信有限公司 | Method and device of intelligent formatting of internal hard disk of Android equipment |
CN104991746A (en) * | 2015-07-27 | 2015-10-21 | 深圳市蓝天威视科技有限公司 | Method and system for storing and reading record data in FAT hard disk |
CN105446772A (en) * | 2015-11-16 | 2016-03-30 | 青岛海信移动通信技术股份有限公司 | System upgrading method and apparatus |
CN105446772B (en) * | 2015-11-16 | 2019-01-04 | 青岛海信移动通信技术股份有限公司 | A kind of method and apparatus of system upgrade |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10168962B2 (en) | Tape emulating disk based storage system and method with automatically resized emulated tape capacity | |
CA2047696C (en) | Method of reading and writing files on non-erasable storage media | |
EP1905044B1 (en) | Apparatus, system and method for accessing persistent files in non-execute-in-place flash memory | |
US20060020645A1 (en) | Information processing apparatus and recording medium | |
US8140793B2 (en) | Virtual tape device, data backup method, and recording medium | |
JP2008545202A (en) | Method and system for managing partitions in a storage device | |
KR100703807B1 (en) | Method and apparatus for managing block by update type of data in block type memory | |
US7350049B1 (en) | Method and apparatus for managing access to a file allocation table | |
CN101582084B (en) | Method and device for data storage | |
KR20060061204A (en) | Computing device with relatively limited storage space and operating/file system thereof | |
JP2016099949A (en) | Meta-information writing method, meta-information reading method, file management system, computer system, program, and data structure | |
CN102591797A (en) | Auxiliary storage device and processing method thereof | |
CN101673242A (en) | Method and device for formatting hard disk | |
US20160011792A1 (en) | Media control device and control method | |
KR100954603B1 (en) | A log file of file system and method for recovering file system | |
CN110928840B (en) | Method for reading QNX6 file system | |
CN104951569B (en) | File system and the file management method for using this document system | |
CN104133640A (en) | Quick recovery from dormancy | |
CN102063273B (en) | Hard disk management method and device | |
CN109656881B (en) | Method and system for realizing dynamic file management based on FAT16 technology | |
JP2018092426A (en) | Storage control device, storage device, and control program | |
CN102023873A (en) | Application program execution method and system, storage media controller and storage device | |
JP6276301B2 (en) | Storage access control device, storage access control system, storage access control method, and storage access control program | |
JP6097118B2 (en) | Program conversion device, program execution device, program conversion method, and conversion program | |
CN102622301A (en) | Method and system for reading and updating flash-memory files |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
C12 | Rejection of a patent application after its publication | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20100317 |