尝试打包图像时gcimagebundle工具失败

时间:2014-02-21 02:46:16

标签: python

因此,我开始使用GCE一个星期,并在开始迁移某些系统之前测试不同的工具和选项。目前,我正在尝试构建我自己的GCE不提供的操作系统自定义映像。为了测试,我正在使用Ubuntu 12.04LTS构建我的自定义映像。我完全阅读了文档https://developers.google.com/compute/docs/building-image

但是,当需要捆绑我的图像时,它会失败。我试图按如下方式捆绑图像:

  

sudo gcimagebundle -r / -o / tmp / --log_file = / tmp / abc.log

然而,这失败并出现以下错误:

Starting logging in /tmp/abc.log found platform Ubuntu exclude list: (/etc/ssh/.host_key_regenerated, 0:0:0) (/dev, 0:1:0) (/proc, 0:1:0) (/run,  0:1:1) (/selinux, 0:0:0) (/tmp, 0:1:0) (/sys, 0:1:0) (/var/lib/google/per-instance, 0:1:0)  (/var/lock, 0:1:1) (/var/log, 0:1:1) (/var/run, 0:1:1) ignoring mounts /proc /sys /sys/fs/fuse/connections /sys/kernel/debug /sys/kernel/security  /dev /dev/pts /run /run/lock /run/shm overwrite list = Initializing disk file Traceback (most recent call last):   File "/usr/local/bin/gcimagebundle", line 28, in <module>
    main()   File "/usr/local/bin/gcimagebundle", line 24, in main
    imagebundle.main()   File "/usr/local/lib/python2.7/dist-packages/gcimagebundlelib/imagebundle.py", line 186,  in main
    (fs_size, digest) = bundle.Bundleup()   File "/usr/local/lib/python2.7/dist-packages/gcimagebundlelib/block_disk.py", line 148, in Bundleup
    with utils.LoadDiskImage(disk_file_path) as devices:   File "/usr/local/lib/python2.7/dist-packages/gcimagebundlelib/utils.py", line 50, in __enter__
    output = RunCommand(kpartx_cmd)   File "/usr/local/lib/python2.7/dist-packages/gcimagebundlelib/utils.py", line 352, in RunCommand
    stdout=subprocess.PIPE, stderr=subprocess.PIPE)   File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
    errread, errwrite)   File "/usr/lib/python2.7/subprocess.py", line 1249, in _execute_child
    raise child_exception OSError: [Errno 2] No such file or directory  root@none:/boot#

然后我尝试根据不同的文档和视频运行命令稍微不同但仍然失败:

root@none:/boot# /usr/share/imagebundle/compute-image-packages-1.1.0.1/gcimagebundle/build/scripts-2.7/gcimagebundle
-r / -o /tmp/ --log_file=/tmp/abc.log Starting logging in /tmp/abc.log found platform Ubuntu exclude list: (/etc/ssh/.host_key_regenerated, 0:0:0) (/dev, 0:1:0) (/proc, 0:1:0) (/run, 0:1:1) (/selinux, 0:0:0) (/tmp, 0:1:0) (/sys, 0:1:0) (/var/lib/google/per-instance, 0:1:0) (/var/lock, 0:1:1) (/var/log, 0:1:1) (/var/run, 0:1:1) ignoring mounts /proc /sys /sys/fs/fuse/connections /sys/kernel/debug /sys/kernel/security /dev /dev/pts /run /run/lock /run/shm overwrite list = Initializing disk file Traceback (most recent call last):   File "/usr/share/imagebundle/compute-image-packages-1.1.0.1/gcimagebundle/build/scripts-2.7/gcimagebundle", line 28, in <module>
    main()   File "/usr/share/imagebundle/compute-image-packages-1.1.0.1/gcimagebundle/build/scripts-2.7/gcimagebundle", line 24, in main
    imagebundle.main()   File "/usr/local/lib/python2.7/dist-packages/gcimagebundlelib/imagebundle.py", line 186, in main
    (fs_size, digest) = bundle.Bundleup()   File "/usr/local/lib/python2.7/dist-packages/gcimagebundlelib/block_disk.py", line 148, in Bundleup
    with utils.LoadDiskImage(disk_file_path) as devices:   File "/usr/local/lib/python2.7/dist-packages/gcimagebundlelib/utils.py", line 50, in __enter__
    output = RunCommand(kpartx_cmd)   File "/usr/local/lib/python2.7/dist-packages/gcimagebundlelib/utils.py", line 352, in RunCommand
    stdout=subprocess.PIPE, stderr=subprocess.PIPE)   File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
    errread, errwrite)   File "/usr/lib/python2.7/subprocess.py", line 1249, in _execute_child
    raise child_exception OSError: [Errno 2] No such file or directory

我在这里缺少什么? Python工具寻找哪个目录,返回“没有这样的文件或目录”?

我收到了其他人的帮助,告诉我要安装 kpartx ,这样可以解决上面的错误。我能够更进一步,现在出现以下错误:

root@none:/usr/share# gcimagebundle -r / -o /tmp
--log_file=/tmp/imagebundle.log Starting logging in /tmp/imagebundle.log

found platform Ubuntu exclude list: (/etc/ssh/.host_key_regenerated, 0:0:0) (/dev, 0:1:0) (/proc, 0:1:0) (/run, 0:1:1) (/selinux, 0:0:0) (/tmp, 0:1:0) (/sys, 0:1:0) (/var/lib/google/per-instance, 0:1:0) (/var/lock, 0:1:1) (/var/log, 0:1:1) (/var/run, 0:1:1) ignoring mounts /proc /sys /sys/fs/fuse/connections /sys/kernel/debug /sys/kernel/security /dev /dev/pts /run /run/lock /run/shm overwrite list = Initializing disk file Making filesystem Copying contents

Traceback (most recent call last):   File "/usr/local/bin/gcimagebundle", line 28, in <module>
    main()   File "/usr/local/bin/gcimagebundle", line 24, in main
    imagebundle.main()   File "/usr/local/lib/python2.7/dist-packages/gcimagebundlelib/imagebundle.py", line 186, in main
    (fs_size, digest) = bundle.Bundleup()   File "/usr/local/lib/python2.7/dist-packages/gcimagebundlelib/block_disk.py", line 172, in Bundleup
    manifest_created = self._manifest.CreateIfNeeded(manifest_file_path)   File "/usr/local/lib/python2.7/dist-packages/gcimagebundlelib/manifest.py", line 46, in CreateIfNeeded
    self._LoadLicenses()   File "/usr/local/lib/python2.7/dist-packages/gcimagebundlelib/manifest.py", line 55, in _LoadLicenses
    response = self._http.GetMetadata('instance/', recursive=True)   File "/usr/local/lib/python2.7/dist-packages/gcimagebundlelib/utils.py", line 411, in GetMetadata
    versions = self.Get(base_url).splitlines()   File "/usr/local/lib/python2.7/dist-packages/gcimagebundlelib/utils.py", line 395, in Get
    return urllib2.urlopen(url).read()   File "/usr/lib/python2.7/urllib2.py", line 126, in urlopen
    return _opener.open(url, data, timeout)   File "/usr/lib/python2.7/urllib2.py", line 400, in open
    response = self._open(req, data)   File "/usr/lib/python2.7/urllib2.py", line 418, in _open
    '_open', req)   File "/usr/lib/python2.7/urllib2.py", line 378, in _call_chain
    result = func(*args)   File "/usr/lib/python2.7/urllib2.py", line 1207, in http_open
    return self.do_open(httplib.HTTPConnection, req)   File "/usr/lib/python2.7/urllib2.py", line 1177, in do_open
    raise URLError(err) urllib2.URLError: <urlopen error [Errno -2] Name or service not known>

我安装了 python-http-parser python-httplib2 ,但在尝试构建时仍然遇到同样的失败。

提前致谢:)

1 个答案:

答案 0 :(得分:0)

正确的命令是

sudo gcimagebundle -d <boot-device> -o <output-directory>

尝试

sudo gcimagebundle -d /dev/sda -o ./ --log_file=/tmp/abc.log