aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/build/linux_linux.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/build/linux_linux.go')
-rw-r--r--pkg/build/linux_linux.go18
1 files changed, 17 insertions, 1 deletions
diff --git a/pkg/build/linux_linux.go b/pkg/build/linux_linux.go
index adf830ea9..e0a36f34d 100644
--- a/pkg/build/linux_linux.go
+++ b/pkg/build/linux_linux.go
@@ -47,7 +47,7 @@ func embedLinuxKernel(params Params, kernelPath string) error {
if err := osutil.MkdirAll(mountDir); err != nil {
return err
}
- if err := unix.Mount(loopFile+"p1", mountDir, "ext4", 0, ""); err != nil {
+ if err := tryMount(loopFile+"p1", mountDir); err != nil {
return fmt.Errorf("mount(%vp1, %v) failed: %v", loopFile, mountDir, err)
}
defer unix.Unmount(mountDir, 0)
@@ -65,6 +65,22 @@ func embedLinuxKernel(params Params, kernelPath string) error {
return osutil.CopyFile(imageFile, filepath.Join(params.OutputDir, "image"))
}
+func tryMount(device, mountDir string) error {
+ var err error
+loop:
+ for _, fsType := range []string{"ext4", "vfat"} {
+ err = unix.Mount(device, mountDir, fsType, 0, "")
+ switch err {
+ case syscall.EINVAL:
+ // Most likely it just an invalid superblock error - try another fstype.
+ continue
+ case nil:
+ break loop
+ }
+ }
+ return err
+}
+
func copyKernel(mountDir, kernelPath string) error {
// Try several common locations where the kernel can be.
for _, targetPath := range []string{"boot/vmlinuz", "boot/bzImage", "vmlinuz", "bzImage", "Image.gz"} {