CN106775485B - SD card formatting method and system based on mobile terminal - Google Patents

SD card formatting method and system based on mobile terminal Download PDF

Info

Publication number
CN106775485B
CN106775485B CN201611218014.6A CN201611218014A CN106775485B CN 106775485 B CN106775485 B CN 106775485B CN 201611218014 A CN201611218014 A CN 201611218014A CN 106775485 B CN106775485 B CN 106775485B
Authority
CN
China
Prior art keywords
file system
card
capacity
partition
mobile terminal
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.)
Active
Application number
CN201611218014.6A
Other languages
Chinese (zh)
Other versions
CN106775485A (en
Inventor
彭昔武
邱传波
胡亚军
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Xiamen Luan Chuang Technology Co ltd
Original Assignee
Huizhou TCL Mobile Communication Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Huizhou TCL Mobile Communication Co Ltd filed Critical Huizhou TCL Mobile Communication Co Ltd
Priority to CN201611218014.6A priority Critical patent/CN106775485B/en
Publication of CN106775485A publication Critical patent/CN106775485A/en
Application granted granted Critical
Publication of CN106775485B publication Critical patent/CN106775485B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0638Organizing or formatting or addressing of data
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0629Configuration or reconfiguration of storage systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0638Organizing or formatting or addressing of data
    • G06F3/0644Management of space entities, e.g. partitions, extents, pools
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0646Horizontal data movement in storage systems, i.e. moving data in between storage devices or systems
    • G06F3/0652Erasing, e.g. deleting, data cleaning, moving of data to a wastebasket
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0668Interfaces specially adapted for storage systems adopting a particular infrastructure
    • G06F3/0671In-line storage system
    • G06F3/0673Single storage device
    • G06F3/0679Non-volatile semiconductor memory device, e.g. flash memory, one time programmable memory [OTP]

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Human Computer Interaction (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Telephone Function (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a method and a system for formatting an SD card based on a mobile terminal, wherein the method comprises the following steps: the mobile terminal clears all the partitions of the SD card, and the SD card cleared of all the partitions is divided into a data partition and an expansion partition again; acquiring the capacity of the SD card, and judging whether the capacity of the SD card is larger than a first preset capacity threshold value or not; if the capacity of the file system is larger than the first preset threshold capacity, making the file system for the partition corresponding to the second preset threshold capacity from the storage initial position in the expansion partition, and after the file system is detected to be correct, expanding the capacity of the file system to the whole expansion partition and mounting the file system; and if the capacity is smaller than or equal to the first preset capacity threshold, making the data of the whole expansion partition into a file system, and mounting the file system after checking that the file system is correct. The invention can greatly reduce the time for formatting the high-capacity SD card into the internal storage of the mobile terminal, and provides convenience for a user to transfer the application program data installed on the original mobile phone to the external SD card.

Description

SD card formatting method and system based on mobile terminal
Technical Field
The invention relates to the technical field of mobile terminals, in particular to a method and a system for formatting an SD card based on a mobile terminal.
Background
With the development of life, mobile terminals are increasingly used by people, and mobile terminals such as mobile phones have become indispensable communication tools in life.
At present, Android mobile phone application software is extremely rich. Users often install a lot of software into their mobile phones for experience. The application software installed by the user and the data thereof can be stored in the data partition of the mobile phone. Due to cost considerations, the handset data partitions made by handset manufacturers are typically not too large, perhaps between 4G and 20G. This does not necessarily satisfy the user's requirement to install more complex applications.
Android provides a scheme named as an adoptabe SD card for meeting the increasingly huge storage space requirements of application software. The user can format the large-capacity SD card into internal storage, and then the application program data installed on the original mobile phone is transferred to the external SD card, so that the subsequent mobile phone can use the storage space of the sdcard to store the application program and the data thereof.
With this scheme, the external SD card needs to be first formatted as an ext4 file system. The current default formatting method of Android is too long for SD cards exceeding 16G or more.
When the external SD card is formatted as internal storage, the Android mobile phone can make a file system mirror image of the entire Android _ expand partition of the sdcard and flush the mirror image to an SD storage medium. Due to the limitation of the maximum read-write speed of the SD card, when the capacity of the SD card exceeds 16G, the mirror image of the file system is large, and the writing time of the mirror image is long. Before mounting internal storage, encryption operation needs to be carried out on the written mirror image, and the larger the mirror image is, the longer the encryption time is. Some large capacity, e.g., 64G SD cards, format and write the file system image for even more than 6 minutes, e.g., 64G SD cards, typically over 6 minutes. Such a long formatting time is likely to cause the user to mistakenly think that the formatting process is terminated due to an error.
Accordingly, the prior art is yet to be improved and developed.
Disclosure of Invention
In view of the defects of the prior art, the present invention aims to provide a method and a system for formatting an SD card based on a mobile terminal, and aims to solve the technical problem that in the prior art, when the capacity of the SD card of the mobile terminal is large, before the SD card is mounted in an internal storage, an encryption operation needs to be performed on a written image, and the larger the image is, the longer the encryption time is, so that the time for formatting the SD card into the internal storage is long.
The technical scheme of the invention is as follows:
a method for formatting an SD card based on a mobile terminal, wherein the method comprises the following steps:
A. when the mobile terminal is detected to format the SD card, clearing all the partitions of the SD card, and dividing the SD card cleared of all the partitions into a data partition and an expansion partition again;
B. acquiring the capacity of the SD card, and judging whether the capacity of the SD card is larger than a first preset capacity threshold value or not;
C. if the capacity of the SD card is larger than a first preset capacity threshold value, a file system is manufactured for a partition corresponding to a second preset threshold value capacity from a storage initial position in the expansion partition, after the file system detects that no error exists, the file system is expanded to the whole expansion partition, and the expanded file system is mounted;
D. and if the capacity of the SD card is less than or equal to a first preset capacity threshold value, making the data of the whole extended partition into a file system, and mounting the file system after checking the file system without errors.
The SD card formatting method based on the mobile terminal is characterized in that the mobile terminal is a mobile terminal using an Android system.
The SD card formatting method based on the mobile terminal comprises the following specific steps:
a1, when detecting that the mobile terminal formats the SD card, clearing all the partitions of the SD card by using sgdisk;
a2, and repartitioning the SD card which clears all the partitions into an android _ metadata data partition and an android _ extended partition by using sgdisk.
The SD card formatting method based on the mobile terminal, wherein the step C specifically includes the steps of:
c1, if the capacity of the SD card is detected to be larger than a first preset capacity threshold value, an ext4 file system is made according to the make _ ext4fs for the partition corresponding to the second preset threshold value capacity from the storage starting position in the android _ extended partition;
c2, checking the correctness of the ext4 file system according to e2 fsck;
c3, when the correctness check of the ext4 file system is detected to be correct, expanding the ext4 file system to the whole android _ expanded expansion partition according to resize2 fs;
c4, and mounting the expanded ext4 file system.
The SD card formatting method based on the mobile terminal, wherein the step D specifically comprises the following steps:
d1, if the capacity of the SD card is less than or equal to a first preset capacity threshold, making an ext4 file system for the whole android _ expand partition according to make _ ext4 fs;
d2, checking the correctness of the ext4 file system according to e2 fsck;
d3, when the correctness check of the ext4 file system is detected to be error-free, mounting the expanded ext4 file system.
A system for SD card formatting based on a mobile terminal, wherein the system comprises:
the SD card partition resetting module is used for clearing all partitions of the SD card when the mobile terminal is detected to format the SD card, and dividing the SD card cleared of all the partitions into a data partition and an expansion partition again;
the SD card capacity obtaining and judging module is used for obtaining the capacity of the SD card and judging whether the capacity of the SD card is larger than a first preset capacity threshold value or not;
the first formatting control module is used for manufacturing a file system for a partition corresponding to the capacity of a second preset threshold value from a storage initial position in the expansion partition if the capacity of the SD card is larger than a first preset capacity threshold value, expanding the file system to the whole expansion partition after the file system detects that the file system is correct, and mounting the expanded file system;
and the second formatting control module is used for making the data of the whole extended partition into a file system if the capacity of the SD card is less than or equal to the first preset capacity threshold, and mounting the file system after the file system is checked to be correct.
The SD card formatting system based on the mobile terminal is characterized in that the mobile terminal is a mobile terminal using an Android system.
The SD card formatting system based on the mobile terminal, wherein the SD card partition resetting module specifically includes:
the SD card partition clearing unit is used for clearing all partitions of the SD card by using sgdisk when detecting that the mobile terminal formats the SD card;
and the SD card partition re-dividing unit is used for re-dividing the SD card for clearing all the partitions into the android _ metadata data partition and the android _ extended partition by using the sgdisk.
The system for formatting the SD card based on the mobile terminal, wherein the first formatting control module specifically includes:
the first file system manufacturing unit is used for manufacturing an ext4 file system for a partition corresponding to the second preset threshold capacity from the storage starting position in the android _ extended partition according to make _ ext4fs if the capacity of the SD card is detected to be larger than the first preset capacity threshold;
a first file system checking unit, configured to check correctness of the ext4 file system according to e2 fsck;
the file system capacity expansion unit is used for expanding the ext4 file system to the whole android _ expand partition according to resize2fs after the correctness check of the ext4 file system is detected to be correct;
and the first file system mounting unit is used for mounting the expanded ext4 file system.
The system for formatting the SD card based on the mobile terminal, wherein the second formatting control module specifically includes:
a second file system making unit, configured to make an ext4 file system for the entire android _ extended partition according to make _ ext4fs if the capacity of the SD card is less than or equal to a first predetermined capacity threshold;
the second file system checking unit is used for checking the correctness of the ext4 file system according to e2 fsck;
and the second file system mounting unit is used for mounting the expanded ext4 file system after detecting that the correctness check of the ext4 file system is correct.
The invention provides a method and a system for formatting an SD card based on a mobile terminal, which can greatly reduce the time for formatting a large-capacity SD card into internal storage of the mobile terminal, provide convenience for a user to transfer application program data installed on an original mobile phone to an external SD card, and enable a subsequent mobile phone to use the storage space of the external SD card for storing application programs and data thereof.
Drawings
Fig. 1 is a flowchart of a method for formatting an SD card based on a mobile terminal according to a preferred embodiment of the present invention.
Fig. 2 is a functional block diagram of a preferred embodiment of the system for formatting an SD card based on a mobile terminal according to the present invention.
Detailed Description
In order to make the objects, technical solutions and effects of the present invention clearer and clearer, the present invention is described in further detail below. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
The present invention also provides a flowchart of a preferred embodiment of a method for formatting an SD card based on a mobile terminal, as shown in fig. 1, the method includes the steps of:
s100, when the mobile terminal is detected to format the SD card, clearing all the partitions of the SD card, and dividing the SD card cleared of all the partitions into a data partition and an expansion partition again.
In specific implementation, the mobile terminal is a mobile terminal using an Android system. The mobile terminal includes but is not limited to a mobile phone, a tablet computer and the like. Android provides a scheme named as an adoptabe SD card for meeting the increasingly huge storage space requirements of application software. The user can format the large-capacity SD card into internal storage, and then the application program data installed on the original mobile phone is transferred to the external SD card, so that the sdcard can be used as the storage position for installing the application program and the data of the mobile phone subsequently.
For the internal storage of the large-capacity SD card format, all the partitions of the SD card are cleared firstly, and then the SD card cleared of all the partitions is divided into a data partition and an extended partition again.
In a further embodiment, step S100 specifically includes the steps of:
s101, when detecting that the mobile terminal formats the SD card, clearing all partitions of the SD card by using sgdisk;
s102, the SD card which clears all the partitions is divided into an android _ metadata data partition and an android _ extended partition again by using the sgdisk.
In specific implementation, Android formats sdcard into two partitions when formatting sdcard: an android _ meta partition and an android _ expand partition. The android _ meta partition only occupies the space of the sdcard device 16M, and the rest of the space belongs to the android _ expand space for users to install programs and data thereof. Specifically, sgdisk is adopted to clear all partitions of the original SD card, and the SD card after clearing all the partitions is divided into an android _ metadata data partition and an android _ extended partition again. The sgdisk is a tool for creating a GPT partition, and a specific creation method is the prior art and is not described herein again. The GPT is an abbreviation of a GUID Partition Table, the Chinese translation is a GUID disk Partition Table, the meaning of the Table is a globally unique identification disk Partition Table, and the Table is a standard of structural layout of a Partition Table of an entity hard disk.
S200, acquiring the capacity of the SD card, and judging whether the capacity of the SD card is larger than a first preset capacity threshold value; if the capacity of the SD card is greater than the first predetermined capacity threshold, step S300 is executed, and if the capacity of the SD card is less than or equal to the first predetermined capacity threshold, step S400 is executed.
In particular, when the SD card having a capacity exceeding 16G is formatted as an internal memory, the formatting time is increased, and thus the first predetermined capacity threshold is preferably set to 16G. Therefore, whether the capacity of the SD card is larger than 16G or not is judged, and different formatting processes are executed according to the judgment result.
S300, making a file system for the partition corresponding to the second preset threshold capacity from the storage initial position in the expansion partition, expanding the file system to the whole expansion partition after the file system is detected to be correct, and mounting the expanded file system.
In specific implementation, when the SD card with the capacity exceeding 16G is formatted into the internal storage, the file system is only manufactured for the first 4G of the android _ extended partition and written into the SD, the data volume written into the SD card is reduced, and the whole formatting time is controlled. After encryption, before the file system is mounted, the reduced file system is re-expanded to the actual size of the android _ expanded partition by means of resize2fs or the like, so that the system can normally operate the entire SD card (i.e., the capacity of the SD card is restored to normal). Wherein the resize2fs program redefines the ext2, ext3 or ext4 file systems. Can be used to expand or contract a file system that is not mounted on the device. If this file system is mounted, it can be used to expand the mounted file system, assuming the kernel supports online redefinition of the size.
The mounting means that no partition is arranged under linux, all devices including a disk are identified as a block device file, various device interface files are arranged under/dev, and the device can be operated after the device interface file corresponding to the disk is mounted in a folder. Therefore, after the file system is mounted, a subsequent user can use the SD card as internal storage.
In a further embodiment, step S300 specifically includes the steps of:
s301, if the capacity of the SD card is detected to be larger than a first preset capacity threshold value, an ext4 file system is manufactured according to the make _ ext4fs for a partition corresponding to the capacity of a second preset threshold value from the storage starting position in the android _ extended partition;
s302, checking the correctness of the ext4 file system according to e2 fsck;
s303, when the correctness check of the ext4 file system is detected to be correct, expanding the ext4 file system to the whole android _ expanded expansion partition according to resize2 fs;
s304, mounting the expanded ext4 file system.
In specific implementation, the second predetermined threshold capacity is 2G or 4G, preferably 4G. When the capacity of the SD card is detected to be larger than 16G, making an ext4 file system only for the first 4G of the android _ extended partition by using make _ ext4fs, and checking the correctness of the ext4 file system according to e2 fsck; when the correctness check of the ext4 file system is detected, the file system is expanded to each android _ expanded partition by using resize2fs before mount of mount. e2fsck is a tool to check the correctness of file systems such as ext2, ext3, ext4, etc., and different returned values represent different meanings. Specifically, the return value and the representative value after the e2fsck is executed are as follows: 0 means that no error occurred. 1 represents that the file system is in error and has been corrected. 2 represents that the file system is in error and has been corrected. 4 represents a file system error, but no correction. 8 represents an error in operation. 16 represents the syntax used in error. 128 represents a shared function library error. Wherein the ext4 file system is a Fourth generation extended file system (english: four extended file system, abbreviated as ext 4) which is a log file system under Linux system and is a successor version of the ext3 file system. Making ext4 file systems requires the use of make _ ext4fs commands, such as:
#make_ext4fs -s -l 314572800 -a root -L linux./rootfs_qt.img./root
after execution, the root file is packaged into a rootfs _ qt.
For the SD card with the capacity exceeding 16G, the file system is only made by using the make _ ext4fs for the first 4G during formatting, and the make _ ext4fs can quickly complete the making of the file system. The time it takes to expand the partition with resize2fs is only a few seconds or so. Therefore, the invention can greatly reduce the time for formatting the SD card into the internal storage of the mobile phone.
By using the scheme, the 64G SD card is tested, the original formatting time is probably 6 minutes, and the optimized scheme is basically within 1 minute.
S400, making a file system from the data of the whole extended partition, and mounting the file system after checking the file system to be correct.
In specific implementation, if the capacity of an SD card is less than 16G, a file system is directly manufactured for the whole android _ expanded partition, and the file system is mounted after being checked to be correct.
In a further embodiment, step S400 specifically includes the steps of:
s401, if the capacity of the SD card is smaller than or equal to a first preset capacity threshold value, an ext4 file system is manufactured for the whole android _ extended partition according to make _ ext4 fs;
s402, checking the correctness of the ext4 file system according to e2 fsck;
s403, when the fact that the correctness check of the ext4 file system is correct is detected, the expanded ext4 file system is mounted.
In specific implementation, after all partitions are cleared according to the sgdisk, the sgdisk creates an android _ metadata partition and an android _ extended partition, creates an ext4 file system for the whole android _ extended partition according to make _ ext4fs, checks the ext4 file system by e2fsck, and mounts the ext4 file system by Mount.
In an exemplary embodiment, the apparatus may be implemented by one or more Application Specific Integrated Circuits (ASICs), Digital Signal Processors (DSPs), Digital Signal Processing Devices (DSPDs), Programmable Logic Devices (PLDs), Field Programmable Gate Arrays (FPGAs), controllers, micro-controllers, microprocessors or other electronic components for performing the above-described methods.
In an exemplary embodiment, a non-transitory computer readable storage medium comprising instructions, such as a memory comprising instructions, executable by a processor of an apparatus to perform the above method is also provided. For example, the non-transitory computer readable storage medium may be a ROM, a Random Access Memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.
The present invention also provides a functional schematic block diagram of a preferred embodiment of a system for SD card formatting based on a mobile terminal, as shown in fig. 2, wherein the system comprises:
the SD card partition resetting module 100 is configured to clear all partitions of the SD card when detecting that the mobile terminal formats the SD card, and re-divide the SD card cleared of all partitions into a data partition and an extended partition; as described in the method embodiments.
The SD card capacity obtaining and judging module 200 is configured to obtain a capacity of the SD card, and judge whether the capacity of the SD card is greater than a first predetermined capacity threshold; as described in the method embodiments.
The first formatting control module 300 is configured to, if the capacity of the SD card is greater than a first predetermined capacity threshold, create a file system for a partition corresponding to a second predetermined threshold capacity from a storage start position in the extended partition, after the file system detects that there is no error, expand the file system to the entire extended partition, and mount the expanded file system; as described in the method embodiments.
The second formatting control module 400 is configured to make a file system from the data of the entire extended partition if the capacity of the SD card is less than or equal to the first predetermined capacity threshold, and mount the file system after checking that the file system is error-free; as described in the method embodiments.
The SD card formatting system based on the mobile terminal is characterized in that the mobile terminal is a mobile terminal using an Android system; as described in the method embodiments.
The SD card formatting system based on the mobile terminal, wherein the SD card partition resetting module specifically includes:
the SD card partition clearing unit is used for clearing all partitions of the SD card by using sgdisk when detecting that the mobile terminal formats the SD card; as described in the method embodiments.
The SD card partition repartitioning unit is used for repartitioning the SD card which clears all the partitions into an android _ metadata data partition and an android _ extended partition by using sgdisk; as described in the method embodiments.
The system for formatting the SD card based on the mobile terminal, wherein the first formatting control module specifically includes:
the first file system manufacturing unit is used for manufacturing an ext4 file system for a partition corresponding to the second preset threshold capacity from the storage starting position in the android _ extended partition according to make _ ext4fs if the capacity of the SD card is detected to be larger than the first preset capacity threshold; as described in the method embodiments.
A first file system checking unit, configured to check correctness of the ext4 file system according to e2 fsck; as described in the method embodiments.
The file system capacity expansion unit is used for expanding the ext4 file system to the whole android _ expand partition according to resize2fs after the correctness check of the ext4 file system is detected to be correct; as described in the method embodiments.
The first file system mounting unit is used for mounting the expanded ext4 file system; as described in the method embodiments.
The system for formatting the SD card based on the mobile terminal, wherein the second formatting control module specifically includes:
a second file system making unit, configured to make an ext4 file system for the entire android _ extended partition according to make _ ext4fs if the capacity of the SD card is less than or equal to a first predetermined capacity threshold; as described in the method embodiments.
The second file system checking unit is used for checking the correctness of the ext4 file system according to e2 fsck; as described in the method embodiments.
The second file system mounting unit is used for mounting the expanded ext4 file system after detecting that the correctness check of the ext4 file system is correct; as described in the method embodiments.
In summary, the present invention provides a method and a system for formatting an SD card based on a mobile terminal, wherein the method comprises: the mobile terminal clears all the partitions of the SD card, and the SD card cleared of all the partitions is divided into a data partition and an expansion partition again; acquiring the capacity of the SD card, and judging whether the capacity of the SD card is larger than a first preset capacity threshold value or not; if the capacity of the file system is larger than the first preset threshold capacity, making the file system for the partition corresponding to the second preset threshold capacity from the storage initial position in the expansion partition, and after the file system is detected to be correct, expanding the capacity of the file system to the whole expansion partition and mounting the file system; and if the capacity is smaller than or equal to the first preset capacity threshold, making the data of the whole expansion partition into a file system, and mounting the file system after checking that the file system is correct. The invention can greatly reduce the time for formatting the high-capacity SD card into the internal storage of the mobile terminal, and provides convenience for a user to transfer the application program data installed on the original mobile phone to the external SD card.
It is to be understood that the invention is not limited to the examples described above, but that modifications and variations may be effected thereto by those of ordinary skill in the art in light of the foregoing description, and that all such modifications and variations are intended to be within the scope of the invention as defined by the appended claims.

Claims (10)

1. A method for formatting an SD card based on a mobile terminal is characterized by comprising the following steps:
A. when the mobile terminal is detected to format the SD card, clearing all the partitions of the SD card, and dividing the SD card cleared of all the partitions into a data partition and an expansion partition again;
B. acquiring the capacity of the SD card, and judging whether the capacity of the SD card is larger than a first preset capacity threshold value or not;
C. if the capacity of the SD card is larger than a first preset capacity threshold value, a file system is manufactured for a partition corresponding to a second preset threshold value capacity from a storage initial position in the expansion partition, after the file system detects that no error exists, the file system is expanded to the whole expansion partition, and the expanded file system is mounted; the file system comprises a file system mirror image;
D. and if the capacity of the SD card is less than or equal to a first preset capacity threshold value, making the data of the whole extended partition into a file system, and mounting the file system after checking the file system without errors.
2. The method for formatting the SD card based on the mobile terminal according to claim 1, wherein the mobile terminal is a mobile terminal using Android system.
3. The method for formatting the SD card based on the mobile terminal according to claim 2, wherein the step a specifically comprises the steps of:
a1, when detecting that the mobile terminal formats the SD card, clearing all the partitions of the SD card by using sgdisk;
a2, and repartitioning the SD card which clears all the partitions into an android _ metadata data partition and an android _ extended partition by using sgdisk.
4. The SD card formatting method based on mobile terminal according to claim 3, wherein said step C comprises the steps of:
c1, if the capacity of the SD card is detected to be larger than a first preset capacity threshold value, an ext4 file system is made according to the make _ ext4fs for the partition corresponding to the second preset threshold value capacity from the storage starting position in the android _ extended partition;
c2, checking the correctness of the ext4 file system according to e2 fsck;
c3, when the correctness check of the ext4 file system is detected to be correct, expanding the ext4 file system to the whole android _ expanded expansion partition according to resize2 fs;
c4, and mounting the expanded ext4 file system.
5. The SD card formatting method based on mobile terminal as claimed in claim 3, wherein said step D specifically comprises the steps of:
d1, if the capacity of the SD card is less than or equal to a first preset capacity threshold, making an ext4 file system for the whole android _ expand partition according to make _ ext4 fs;
d2, checking the correctness of the ext4 file system according to e2 fsck;
d3, when the correctness check of the ext4 file system is detected to be error-free, mounting the expanded ext4 file system.
6. A system for SD card formatting based on a mobile terminal, the system comprising:
the SD card partition resetting module is used for clearing all partitions of the SD card when the mobile terminal is detected to format the SD card, and dividing the SD card cleared of all the partitions into a data partition and an expansion partition again;
the SD card capacity obtaining and judging module is used for obtaining the capacity of the SD card and judging whether the capacity of the SD card is larger than a first preset capacity threshold value or not;
the first formatting control module is used for manufacturing a file system for a partition corresponding to the capacity of a second preset threshold value from a storage initial position in the expansion partition if the capacity of the SD card is larger than a first preset capacity threshold value, expanding the file system to the whole expansion partition after the file system detects that the file system is correct, and mounting the expanded file system; the file system comprises a file system mirror image;
and the second formatting control module is used for making the data of the whole extended partition into a file system if the capacity of the SD card is less than or equal to the first preset capacity threshold, and mounting the file system after the file system is checked to be correct.
7. The system according to claim 6, wherein the mobile terminal is a mobile terminal using Android system.
8. The system for SD card formatting based on mobile terminal according to claim 7, wherein the SD card partition resetting module specifically comprises:
the SD card partition clearing unit is used for clearing all partitions of the SD card by using sgdisk when detecting that the mobile terminal formats the SD card;
and the SD card partition re-dividing unit is used for re-dividing the SD card for clearing all the partitions into the android _ metadata data partition and the android _ extended partition by using the sgdisk.
9. The system for formatting an SD card based on a mobile terminal as recited in claim 8, wherein the first formatting control module specifically comprises:
the first file system manufacturing unit is used for manufacturing an ext4 file system for a partition corresponding to the second preset threshold capacity from the storage starting position in the android _ extended partition according to make _ ext4fs if the capacity of the SD card is detected to be larger than the first preset capacity threshold;
a first file system checking unit, configured to check correctness of the ext4 file system according to e2 fsck;
the file system capacity expansion unit is used for expanding the ext4 file system to the whole android _ expand partition according to resize2fs after the correctness check of the ext4 file system is detected to be correct;
and the first file system mounting unit is used for mounting the expanded ext4 file system.
10. The system for formatting an SD card based on a mobile terminal as recited in claim 8, wherein the second formatting control module specifically comprises:
a second file system making unit, configured to make an ext4 file system for the entire android _ extended partition according to make _ ext4fs if the capacity of the SD card is less than or equal to a first predetermined capacity threshold;
the second file system checking unit is used for checking the correctness of the ext4 file system according to e2 fsck;
and the second file system mounting unit is used for mounting the expanded ext4 file system after detecting that the correctness check of the ext4 file system is correct.
CN201611218014.6A 2016-12-26 2016-12-26 SD card formatting method and system based on mobile terminal Active CN106775485B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201611218014.6A CN106775485B (en) 2016-12-26 2016-12-26 SD card formatting method and system based on mobile terminal

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201611218014.6A CN106775485B (en) 2016-12-26 2016-12-26 SD card formatting method and system based on mobile terminal

Publications (2)

Publication Number Publication Date
CN106775485A CN106775485A (en) 2017-05-31
CN106775485B true CN106775485B (en) 2021-02-19

Family

ID=58926733

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201611218014.6A Active CN106775485B (en) 2016-12-26 2016-12-26 SD card formatting method and system based on mobile terminal

Country Status (1)

Country Link
CN (1) CN106775485B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107506496B (en) * 2017-09-28 2021-10-22 北京小米移动软件有限公司 Defragmentation method, defragmentation device and computer-readable storage medium
CN110781030A (en) * 2019-09-09 2020-02-11 晶晨半导体(深圳)有限公司 Backup method for user data in android system upgrading process
CN110941843B (en) * 2019-11-22 2022-03-29 北京明略软件系统有限公司 Encryption implementation method, device, equipment and storage medium
CN111858175A (en) * 2020-07-20 2020-10-30 上海云轴信息科技有限公司 Method and equipment for backing up cloud platform data based on mobile storage device

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103412773A (en) * 2013-08-08 2013-11-27 华为终端有限公司 Method and device for obtaining files
CN103605540A (en) * 2013-11-18 2014-02-26 四川长虹电器股份有限公司 Flash mirror fast writing method based on Android system
WO2014143245A1 (en) * 2013-03-15 2014-09-18 Xilinx, Inc. Multi-boot of fallback boot of a system-on-chip using a file-based boot device

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104866331B (en) * 2014-02-25 2018-06-01 中国电信股份有限公司 The method and apparatus of application is installed, called on mobile terminals

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2014143245A1 (en) * 2013-03-15 2014-09-18 Xilinx, Inc. Multi-boot of fallback boot of a system-on-chip using a file-based boot device
CN103412773A (en) * 2013-08-08 2013-11-27 华为终端有限公司 Method and device for obtaining files
CN103605540A (en) * 2013-11-18 2014-02-26 四川长虹电器股份有限公司 Flash mirror fast writing method based on Android system

Also Published As

Publication number Publication date
CN106775485A (en) 2017-05-31

Similar Documents

Publication Publication Date Title
CN106775485B (en) SD card formatting method and system based on mobile terminal
US10423585B2 (en) Method and device for making differential upgrade package, and method and device for system differential upgrading
KR20080096572A (en) Multi-protocol removable storage device
CN110096314B (en) Interface initialization method, device, equipment and computer readable storage medium
CN106484719B (en) Method and terminal for expanding mobile phone storage
CN110716845B (en) Log information reading method of Android system
CN111258666A (en) Reading method and device of computer file, computer system and storage medium
EP4049130A1 (en) Updating a metadata structure for a firmware update
CN104407890A (en) Method for starting Android system from OTG (On-The-Go) equipment
GB2538621A (en) Verification of storage media upon deployment
US11226757B2 (en) Hot plug memory device data protection method
CN104866388B (en) Data processing method and device
WO2015117356A1 (en) Start-up method and communication terminal
CN109460187B (en) Verification method and verification terminal for data consistency of qcow2 file
US9588884B2 (en) Systems and methods for in-place reorganization of device storage
WO2020088263A1 (en) Identification method and module for hot plugging of sd card, and electronic device
CN106708541A (en) Version upgrading processing method and apparatus
CN115168119A (en) PCIE (peripheral component interface express) link detection method, device and medium for server
CN115757099A (en) Automatic test method and device for platform firmware protection recovery function
CN114968753A (en) Equipment upgrading test method, medium, electronic equipment and test system
CN115291963A (en) Method for configuring hardware resources, electronic device and storage medium
CN114968297A (en) OTA (over the air) upgrading method, electronic equipment and chip system
CN111026584A (en) Device, method and equipment for solving key value database file damage
CN111737223A (en) File copying method, device, equipment and storage medium
CN111651177A (en) Android platform-based number writing method and device and computer readable medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20230827

Address after: Room 1203, No. 2 Houkenanli, Haicang District, Xiamen City, Fujian Province, 361000

Patentee after: Xiamen Luan Chuang Technology Co.,Ltd.

Address before: 516006 Zhongkai hi tech Zone, Huizhou, Guangdong, 86 Chang seven Road West

Patentee before: HUIZHOU TCL MOBILE COMMUNICATION Co.,Ltd.