try to load aufs module, disply error on failure

This commit is contained in:
Victor Vieux 2013-04-15 12:05:46 +02:00
Родитель 27be5aec74
Коммит ac49a797b4
1 изменённых файлов: 15 добавлений и 1 удалений

Просмотреть файл

@ -7,7 +7,9 @@ import (
"fmt"
"io"
"io/ioutil"
"log"
"os"
"os/exec"
"path"
"strings"
"time"
@ -92,7 +94,19 @@ func MountAUFS(ro []string, rw string, target string) error {
roBranches += fmt.Sprintf("%v=ro:", layer)
}
branches := fmt.Sprintf("br:%v:%v", rwBranch, roBranches)
return mount("none", target, "aufs", 0, branches)
//if error, try to load aufs kernel module
if err := mount("none", target, "aufs", 0, branches); err != nil {
log.Printf("Kernel does not support AUFS, trying to load the AUFS module with modprobe...")
if err := exec.Command("modprobe", "aufs").Run(); err != nil {
return fmt.Errorf("Unable to load the AUFS module")
}
log.Printf("...module loaded.")
if err := mount("none", target, "aufs", 0, branches); err != nil {
return fmt.Errorf("Unable to mount using aufs")
}
}
return nil
}
func (image *Image) Mount(root, rw string) error {