Android通过adb快速恢复出⼚设置
⼀
⼀条命令:
adb reboot bootloader && fastboot erase userdata && fastboot erase cache && fastboot reboot
adb reboot bootloader
check if device available
fastboot devices
remove user data
fastboot erase userdata
remove cache
fastboot erase cache
reboot device
fastboot reboot
⼆
adb reboot recovery
擦除data数据
重启⼿机
Fastboot is a powerful tool bundled with Google Android SDK and also an engineering protocol that helps to write data directly to your phone’s flash memory. Since it directly writes to the phone’s flash memory, It can start on your device even before Android OS loads, even under the scenario when Android isn’t installed at all.
The phone needs to be booted into “Bootloader mode” to use the Fastboot commands. It enables access on all your device partitions. Hence, one can patch those partitions by flashing firmware, recoveries, bootloader etc.
Fastboot is most commonly used for unlocking the bootloader or to establish communication with hardware when the software has failed or bricked. If you are familiar with rooting and modding your android phone, you must have heard a lot about ADB and fastboot. If you are new to this scene, we’d recommend checking our beginners guide to rooting.
Page Contents [show]
Popular Fastboot Commands
When you’re working on the bootloader mode, ADB commands will no longer work, as the device is not booted into Android OS. Hence, the Android debugging tools can’t communicate to the phone. As mentioned above, the Fastboot commands would work even if the OS isn’t booted, provided your device is booted into Bootloader/Fastboot mode. These are probably the most useful tools available which will come to rescue when you brick your device or when you want to replace your device partitions.
To execute the below mentioned commands, you’ll also need to have Fastboot installed on your computer system, You can follow our guide to install ADB and Fastboot for the installation. Now that you have Fastboot working on your system, you can check the below commands. To make it easier,
we’ve added a short description, syntax and an example.
Before you begin executing the commands:
ADB and Fastboot installed on your system
Boot your device into fastboot mode/bootloader mode. (This method requires ADB, However, you can also check our guide which has key combinations to boot your device into fastboot mode.)
Enable USB Debugging, to do so, You’ll need to enable Android developer options:
Go to Settings > About > Build Number and Tap for 7 times.
You’ll see a message “You’re a developer now.”
Come back to Settings > Developer Options > USB debugging and enable it.
Fastboot devices command
Type Fastboot devices in the command prompt and result should be a serial number, similar to the adb devices command. If entering this command shows your device name with a serial number, it im
plies that your phone is good to go for fastboot operations. However, if the result is empty then you might want to check the fastboot installation and drivers.
Syntax:
fastboot devices
Fastboot OEM unlock command
The Fastboot OEM unlock command is the most popular command, it is your key to unlock the bootloader of your device. Although this command works with most of the devices, it won’t work for some brands. If your OEM enables fastboot mode, then you will be able to unlock your phone with this command.
Brands such as Google Pixel, Google Nexus, OnePlus, HTC, Motorola, and etc. usually support bootloader unlock with this command. If you own a different device, you’d have to follow separate guides to do the trick. Also, unlocking the bootloader voids the warranty for some brands, so only unlock if you are willing to risk your warranty.
Syntax:
fastboot oem unlock
PS: Running the unlock command in the command prompt will wipe your entire data on the phone. So please proceed carefully. We won’t be held responsible for your data loss!
Fastboot OEM lock command
The Fastboot OEM unlock command is opposite of the OEM unlock command. Using this command, you can lock your bootloader and go back to the stock factory mode.
Just for information: This command could help you with your warranty even after you’ve unlocked it. Because in most parts of the world, the representatives at service centers think that a locked bootloader means the device wasn’t unlocked. Although there are ways to find out if a device was previously unlocked, most of the service centers don’t get that far. But if they find out, don’t blame us!
Syntax:
fastboot oem lock
Fastboot Flash command
The Fastboot flash command would help you to flash ZIP files. Companies like OnePlus, release the flashable ZIP file of the upcoming firmware for their testers. So, one can simply download the ZIP file, place it in the folder on their PC, open Command window from that folder and flash the zip. Normally, fastboot images are flashed in this way.
Note: It is always recommended to place the zip files in the same folder of your ADB binaries so that you do not need to specify the path or you can alternatively open the command window from that particular folder.
Syntax:
fastboot flash %FILENAME.ZIP%
Example:
fastboot flash newfirmware.zip
Fastboot Flash Recovery command
The Fastboot flash recovery is a powerful fastboot command which is used to flash recovery images.
This will patch your recovery partition with a new image. When we install a custom recovery such as TWRP on our device, this is the command we use. This would replace the stock recovery with the custom recovery.
android最新版Syntax:
fastboot flash recovery %FILENAME.IMG%
Example:
fastboot flash recovery twrp.img
Fastboot Flash Boot command
The boot image contains the kernel of your device. You can use the Fastboot Flash boot command to replace the stock kernel with a custom kernel of your choice. This command would replace the boot partition of your device. It might look simple, but could be risky if you flash a wrong boot image. There are chances that your device might not boot or might get stuck in a Bootloop. The only way to recover if you mess up with this would be flashing the stock boot image.
Syntax:
fastboot flash boot %FILENAME.IMG%
Example:
fastboot flash boot bootimage.img
Fastboot Erase command
As the name says, this command would erase items from your device. By using the Fastboot erase command you’ll be able to wipe data from different partitions on your device. This command is generally used before flashing a new ROM, as it wipes the existing data and makes space for the new files to be written. This command deletes all your data from the partitions you’ve mentioned in the command, so it’s always a good idea to take a backup before you run it.
Syntax:
fastboot erase %PARTITION NAME%
Example:
To erase system partition
fastboot erase system
To erase boot partition
fastboot erase boot
To erase cache partition
fastboot erase cache
To erase user data partition
fastboot erase userdata
To erase recovery partition
fastboot erase recovery
Fastboot Format command
If you want to completely format the flash partitions of your device, you can use Fastboot format com
mand. This will allocate new blocks of data to your device partition and that makes it different from fastboot erase command. A full backup of device data is always recommended as it can wipe your entire data.
Syntax:
fastboot format %PARTITION NAME%
Example:
To format system partition
fastboot format system
To format boot partition
fastboot format boot
To format cache partition
fastboot format cache
To format user data partition
fastboot format userdata
To format recovery partition
fastboot format recovery
Fastboot Reboot/reboot-bootloader commands
The Fastboot reboot command will help you to boot your device normally to OS. On entering the reboot command you’ll be booting the system partition of your device. Whereas the reboot-bootloader command will take you back to bootloader mode followed by a reboot. Syntax:
To reboot your device
fastboot reboot
To reboot your device to fastboot mode
fastboot reboot-bootloader
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论