Skip to content

Instantly share code, notes, and snippets.

@redaphid
Created October 18, 2025 07:38
Show Gist options
  • Save redaphid/8beaacc6564a3adf00c4a14ac5d88aa4 to your computer and use it in GitHub Desktop.
Save redaphid/8beaacc6564a3adf00c4a14ac5d88aa4 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Partition Resize Script for Windows Dual Boot
# Resizes nvme1n1p3 (Linux) from ~1991GB to 1500GB
# Creates nvme1n1p5 (Windows) with 300GB
set -e
echo "═══════════════════════════════════════════════════════════"
echo " PARTITION RESIZE SCRIPT FOR WINDOWS DUAL BOOT"
echo "═══════════════════════════════════════════════════════════"
echo ""
echo "This script will:"
echo " 1. Shrink /dev/nvme1n1p3 (Linux) from 1991GB to 1500GB"
echo " 2. Create /dev/nvme1n1p5 (Windows) with 300GB"
echo " 3. Leave space for Windows installation"
echo ""
echo "Current partition layout:"
lsblk -o NAME,SIZE,TYPE,FSTYPE,LABEL /dev/nvme1n1
echo ""
echo "⚠️ WARNING: This operation cannot be undone!"
echo "⚠️ Make sure you have backups of important data!"
echo "⚠️ You must boot from an Arch Linux live USB to run this!"
echo ""
read -p "Do you want to proceed? (yes/no): " confirm
if [ "$confirm" != "yes" ]; then
echo "Operation cancelled."
exit 1
fi
echo ""
echo "Step 1: Checking filesystem..."
e2fsck -f /dev/nvme1n1p3
echo ""
echo "Step 2: Shrinking ext4 filesystem to 1500GB..."
resize2fs /dev/nvme1n1p3 1500G
echo ""
echo "Step 3: Shrinking partition to 1500GB..."
parted /dev/nvme1n1 ---pretend-input-tty <<EOF
resizepart 3
1505GB
yes
quit
EOF
echo ""
echo "Step 4: Creating Windows partition (300GB)..."
parted /dev/nvme1n1 mkpart primary ntfs 1505GB 1805GB
echo ""
echo "Step 5: Setting Windows partition type..."
parted /dev/nvme1n1 set 5 msftdata on
echo ""
echo "═══════════════════════════════════════════════════════════"
echo " ✓ RESIZE COMPLETE!"
echo "═══════════════════════════════════════════════════════════"
echo ""
echo "Partition layout:"
parted /dev/nvme1n1 print
echo ""
lsblk -o NAME,SIZE,TYPE,FSTYPE,LABEL,MOUNTPOINT /dev/nvme1n1
echo ""
echo "Next steps:"
echo " 1. Reboot and remove the USB"
echo " 2. Boot into your Linux system to verify everything works"
echo " 3. Boot Windows installer USB"
echo " 4. Install Windows to the new partition (~300GB unformatted)"
echo " 5. After Windows installs, boot back to Linux"
echo " 6. Run: sudo update-grub"
echo ""
echo "Press Enter to continue..."
read
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment