/// <summary> /// Resizes the sdcard partition (this should be non-destructive to the data) /// </summary> /// <param name="begin">Where the new partition will start</param> /// <param name="end">Where the new partition will end</param> public void ResizeSdcard(int begin, int end) { _parent.WriteToConsole("Resizing /sdcard partition (begin=" + begin + ", end=" + end + ")...\n"); AdbCommand.ExecutePartitionCommand(Constants.PARTED_RESIZE + Constants.SDCARD_PART_NUMBER + " " + begin + " " + end, _parent); _parent.WriteToConsole("Sdcard resized successfully.\n\n"); }
/// <summary> /// Preps the device for repartitioning by unmounting all partitions and deleting the cache /// and data partitions. /// </summary> public void RepartitionPreparation() { //Unmount the data, cache, and sdcard partitions since we can't modify them //if they're mounted. AdbCommand.ExecuteShellCommand(Constants.UMOUNT_CACHE); AdbCommand.ExecuteShellCommand(Constants.UMOUNT_DATA); AdbCommand.ExecuteShellCommand(Constants.UMOUNT_SDCARD); //Remove the data and cache partitions up front AdbCommand.ExecutePartitionCommand(Constants.PARTED_REMOVE + Constants.CACHE_PART_NUMBER, _parent); AdbCommand.ExecutePartitionCommand(Constants.PARTED_REMOVE + Constants.DATA_PART_NUMBER, _parent); }
/// <summary> /// Recreates the /cache partition /// </summary> /// <param name="begin">Where the partition will start</param> /// <param name="end">Where the partition will end</param> public void RepartitionCache(int begin, int end) { _parent.WriteToConsole("Repartitioning /cache (begin=" + begin + ", end=" + end + ")...\n"); AdbCommand.ExecutePartitionCommand(Constants.PARTED_MAKE_EXTFS + begin + " " + end, _parent); AdbCommand.ExecutePartitionCommand(Constants.PARTED_NAME + Constants.CACHE_PART_NUMBER + " cache", _parent); _parent.WriteToConsole("Running e2fsck and tune2fs...\n"); AdbCommand.ExecutePartitionCommand(Constants.TUNE2FS_EXT3 + Constants.CACHE_DEVICE, _parent); AdbCommand.ExecutePartitionCommand(Constants.E2FSCK + Constants.CACHE_DEVICE, _parent); AdbCommand.ExecutePartitionCommand(Constants.TUNE2FS_EXT4 + Constants.CACHE_DEVICE, _parent); AdbCommand.ExecutePartitionCommand(Constants.E2FSCK + Constants.CACHE_DEVICE, _parent); _parent.WriteToConsole("Cache repartitioning complete.\n\n"); }