Hardware Tutorial
Updated
Resizing partitions (for Android)
This was shamelessly snatched from https://forum.xda-developers.com/t/guide-resizing-partitions.3955615/
originally posted by user:
@f0mey : This was done as preservation and out of respect for your work. If you disagree with my posting, please let me know and I will remove it immediately.
posting it here because it's shown as the following on xda-developers:
OUTDATED METHOD, CAN RESIZE PARTITIONS DIRECTLY IN "HEKATE"
This is a lost art and absolutely crucial information if you're manually partitioning an eMMC instead of using Hekate.
Don't get me wrong, Hekate is absolutely fantastic for the vast majority,
but if you are like me and want to do it manually, you have to go sifting through code to find the partition sizes and there are a lot of them!
Don't believe me? Check it out here!
https://github.com/CTCaer/hekate/bl...yx_gui/frontend/gui_tools_partition_manager.c
At any rate, this information helped me immensely while carving up my 256G eMMC.
The techniques are pertinent for SDCard partitioning as well.
You will want to reference the #Switchroot wiki for partition sizing:
https://wiki.switchroot.org/en/Documentation/EMMC
Backup the emmc with boot0/1 and rawnand.bin
Have a PC running linux for EMMC perparation.
WARNING: When setting up android, under no circumstances use the sd card as a memory extension, otherwise it will be formatted.
Without further ado, here's f0mey!
---------------------------------------------------
This seems to be a popular question on the release thread, so I thought I would share the method I used to resize the partitions included in the stock switchroot android image.
You can do this a number of ways, I'm lazy tho.. so I went the fastest route I could think of.
All of the following steps were done on a linux virtual machine running the gparted live ISO.. this is not a tutorial how to setup a virtual machine or linux, I'm going to assume you're competent enough to do that as all the steps will require one or the other!
What tools are we going to be using?
The only steps taken prior to what I'm going to share here is that I flashed the 16gb image to my microsd.
So what is the end goal?
First thing I did was capture some data of the default partition layout for reference:
Great now that we have that, lets get stuck into it.
That's it folks, we're done! I know this was a little lengthy... hopefully this helps some of you out!
If you're interested in knowing more in-depth info about hybrid MBR's I came across the following website that contains invaluable information: HERE.
@evil_santa is everywhere…
Jan 3, 2021
Please use This script and This Android image.
The Android image is ready to use don't boot into Twrp. All additional files are included.
originally posted by user:
@f0mey : This was done as preservation and out of respect for your work. If you disagree with my posting, please let me know and I will remove it immediately.
posting it here because it's shown as the following on xda-developers:
OUTDATED METHOD, CAN RESIZE PARTITIONS DIRECTLY IN "HEKATE"
This is a lost art and absolutely crucial information if you're manually partitioning an eMMC instead of using Hekate.
Don't get me wrong, Hekate is absolutely fantastic for the vast majority,
but if you are like me and want to do it manually, you have to go sifting through code to find the partition sizes and there are a lot of them!
Don't believe me? Check it out here!
https://github.com/CTCaer/hekate/bl...yx_gui/frontend/gui_tools_partition_manager.c
At any rate, this information helped me immensely while carving up my 256G eMMC.
The techniques are pertinent for SDCard partitioning as well.
You will want to reference the #Switchroot wiki for partition sizing:
https://wiki.switchroot.org/en/Documentation/EMMC
EMMC Installation guide
Pre requisite
Backup the emmc with boot0/1 and rawnand.bin
Have a PC running linux for EMMC perparation.
Installation
EMMC preparation (for Android and Linux alongside HOS on a larger eMMC)
- If you have a new emmc, install it and write back boot0/1 and the rawnand bin in hekate.
- Under Linux mount the emmc with hekate. Deactivate write protect!
- Check where linux has mounted the emmc (sdb, sdc ...)
- Open gparted and confirm the resize from the emmc gpt table.
- Close gparted.
- Open Terminal and sudo gdisk /dev/sdx (where x is your the device letter)
- Press x=>s=>20=>v=>w=>y to enlarge the gpt table to 20 entries. (If you also want to do linux on the emmc you have to enter 24.)
- Open gparted again.
- HOS has 11 partitions, Android need 9 partitions we have to create them.
- Add the 9 partitions and set the file system as deleted.
Partition | Name | Size |
---|---|---|
Vendor | vendor | 1GiB |
System | APP | 2GiB |
Linux Kernel | LNX | 32MiB |
Recovery (TWRP) | SOS | 64MiB |
Device Tree Reference | DTB | 1MiB |
Encryption* | MDA | 16MiB |
Cache | CAC | 700 MiB |
Miscellaneous | MSC | 3MiB |
Userdata | UDA | Custom |
- If you want to add Linux, add a partition with the label of your choice (e.g.: SWR-UBU for Ubuntu Bionic) and 3 dummy partitions with 1mb unformated. In order to have 24 partitions. gdisk cannot create 21 partitions because the sector is filled automatically (multiple of 4) if there are only 21 partitions on the emmc and not 24 Horizon does not start. The bootloader checks that and Horizon brings up a pink screen.
Flashing the EMMC
- Using dd in terminal flash the following (replacing hekate's Flash Android step)
File | Label |
---|---|
boot.img | LNX |
twrp.img | SOS |
tegra210-icosa.dtb | DTB |
- For linux merge the install image with cat l4t.0* > ubuntu.img and dd it to SWR-UBU (replacing hekate's Flash Linux step)
- Add the release files (bootfiles, ini, lineage zip, any extra zips)
- Boot hekate go to advanced boot entries click on android while you press vol -
- In twrp starts flash the lineage zip and any extra zips.
WARNING: When setting up android, under no circumstances use the sd card as a memory extension, otherwise it will be formatted.
Without further ado, here's f0mey!
---------------------------------------------------
This seems to be a popular question on the release thread, so I thought I would share the method I used to resize the partitions included in the stock switchroot android image.
You can do this a number of ways, I'm lazy tho.. so I went the fastest route I could think of.
All of the following steps were done on a linux virtual machine running the gparted live ISO.. this is not a tutorial how to setup a virtual machine or linux, I'm going to assume you're competent enough to do that as all the steps will require one or the other!
What tools are we going to be using?
- gparted (GUI interface)
- gdisk (terminal)
The only steps taken prior to what I'm going to share here is that I flashed the 16gb image to my microsd.
So what is the end goal?
- Expand the general storage (fat32) partition.
- Expand the android user data partition.
- Allocate a partition for emummc (optional).
- Repair the MBR which we destroy by resizing the partitions.
First thing I did was capture some data of the default partition layout for reference:
Great now that we have that, lets get stuck into it.
- Fire up gparted and you'll be presented with the following popup:
We want to hit the "Fix" button.. this will allow us to utilise all the remaining space on the microsd card.
As soon as we do this tho, there is no turning back.. you'll need to complete the tutorial.
- What we're looking at here is the default layout, note the unallocated space highlighted below:
- The first thing we're going to do is expand the android user data partition (sdd7 in the screenshot above).. Right click "userdata" -> "Resize/move".
I decided to go with 32GB which should be plenty, how large you want to make this partition is entirely up to you.
- The next thing we're going to do is move the partition down the stack, we do this by entering "0" into the "free space following" field.
You'll notice the white box surrounded by the dark purple border has moved position to the far right to reflect your changes.. hit the "resize/move" button and confirm the warning window.
- You can now see the "userdata" partition has moved down the stack, will be resized to 32GB and our unallocated space has moved up.
- We're now going to repeat this process for the remaining android partitions (without resizing tho).. starting from the "dtb" partition and working our way up to "vendor".
- Right click partition -> "Resize/move".
- Modify "free space following" to "0".
- Hit the "Resize/move" button.
- Confirm the warning.
- You get the idea.. repeat this process until you reach the "hos_data" partition.
- Eventually you'll be left with something like this, note the unallocated space is now directly under our "hos_data" partition.
- It's time to expand our fat32 partition, you can drag the black arrow on the right hand side all the way to the end to set the maximum size.
- [EMUMMC USERS ONLY] If you intend on using emummc we can allocate some space for the partition by entering "29856" in the "free space following field", this will automatically reduce the partition size to accommodate the required free space.. this step is completely optional.
- [EMUMMC USERS ONLY] We need to create a new partition (right click "unallocated" -> "new").. the only option we're going to change here is the "file system" field to "unformatted".
- Now is the time to verify all our settings are correct before finally hitting the apply button.. confirm the warning and let it do its thing.
- Before closing gparted, we want to take note of the drive identifier located on the top right of the screen.. mine is "/dev/sdd", we're going to be using the next steps.
- All the remaining steps will be executed using gdisk in a terminal window.. first of which will be the following command:
Code:sudo gdisk /dev/sdd
- Input "r" as a command, this will enter us into the "recovery/transformation" submenu.
- You can output the MBR & partition table by inputting "o" & "p" as commands, since we used gparted the MBR has been modified.. we need to revert this back to ensure everything plays nice.
- Input "h" as a command, this will create a new hybrid MBR to replace the one we destroyed with gparted. If you intend on using emummc we need to add both the hos_data partition (#1) & the emummc partition (#8)..
- You would do this by entering:
Code:1 8
Code:1
- Place EFI GPT parition first in MBR?
Code:N
- Creating entry for GPT partition #1 (MBR partition #1)
Enter an MBR hex code:
Code:EE
- Set bootable flag?
Code:N
- [EMUMMC USERS ONLY] Creating entry for GPT partition #8 (MBR partition #2)
Enter an MBR hex code:
Code:0b
- [EMUMMC USERS ONLY] Set bootable flag?
Code:N
- Unused partition space found. Use one to protect more partitions?
Code:N
- You would do this by entering:
- Great, now lets output the MBR & partition table by inputting the "o" & "p" commands once again to confirm our changes.
Looking good! :good:
- The last thing to do is write our changes, we do this by entering the "w" command.
- Do you want to proceed?
Code:Y
- Do you want to proceed?
That's it folks, we're done! I know this was a little lengthy... hopefully this helps some of you out!
If you're interested in knowing more in-depth info about hybrid MBR's I came across the following website that contains invaluable information: HERE.
Post automatically merged:
@evil_santa is everywhere…
Jan 3, 2021
Please use This script and This Android image.
The Android image is ready to use don't boot into Twrp. All additional files are included.
Last edited by binkinator,