Closed schmidtw closed 1 year ago
This Library parse only vmdk, not MBR{Filesystem}
You can use go-disk library to parse disk layer(MBR or GUID Partition Table) https://github.com/masahiro331/go-disk
And, use go-xxx-fileystem libraries to parse filesystem. https://github.com/masahiro331/go-xfs-filesystem https://github.com/masahiro331/go-ext4-filesystem
sample code
package main
import (
"fmt"
"io/fs"
"log"
"os"
"github.com/masahiro331/go-disk"
"github.com/masahiro331/go-xfs-filesystem/xfs"
"github.com/masahiro331/go-vmdk-parser/pkg/virtualization/vmdk"
)
func main() {
f, err := os.Open(os.Args[1]) // some vmdk file
if err != nil {
log.Fatal(err)
}
vreader, err := vmdk.Open(f, nil)
if err != nil {
log.Fatal(err)
}
d, err := disk.NewDriver(vreader)
if err != nil {
log.Fatal(err)
}
for {
partition, err := d.Next()
if err != nil {
log.Fatal(err)
}
reader := partition.GetSectionReader()
if !partition.Bootable() {
// for xfs filesystem
fsys, err := xfs.NewFS(reader, nil)
if err != nil {
log.Fatal(err)
}
fs.WalkDir(fsys, "/etc/", func(path string, d fs.DirEntry, err error) error {
if err != nil {
return err
}
fmt.Println(path)
return nil
})
}
}
}
If you want to know at which offset in the vmdk the MBR or filesystem starts, this library currently only works with compressed VMDKs, so you won't know until you decompress it.
You can read specification of vmdk. https://www.vmware.com/app/vmdk/?src=vmdk
Ok, great - that's exactly what I was hoping to get out of this. While I have a different filesystem impl, I'm also going to check out yours.
We're putting metadata about an image in the image (in a fat32 fs right now), but it would be easier if it was available in the ext4 fs. :smile:
Can I read fat32 fs implementation?? I want to parse fat32 for windows image.
I have libraries to parse VHD and VHDX for windows virtual machine image format.
I'm trying to figure out how to use this API to find the MBR/filesystem blob in a vmdk image. Can I do that with this library? If so, any suggestions on how to do that?
Thanks