Renaming an index in Elastic (slight hacks)

Sometimes you need to rename an Elasticsearch index—maybe to reuse the name for an alias. Officially, this isn’t supported. But with some manual edits and caution, it can be done. ⚠️ Warning: This is dangerous and unsupported. Back up your data first. Recommended Alternatives Reindex API Snapshot and restore Index split If these don’t work for your case, read on. The Hacky Method Stop the Elasticsearch node. Find the metadata files: grep -rF --include '*.st' 'my-old-index' data/ You’ll usually find matches in state-*.st files in index folders. Sometimes also in global-*.st files. Edit each match using a hex editor: Replace my-old-index with my-new-index. Keep lengths equal to preserve file structure. Recalculate the CRC32 checksum: Many editors like HxD support this. CRC32 covers the entire file except the last 8 bytes. Only the last 4 bytes (of those 8) are used. Double-check: Re-run the grep to ensure all instances were changed. Restart Elasticsearch. ...

March 5, 2021 · 1 min · Michael Bisbjerg

Move WSL to different drive

Windows Subsystem for Linux is awesome, but storing its files on the system drive can be limiting. Here’s how to move WSL distributions to another disk. List Containers wsl --list Sample output: Windows Subsystem for Linux Distributions: ubuntu (Default) docker-desktop-data docker-desktop Move a Container Shut down WSL to avoid issues: wsl --shutdown Export the container: wsl --export ubuntu N:\ubuntu.tar Unregister the container: wsl --unregister ubuntu Re-import to new location: wsl --import ubuntu N:\WSL\ubuntu N:\ubuntu.tar --version 2 (Optional) Delete the exported .tar file after verifying the setup. This approach preserves the distro while allowing full control over its storage location.

February 17, 2021 · 1 min · Michael Bisbjerg