🐧

Windows

4 notes  •  Linux & Server Admin

Delete Extra Partitions on a USB Drive with DiskPart (Windows)

When a USB drive has multiple partitions or is unrecognised by Windows after Linux use, DiskPart can wipe and recreate it cleanly.

Step 1 — Open DiskPart

Win + R → type: diskpart → Enter

Step 2 — Identify the USB Disk

DISKPART> list disk

Note the disk number of your USB drive (e.g., Disk 1).

Step 3 — Select and Clean the Disk

DISKPART> select disk 1
DISKPART> clean

Step 4 — Create a New Partition

DISKPART> create partition primary
DISKPART> select partition 1
DISKPART> active
DISKPART> format fs=fat32 quick label="USB"
DISKPART> assign
DISKPART> exit

Notes

  • Double-check the disk numberclean wipes everything on the selected disk.
  • Use format fs=ntfs quick for drives >32 GB if FAT32 file size limits are a concern.

Remove All Partitions from a USB Drive (Windows DiskPart)

Use DiskPart to remove all partitions from a USB thumb drive and restore it to a single-partition state.

Steps

Win + R → diskpart → Enter

DISKPART> list disk
DISKPART> select disk <NUMBER>   # e.g., select disk 2
DISKPART> list partition
DISKPART> clean                   # removes all partitions
DISKPART> create partition primary
DISKPART> format fs=fat32 quick
DISKPART> assign
DISKPART> exit

Notes

  • Verify the disk number carefully with list disk — the USB size should help identify it.
  • After clean, Windows will show the drive as unallocated in Disk Management.

Batch Resize Photos While Retaining Folder Structure (IrfanView)

IrfanView's Batch Conversion feature can resize thousands of images while preserving the original folder structure.

Step 1 — Open Batch Conversion

In IrfanView: File → Batch Conversion/Rename

Step 2 — Configure Settings

  1. Under Name pattern enter $F — this preserves the original filename.
  2. Select Output format (e.g., JPEG).
  3. Click Advanced and set the resize dimensions.
  4. Check Use subdirectories to process subfolders.
  5. Set the Output directory to your destination folder.

Step 3 — Add Files and Run

  1. Click Add all or drag files/folders into the file list.
  2. Click Start Batch.

Notes

  • IrfanView is free: irfanview.com
  • For command-line batch resizing on Linux: mogrify -resize 1920x1080 -quality 85 *.jpg

Windows File Permission and Network Commands

Useful Windows commands for managing file permissions, network connections, and SSH key files.

Fix PEM Key Permissions (for SSH/AWS)

icacls dbserver.pem /inheritance:r /grant:r "%USERNAME%:R"

This removes inherited permissions and grants read-only access to your user — required for SSH private keys.

Find Processes Using a Port

netstat -ano | findstr :8080
# Then kill by PID:
taskkill /PID 1234 /F

Open / Close Firewall Ports (Windows Firewall)

# Open port 8080
netsh advfirewall firewall add rule name="Open Port 8080" ^
  dir=in action=allow protocol=TCP localport=8080

# Remove rule
netsh advfirewall firewall delete rule name="Open Port 8080"

Map a Network Drive

net use Z: \\server\share /user:domain\username password /persistent:yes

Flush DNS Cache

ipconfig /flushdns