[Nexus 7 (2013) Original Android Development] Os_A:
I did Repartition for my DEB which was stock and bootloader locked. Developers option enabled and USB debugging enabled. No screen lock.

It did not come out exactly as described in first post so I will add my guide and comments.

---------------- skip this if you decide not to backup EFS. Be warned: You will have no means to restore IMEI and Mac numbers if something goes wrong in repartitioning if you skip this -------

At first I decided to backup EFS and persist partition. There are prerequisites to do that:

1. Unlock bootloader. Steps:

Boot into system and connect to PC. Run Platform tools and check if device is connected adb devices your tablet must be listed as a device ID

Run adb reboot bootloader to go in bootloader mode

Run fastbooot oem unlock to unlock bootloader

Your device will reset itself and wipe userdata. You will loose everything you put on the tablet.

2. Install TWRP and Root your Nexus 7. Steps:

Boot into OS skipping most of the questions. Enable Developers options and USB debugging to be on safe side.

Copy TWRP image (official from twrp.me! not the one for repartition with UA at end) to your platform-tools folder.

In fastboot mode run fastboot flash Recovery twrp-3.3.1-0-deb.img

I had some trouble rebooting into recovery after that so I re-flashed the recovery to run from RAM fastboot boot Recovery twrp-3.3.1-0-deb.img then copied

twrp-3.3.1-0-deb.img to device. I also copied SuperSU there. Using RAM-running recovery I re-flashed twrp-3.3.1-0-deb.img again and rebooted into it.

Next step is to Root. It was easier for me to use SuperSU.zip. Flash it using TWRP.

There is another guide here on XDA that might be helpful...

3. You Nexus is rooted. You can copy EFS/modem partitions and persist partition in adb now.

Boot into OS. Run

adb shell

su

dd if=/dev/block/mmcblk0p2 of=/sdcard/modemst1.img

wait for end

dd if=/dev/block/mmcblk0p3 of=/sdcard/modemst2.img

wait for end copy

dd if=/dev/block/mmcblk0p4 of=/sdcard/persist.img

wait for end

Now the partition images are somewhere on your storage. I was unable to locate the files from Windows explorer so I rebooted into TWRP and located them using Advanced tab/file manager where I copied them into download folder.

Reboot tablet into Android and using Windows Explorer copy 3 image files into your Windows HDD for safe storage.

--------------- end EFS backup guide ----------------

Now to repartition. Remember that we have official TWRP recovery installed before that. Also copy Clamor's repartition ZIPs into your platform-tools PC folder.

1. Boot into recovery. Check if you have unchecked install prompt for TWRP otherwise OS may not boot. And system modification should be allowed of course too.

Install flo-deb_clamor_repartition.zip. Follow instructions on screen to go to advanced/Terminal and type command accordingly.

2. Phone reboots into recovery but here's a problem in my case: storage is inaccessible for copying files from PC. And we need to copy new TWRP there, the one which supports resized partitions and has UA in the end.

In bootloader mode tell recovery to run from RAM fastboot boot twrp-3.3.1-1_UA-deb.img . Image file should be in your platform-tools folder.

In UA recovery do as per original guide. ( Format everything. (mount errors will not affect formatting!) - In TWRP: Wipe > Format data - Type yes - Once this completes go to: Wipe > Advanced Wipe - Tick all the boxes and wipe. There should be no further mount errors.)

Now you are able to copy twrp-3.3.1-1_UA-deb.img, your ROM zip and GAPPS to storage. Do that. I also copied unified_partition_resize.zip

Install twrp-3.3.1-1_UA-deb.img (remember we are running it from RAM now, so we need to have it on the device) and reboot into recovery. Install ROM.zip.

Next I flashed unified_partition_resize.zip but I am not sure it's necessary. (Supposedly a ROM can re-adjust partitions after flashing so this puts back re-partion scheme). Then flash GAPPS if needed and reboot into OS.

All done. Your Nexus 7 now has bigger system partition and can run lineage 17.1 or any other ROM you prefer.

Many thanks to the developer Clamor