http://www.cyborgworkshop.org/2014/07/0 ... installed/
I have a vmdk file that I need to mount on a linux box to move some data around, but unfortunately I don’t have vmware installed on that box. I could install it and go through that hassle, or I could spend 10 times as much effort trying to figure out how to mount a raw vmdk in linux natively. Lets do that instead!
First off, I’m working on a vmdk from an ESXI 5.5 install. The vmdk is flat, no snapshots, no additional extents. I have no idea how you would do this if things are more complex.
First step, we need to look at the disk itself and figure out the partition table. Fortunately for us, vmdk files act a lot like a regular disk so we can use the tools that linux already has. We start by attaching the vmdk to a loop back device
losetup /dev/loop0 vi-flat.vmdk
Now we inspect that file to see if we can find the partition table
#fdisk -l -u /dev/loop0
Disk /dev/loop0: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders, total 104857600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0008f880
Device Boot Start End Blocks Id System
/dev/loop0p1 * 2048 499711 248832 83 Linux
/dev/loop0p2 501758 104855551 52176897 5 Extended
/dev/loop0p5 501760 104855551 52176896 8e Linux LVM
That looks familiar. We need to know the offset of the partitions on the disk in order to mount them manually, so we’re going to take the sector size (512 bytes in my case) and multiply that by the value of the partition start sector to come up with the bytes offset . In my case its
512 * 2048 = 1048576
Now we are going to setup a loopback device that attaches to our vmdk, but starts at the offset that we just calculated. That gives us just the partition we want.
#losetup -o 1048576 /dev/loop1 /dev/loop0
And now we can mount that loopback just like we would any drive
#mount /dev/loop1 /mnt/vmdkfile/
And use it like a regular drive mount
#ls /mnt/vmdkfile/
abi-3.8.0-39-generic config-3.8.0-41-generic initrd.img-3.8.0-41-generic
…
When you are done, just unmount the file and detach the loops
umount /mnt/vmdkfile/
losetup -d /dev/loop1
losetup -d /dev/loop0
Happy hacking!
Mount a VMDK in linux without having VMWare installed
虛擬化,雲端運算
前往
- Software
- ↳ CodeCharge Studio
- ↳ CodeCharge
- ↳ DemoCharge
- ↳ SuperPDF
- ↳ 551einv
- ↳ E3進銷存
- 程式語言
- ↳ PHP
- ↳ CodeLobster PHP Edition
- ↳ Yii
- ↳ CodeIgniter
- ↳ Phalcon
- ↳ Symfony
- ↳ FuelPHP
- ↳ Zend Framework 2
- ↳ laravel
- ↳ WordPress
- ↳ ASP.NET/C#
- ↳ ASP/VBScript
- ↳ JSP
- ↳ Java Servlets
- ↳ ColdFusion
- ↳ Perl
- ↳ Java Script
- ↳ jQuery
- ↳ HTML + CSS
- ↳ jQuery
- ↳ nodejs
- ↳ VB6
- ↳ Git
- ↳ App Inventor 2
- ↳ bash
- ↳ C++/ VC/ OpenCV
- ↳ OpenCV
- ↳ go
- ↳ cordova
- ↳ python
- ↳ Xamarin
- ↳ Assembly
- 資料庫
- ↳ MySQL
- ↳ PostgreSQL
- ↳ ORACLE
- ↳ Access
- ↳ SQL Server
- ↳ SQLite
- ↳ MariaDB
- ↳ Mongodb
- 作業系統
- ↳ Linux
- ↳ Ubuntu
- ↳ CentOS
- ↳ Mint
- ↳ Mandriva
- ↳ Debian
- ↳ Red Hat Enterprise Linux
- ↳ Oracle Linux
- ↳ Fedora
- ↳ Kali Linux
- ↳ OpenSUSE
- ↳ Elementary OS
- ↳ Microsoft
- ↳ Server 2008 R2
- ↳ Server 2012 R2
- ↳ Server 2012
- ↳ 8
- ↳ 10
- ↳ System Center 2016
- ↳ NOVELL
- ↳ FreeBSD
- ↳ VMware
- ↳ VirtualBox
- ↳ Mac OS X
- ↳ Solaris
- ↳ iOS
- ↳ Android
- ↳ Cloud
- ↳ OpenStack
- ↳ Docker
- ↳ Proxmox VE
- ↳ CloudReady
- ↳ chrome
- 網頁伺服器
- ↳ apache
- ↳ tomcat
- ↳ nginx
- ↳ IIS
- ↳ JBoss
- ↳ weblogic
- ↳ WebHosting
- 硬體
- ↳ 硬體及週邊
- ↳ RouterOS
- ↳ LEGO NXT
- ↳ Arduino
- ↳ MSP430
- ↳ Raspberry Pi
- ↳ OpenERP
- ↳ Storage
- ↳ Server
- ↳ Brocade
- ↳ MODELS
- ↳ FortiGate
- 軟體
- ↳ sublime
- ↳ LibreNMS