This is a quick guide to mounting a qcow2 disk images on your host server. This is useful to reset passwords, edit files, or recover something without the virtual machine running.
Step 1 - Enable NBD on the Host
modprobe nbd max_part=8
| package at.favre.lib.bytes.otherPackage; | |
| import org.junit.Test; | |
| import javax.crypto.Cipher; | |
| import javax.crypto.SecretKey; | |
| import javax.crypto.spec.GCMParameterSpec; | |
| import javax.crypto.spec.SecretKeySpec; | |
| import java.nio.ByteBuffer; | |
| import java.nio.charset.StandardCharsets; |
| import socket | |
| from http.server import HTTPServer, SimpleHTTPRequestHandler | |
| import io | |
| class MyHandler(SimpleHTTPRequestHandler): | |
| def do_GET(self): | |
| if self.path == '/ip': | |
| output = io.StringIO() | |
| self.send_response(200) | |
| self.send_header('Content-type', 'text/html') |
| # Setting up the colors and copy/paste | |
| set -g default-terminal "screen-256color" | |
| # This is OS/X specific and should only be enabled when the 'reattach-to-user-namespace' is installed | |
| set -g default-command "reattach-to-user-namespace -l /bin/bash" | |
| bind C-c run "tmux save-buffer - | reattach-to-user-namespace pbcopy" | |
| bind C-v run "tmux set-buffer $(reattach-to-user-namespace pbpaste); tmux paste-buffer" | |
| # Make it use C-a, similar to screen.. | |
| unbind C-b |