[AT&T LG Optimus G] alastair53:
DISCLAIMER: THIS IS VERY DANGEROUS COMPARED TO A NORMAL ROM FLASH. DO NOT DO THIS IF YOU DON'T KNOW WHAT YOU'RE DOING OTHER THAN FLASHING ROMS.

IF SOMETHING GOES WRONG, YOU HAVE ONLY YOURSELF TO BLAME. YOU HAVE BEEN WARNED.[/B]

To convert to Nexus 4

First off, there are a few issues.

-SDCard doesn't work.

-Capacitive buttons aren't working. No known way to fix it.

First off, lets flash the N4 Rom.

1) Install LGNPST - Use tSilenzio's AutoLGNPST - http://www.oudhitsquad.com/android/LGE/Firmware/Tools/AutoLGNPST-tSilenzio.zip

2) Download the Nexus 4 Image - https://www.androidfilehost.com/?fid=9390248398092765463

3) Rename the extracted .tot file to a .bin file

4) Put the phone in Download mode. Volume Up + Volume Down While inserting USB cable.

5) Open LGNPST and select the phone - Should be Com[Number]

6) In the DLL section, select LGNPST_LS970.dll

7) In the file selection, select the previously renamed Nexus 4 bin file.

8) Start the flashing process and hold your breath.

9) When it hits 67%, your phone should start booting. DO NOT UNPLUG YET.

10) At 85%, an error will occur saying that the phone was unplugged. Ignore it and close LGNPST. The image is fully flashed.

11) Hold Volume Up + Power to put the phone into FASTBOOT mode.

12) Download the recovery from here and place it into your fastboot directory. - http://xdaforums.com/showthread.php?t=2010984

13) Download the following 3 files and place them on the MicroSD card. - http://d-h.st/cFA - http://d-h.st/yUQ - http://d-h.st/0dH

14) While still in fastboot, type "fastboot boot recovery.img" - This will put the phone on the custom recovery. Make sure the SD card is in.

---Here, we're going to fix the partition tables for 16GB of space and replace the backup GPT so that we can't hardbrick from the backup GPT.

15) Run adb shell to get into a root shell in recovery.

16) Copy the modified DD onto the phone

# cp /external_sd/dd /
# chmod 755 /dd

17) Backup the partition tables incase something goes wrong.

# /dd if=/dev/block/mmcblk0 of=/external_sd/pgpt8G.img bs=512 count=34
# /dd if=/dev/block/mmcblk0 of=/external_sd/sgpt8G.img bs=512 skip=30777311

18) Unmount the filesystems so that you can overwrite the partition table.

# umount /data
# umount /cache

19) Make sure nothing is mounted. It should return this (Other than partition size):

# df -h
Filesystem Size Used Available Use% Mounted on
tmpfs 911.7M 48.0K 911.6M 0% /dev
/dev/block/mmcblk1p1 59.4G 4.8G 54.6G 8% /external_sd

20) Move the partitions to their new locations. This may take a couple minutes.

# /dd if=/dev/block/mmcblk0 of=/external_sd/DDR bs=512 skip=15267840 count=2015
# /dd if=/external_sd/DDR of=/dev/block/mmcblk0 bs=512 seek=30775296 conv=notrunc

21) Install the new partition tables.

# /dd if=/external_sd/sgpt16G.img of=/dev/block/mmcblk0 bs=512 seek=30777311 conv=notrunc
# /dd if=/external_sd/pgpt16G.img of=/dev/block/mmcblk0 bs=512 seek=0 conv=notrunc

22) Make sure no errors occurred. Run 'parted /dev/block/mmcblk0' and check that it returns the same as the below.

GNU Parted 1.8.8.1.179-aef3
Using /dev/block/mmcblk0
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p
p
Model: MMC 016G92 (sd/mmc)
Disk /dev/block/mmcblk0: 15.8GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number Start End Size File system Name Flags
1 524kB 67.6MB 67.1MB fat16 modem
2 67.6MB 68.2MB 524kB sbl1
3 68.2MB 68.7MB 524kB sbl2
4 68.7MB 70.8MB 2097kB sbl3
5 70.8MB 71.3MB 524kB tz
6 71.3MB 94.4MB 23.1MB boot
7 94.4MB 117MB 23.1MB recovery
8 117MB 118MB 799kB m9kefs1
9 118MB 119MB 799kB m9kefs2
10 119MB 120MB 799kB m9kefs3
11 120MB 121MB 524kB rpm
12 121MB 121MB 524kB aboot
13 121MB 122MB 524kB sbl2b
14 122MB 124MB 2097kB sbl3b
15 124MB 124MB 524kB abootb
16 124MB 125MB 524kB rpmb
17 125MB 125MB 524kB tzb
18 125MB 126MB 524kB metadata
19 126MB 143MB 16.8MB misc
20 143MB 159MB 16.8MB ext4 persist
21 159MB 1040MB 881MB ext4 system
22 1040MB 1627MB 587MB ext4 cache
23 1627MB 15.8GB 14.1GB ext4 userdata
24 15.8GB 15.8GB 524kB DDR
25 15.8GB 15.8GB 507kB grow

23) If something different was returned, run the below code to restore the previous partition tables.

# /dd if=/external_sd/sgpt8G.img of=/dev/block/mmcblk0 bs=512 seek=30777311 conv=notrunc
# /dd if=/external_sd/pgpt8G.img of=/dev/block/mmcblk0 bs=512 seek=0 conv=notrunc

24) Exit the shell and type 'adb reboot bootloader' or reboot the phone while holding Volume Up.

25) Check that you're in fastboot mode and exit the following commands - This will fix the filesystem to take up the entire partition.

fastboot erase userdata
fastboot format userdata
fastboot -w

26) Boot the phone and update as needed. Then, put this on the phone and flash in recovery.

27) You are now working other than the SD card and Capacitive buttons.

Credits:

http://xdaforums.com/showthread.php?t=2117576

http://xdaforums.com/showthread.php?t=2099784

http://xdaforums.com/showthread.php?t=2160124

http://xdaforums.com/showthread.php?t=2146816

To convert from Nexus 4

This assumes that you have read the Convert to section.

1) Wipe the phone. Go into fastboot mode [Vol Up + Power] and execute the following commands. This is to prevent corrupted data partitions.

fastboot -w
fastboot format system
fastboot format userdata
fastboot format cache
fastboot format data
fastboot erase system
fastboot erase userdata
fastboot erase cache
fastboot erase data

2) LGNPST back to stock. You will do this twice to fix some issues.

To get into download mode, turn the phone off and hold Vol Up + Vol Down while inserting the USB cable.

3) Download these 2 images. Mar. 8, 2013 and Sept. 29, 2012

4) Flash the Mar. 8, 2013 firmware in LGNPST (See above for how to flash firmware in LGNPST. As before, the phone will start booting at 67% and LGNPST will show an error at 85%. Ignore the error and close LGNPST.

5) Restart the phone in download mode and now flash the Sept. 29, 2012 firmware. If you don't, your /SDCARD may be corrupted and you cant root.

6) Root the phone and unlock the bootloader. See here

7) If that doesn't work, try Teenybin.

8) Some partitions are broken. Go into CWM recovery and open an 'adb shell'.

9) Execute the following code. This will backup the broken partitions and wipe them.

dd if=/dev/block/mmcblk0p15 of=/sdcard/mmcblk0p15.bak
dd if=/dev/block/mmcblk0p16 of=/sdcard/mmcblk0p16.bak
dd if=/dev/block/mmcblk0p19 of=/sdcard/mmcblk0p19.bak
mke2fs -T ext4 /dev/block/mmcblk0p15
mke2fs -T ext4 /dev/block/mmcblk0p16
mke2fs -T ext4 /dev/block/mmcblk0p19

---You should now be back to stock--- LGNPST again if you want 'True Stock'

Let me know if you see anything wrong and please leave nasty comments at the door.