# Complete OnePlus 7 Root Process: GM1901_11_h.40

Here's the comprehensive step-by-step guide for rooting your OnePlus 7 after updating to GM1901_11_h.40 firmware.

## Pre-Requirements Checklist

**Hardware/Software Ready:**

- ✅ OnePlus 7 with **unlocked bootloader**
- ✅ Arch Linux with **ADB/Fastboot installed**
- ✅ **USB Debugging enabled** in Developer Options
- ✅ **Quality USB-C cable** (avoid cheap cables that cause connection issues)

**Downloads Needed:**

- ✅ **Magisk APK** from GitHub[1]
- ✅ **Payload dumper** tool installed[2]
- ✅ **GM1901_11_h.40 firmware** (via Oxygen Updater)

## Phase 1: Firmware Download & Backup

### Step 1: Download H.40 Firmware

```bash
# On your phone, install Oxygen Updater from Play Store
# Download GM1901_11_h.40 firmware
# DO NOT install it yet - just download
```

### Step 2: Transfer Firmware to Computer

```bash
# Connect phone to computer
adb devices
# Should show your device

# Find and copy firmware
adb pull /sdcard/OxygenUpdater/GM1901_11_h.40.zip ~/Downloads/
```

### Step 3: Create Backup Directory

```bash
# Create organized workspace
mkdir ~/oneplus7_root
cd ~/oneplus7_root
cp ~/Downloads/GM1901_11_h.40.zip .
```

## Phase 2: Extract Boot Image

### Step 4: Extract Firmware

```bash
# Unzip firmware
unzip GM1901_11_h.40.zip

# You should see payload.bin and other files
ls -la
# Look for payload.bin (usually ~2GB file)
```

### Step 5: Extract Boot Partition

```bash
# Extract only boot.img (faster than full extraction)
payload_dumper --partitions boot payload.bin

# This creates boot.img in current directory
ls -la boot.img
# Should show ~64MB file
```

### Step 6: Verify Boot Image

```bash
# Check file type
file boot.img
# Should show: "Android bootimg"

# Get file hash for verification
sha256sum boot.img > boot_original.sha256
```

## Phase 3: Install Firmware Update

### Step 7: Update Phone to H.40

```bash
# Back up current important data first
adb backup -all -nosystem

# Now install the H.40 update via Oxygen Updater or Settings
# Let phone complete update and boot normally
# Test all functions work correctly
```

### Step 8: Re-enable Developer Options

```bash
# After update, re-enable Developer Options
# Settings → About Phone → Build Number (tap 7 times)
# Settings → System → Developer Options → USB Debugging (ON)

# Verify ADB still works
adb devices
```

## Phase 4: Install Magisk & Patch Boot

### Step 9: Install Magisk Manager

```bash
# Transfer Magisk APK to phone
adb push Magisk-v29.0.apk /sdcard/

# Install on phone
adb shell pm install /sdcard/Magisk-v29.0.apk
```

### Step 10: Transfer Boot Image for Patching

```bash
# Copy extracted boot.img to phone
adb push boot.img /sdcard/Download/boot.img

# Verify transfer
adb shell ls -la /sdcard/Download/boot.img
```

### Step 11: Patch Boot Image with Magisk

**On your phone:**

1. **Open Magisk Manager app**
2. **Tap "Install" button** next to Magisk section
3. **Select "Select and Patch a File"**
4. **Navigate to /sdcard/Download/boot.img**
5. **Select the boot.img file**
6. **Tap "Let's Go"** - Magisk will patch the image
7. **Wait for completion** - shows "All done!"

The patched file will be saved as: `/sdcard/Download/magisk_patched-[random_string].img`

### Step 12: Transfer Patched Boot Back

```bash
# Pull the patched boot image
adb pull /sdcard/Download/magisk_patched-*.img

# Rename for clarity
mv magisk_patched-*.img magisk_patched_h40.img

# Verify the patched file
ls -la magisk_patched_h40.img
file magisk_patched_h40.img
```

## Phase 5: Flash Patched Boot & Root

### Step 13: Boot to Fastboot Mode

```bash
# Reboot phone to bootloader
adb reboot bootloader

# Verify fastboot connection
fastboot devices
# Should show your device serial number

# Check current slot
fastboot getvar current-slot
```

### Step 14: Flash Patched Boot Image

```bash
# OnePlus 7 uses A/B partitions - flash both slots for safety
fastboot flash boot_a magisk_patched_h40.img
fastboot flash boot_b magisk_patched_h40.img

# Alternative: Flash only current slot
fastboot flash boot magisk_patched_h40.img
```

### Step 15: Reboot and Verify

```bash
# Reboot phone
fastboot reboot

# Wait for phone to boot completely
# Should boot normally to OxygenOS
```

## Phase 6: Root Verification & Setup

### Step 16: Verify Root Access

```bash
# Check if root is working
adb shell su -c "id"
# Should return: uid=0(root) gid=0(root) groups=0(root)

# Check Magisk status
adb shell su -c "magisk -v"
# Should show Magisk version
```

### Step 17: Configure Magisk

**On your phone:**

1. **Open Magisk Manager**
2. **Verify both sections show green checkmarks:**
   - **Magisk**: Installed version
   - **App**: Installed version
3. **Configure settings:**
   - **Enable "Zygisk"** for better compatibility
   - **Enable "Enforce DenyList"** for banking apps
   - **Add apps to DenyList** that shouldn't detect root

### Step 18: Install Root Management Apps

```bash
# Install useful root apps
# Examples: AdAway, Titanium Backup, Greenify, etc.
```

## Phase 7: Security & Maintenance

### Step 19: Hide Root from Detection

```bash
# Configure DenyList for sensitive apps:
# - Banking apps
# - Payment apps (Google Pay, PayPal)
# - Corporate apps
# - Games with anti-cheat
```

### Step 20: Create Recovery Backup

```bash
# Keep these files safe for recovery:
cp boot.img boot_stock_h40.img          # Original boot
cp magisk_patched_h40.img magisk_boot_backup.img  # Working patched boot
cp boot_original.sha256 checksums.txt   # Verification hashes
```

## Troubleshooting Common Issues

### If Phone Won't Boot (Bootloop)

```bash
# Flash original boot image back
fastboot flash boot_a boot.img
fastboot flash boot_b boot.img
fastboot reboot
```

### If Magisk Shows Red X

```bash
# Re-patch boot image with newer Magisk version
# Or try direct install mode in Magisk
```

### If Apps Detect Root

```bash
# Enable more aggressive hiding:
# Magisk → Settings → Enable MagiskHide
# Add problematic apps to hide list
```

### Banking Apps Not Working

```bash
# Configure DenyList properly:
# Magisk → Settings → Configure DenyList
# Add all banking/payment apps
# Enable "Enforce DenyList"
```

## Post-Root Recommendations

**Security Hardening:**

- Install **AdAway** for system-wide ad blocking
- Use **AFWall+** for advanced firewall control
- Install **Privacy Guard** for permission management

**System Optimization:**

- **Greenify** for background app management
- **SD Maid** for system cleaning
- **Tasker** for advanced automation

**Backup Solutions:**

- **Titanium Backup** for complete app/data backup
- **TWRP** custom recovery (optional)

## Maintenance Notes

**Monthly Tasks:**

- Update Magisk when new versions release[1]
- Update Magisk modules
- Verify root access still working
- Check for OxygenOS updates (be cautious with major updates)

**Before System Updates:**

- Always uninstall Magisk first (restore stock boot)
- Apply system update
- Re-root with updated boot image

Your OnePlus 7 should now be fully rooted with Magisk on OxygenOS 12 H.40, providing you with complete system-level access while maintaining the ability to pass most safety checks for banking and other sensitive applications.

[1] https://github.com/topjohnwu/magisk/releases/
[2] https://github.com/vm03/payload_dumper
