[Linux] 在 Ubuntu 上讀取 VMware ESXi 5.0 vmfs 的檔案

[Linux] 在 Ubuntu 上讀取 VMware ESXi 5.0 vmfs 的檔案

之前部門用 MoinMoin 架了一台 wiki server

這台 wiki server 是在 ESXi 上的,

不過最近搬樓層之後,ESXi 的硬碟似乎出了問題,

用 vSphere Client 連進去會看到所有的 VM 都是 Inaccessible,

直接用 ssh 連進去 ESXi 裡面,只要去 ls /vmfs/volumes 就會卡很久,

應該是有磁碟壞軌之類的問題…

 

硬碟壞了也就算了,但 wiki server 上有不少累積下來的文件,

要全部重建的話,可就真的哀鴻遍野了…

後來還是把硬碟拆了下來,打算直接讀取 ESXi 裡面 vmfs 裡的資料~

試了一下,在 Ubuntu 15.04 上成功的讀到 vmfs 的資料囉~

 

參考資料:

How to access VMFS Datastore from Linux / Windows

 

1. 安裝 vmfs-tools

要能謮取 ESXi 的 vmfs 檔案結構,得先安裝 vmfs-tools 這個套件:

sudo apt-get install vmfs-tools

 

因為我的 ESXi 是 5.0 版本,要能成功讀取的話,

vmfs-tools 的版本要是 0.2.5 以上才行,用 apt-cache show 確認一下版本號:

testuser@localhost ~ $ sudo apt-cache show vmfs-tools
Package: vmfs-tools
Priority: extra
Section: universe/otherosfs
Installed-Size: 267
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Mike Hommey <glandium@debian.org>
Architecture: amd64
Version: 0.2.5-1
Depends: libc6 (>= 2.14), libfuse2 (>= 2.8.1), libuuid1 (>= 2.16)
Filename: pool/universe/v/vmfs-tools/vmfs-tools_0.2.5-1_amd64.deb
Size: 116056
MD5sum: 6a9d12b2c179e399f03b5f7cb14086d6
SHA1: 0afbba3e448d488afa8b4f9bd6b35a048430d876
SHA256: d0e0b990d732b81811657bb32c44d7fe7957191904934c025fe602ddf48805d7
Description-en: Tools to access VMFS filesystems
VMFS is a clustered filesystem designed to store virtual machine disks for
VMware ESX or ESXi Server hosts. This set of tools allows to access these
filesystems from some other non ESX/ESXi host for e.g. maintenance tasks.
.
Only read access is available at the moment, but write access is under
works. Multiple extents are supported.
.
The VMFS can be accessed with a command line tool or mounted through a
userspace filesystem (FUSE-based).
Description-md5: 0cdea504f6c5a9da0070eeda2f011352
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Origin: Ubuntu

 

2. 將 ESXi 硬碟接上 Ubuntu 並確認掛載位置

將 ESXi 的硬碟接在 Ubuntu 之後,應該可以看到有幾個硬碟被接上來了, 

這邊要確認的是接上來的硬碟是掛在哪個設備下面,

用 fdisk -l 可以列出所有的分割區,像我原本就有一顆硬碟會在 /dev/sda,

接上來的 ESXi 通常會是在 /dev/sdb,看一下磁碟大小應該也可以猜出來:

testuser@localhost ~ $ sudo fdisk -l
Disk /dev/sda: 465.8 GiB, 500107862016 bytes, 976773168 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
Disklabel type: dos
Disk identifier: 0x4def5836
Device     Boot     Start       End   Sectors   Size Id Type
/dev/sda1  *         2048 943237119 943235072 449.8G 83 Linux
/dev/sda2       943239166 976771071  33531906    16G  5 Extended
/dev/sda5       943239168 976771071  33531904    16G 82 Linux swap / Solaris
Disk /dev/sdb: 931.5 GiB, 1000204886016 bytes, 1953525168 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
Disklabel type: gpt
Disk identifier: DB3B43BE-EAC9-4595-96A6-14F8262DC589
Device        Start        End    Sectors   Size Type
/dev/sdb1        64       8191       8128     4M EFI System
/dev/sdb2   1843200   10229759    8386560     4G Microsoft basic data
/dev/sdb3  10229760 1953525134 1943295375 926.7G unknown
/dev/sdb5      8224     520191     511968   250M Microsoft basic data
/dev/sdb6    520224    1032191     511968   250M Microsoft basic data
/dev/sdb7   1032224    1257471     225248   110M unknown
/dev/sdb8   1257504    1843199     585696   286M Microsoft basic data

 

3. 將 ESXi 的 vmfs 掛載到目錄

從上面 fdisk -l 的列表中,可以看到 ESXi 將硬碟切成好幾個分割區,

理論上找最大的那一個分割區,應該就是放 VM 的那一個了,

以本例來說就是 /dev/sdb3 (926.7G)~

先建立一個目錄,再用 vmfs-fuse 將 /dev/sdb3 掛載到這個目錄上:

mkdir vmfs
sudo vmfs-fuse /dev/sdb3 vmfs

 

掛載上來之後,用 ls 看一下,可以看到 VM 的目錄,

像我們原本的 wiki server 是架在 Ubuntu Server 12.04 LTS 這個 VM 上,

就可以把這個目錄複製到其他台 ESXi 上面,就能再跑起來囉~^^

root@localhost:/home/testuser# ll vmfs
total 1504348
drwxr-xr-t 13 root     root          2800 Apr 23 23:03 ./
drwxr-xr-x 23 testuser testuser      4096 Sep 25 12:18 ../
-r--------  1 root     root       4980736 Jan 18  2013 .fbb.sf
-r--------  1 root     root     267026432 Jan 18  2013 .fdc.sf
-r--------  1 root     root       1179648 Jan 18  2013 .pb2.sf
-r--------  1 root     root     268435456 Jan 18  2013 .pbc.sf
-r--------  1 root     root     262733824 Jan 18  2013 .sbc.sf
drwxr-xr-x  2 root     root          1400 Jun 29  2013 Ubuntu Server 12.04 LTS/
-r--------  1 root     root       4194304 Jan 18  2013 .vh.sf
drwxr-xr-x  2 root     root          2100 Mar 26  2013 Windows 7 Enterprise/

 

(本頁面已被瀏覽過 2,272 次)

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料