惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Martin Fowler
Martin Fowler
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
IT之家
IT之家
美团技术团队
酷 壳 – CoolShell
酷 壳 – CoolShell
Y
Y Combinator Blog
T
Tailwind CSS Blog
D
Docker
博客园 - Franky
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Google DeepMind News
Google DeepMind News
腾讯CDC
Vercel News
Vercel News
Engineering at Meta
Engineering at Meta
U
Unit 42
The Cloudflare Blog
S
SegmentFault 最新的问题
WordPress大学
WordPress大学
爱范儿
爱范儿
Recent Announcements
Recent Announcements
博客园 - 聂微东
博客园 - 叶小钗
H
Help Net Security
MyScale Blog
MyScale Blog

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Raw VM Image Mounting with losetup
Mathieu K · 2026-05-17 · via DEV Community
Cover image for Raw VM Image Mounting with losetup

Mathieu K

I use Qemu/KVM for most of my custom virtual machine, and sometime, I need to do some backup or to check the filesystem from the host point of view. The process is quite simple, the virtual disk is used as a virtual storage device and then we mount the partition on the host. On FreeBSD, we use mdconfig, on OpenBSD we use vmconfig and on Linux, we are using losetup. Both of these commands have the same goal: allocate a special device pointing to a file present on a filesystem. Here an example with losetup.

First we want to mount the image /path/to/your/image.raw on a free losetup device (usually present in /dev/loop*). The --find flag will look for the next available loop device, the --show will print it to stdout and -P will reload the partition table.

# use available loop device, and attach image.raw to it
loop=$(losetup --find --show -P /path/to/your/image.raw)

Enter fullscreen mode Exit fullscreen mode

Then, we can check if the partitions are present (or not). The attached device has been put into the loop variable.

# check the loop devices partition
ls -l ${loop}*

Enter fullscreen mode Exit fullscreen mode

If you are using lvm (it was my case for this note), simply use lvscan command and automatically enable the logical volume found.

lvscan -a y 

Enter fullscreen mode Exit fullscreen mode

mount the logical volume on your and do what you have to do.

mount /dev/vg/lv /mnt

# Do your stuff here.

Enter fullscreen mode Exit fullscreen mode

When you have done, you can simply umount the partition...

umount /mnt

Enter fullscreen mode Exit fullscreen mode

... and finally detach the loop device.

losetup --detach ${loop}

Enter fullscreen mode Exit fullscreen mode

Note: this procedure can be used only for raw qemu image. If you are using qcow format or another one, you will first need to convert it with qemu-img or use a tool like mount-qcow2-image.


Cover Image by Aleksandr Popov on Unsplash