Ubuntu 13.10 运行VirtualBox虚拟机编译出现错误提示运行"/etc/init.d/vboxdrv setup"的问题

运行虚拟机提示:

之后提示:

在终端下运行:

提示信息

提示有错误,查看了一下错误日志

内容如下

根据提示应该是没有找到对应的源文件,查看了一下系统版本号:

在进入/usr/src里发现果然没有对应的版本号头文件。

解决方法:

VirtualBox压缩VDI格式硬盘/调整磁盘大小

首先,看 vbox的官方文档:

http://www.virtualbox.org/manual/ch08.html#vboxmanage-modifyvdi

  • With the --compact option, can be used to compact disk images, i.e. remove blocks that only contains zeroes. This will shrink a dynamically allocated image again; it will reduce the physical size of the image without affecting the logical size of the virtual disk. Compaction works both for base images and for diff images created as part of a snapshot.For this operation to be effective, it is required that free space in the guest system first be zeroed out using a suitable software tool. For Windows guests, you can use the sdelete tool provided by Microsoft. Executesdelete -z in the guest to zero the free disk space before compressing the virtual disk image. For Linux, use the zerofree utility which supports ext2/ext3 filesystems.Please note that compacting is currently only available for VDI images. A similar effect can be achieved by zeroing out free blocks and then cloning the disk to any other dynamically allocated format. You can use this workaround until compacting is also supported for disk formats other than VDI.

关键之处正在于 sdelete 应该使用 -c -z  两个选项 ,而网上所以的方法都说是使用 -c 选项。

 Using SDelete

SDelete is a command line utility that takes a number of options. In any given use, it allows you to delete one or more files and/or directories, or to cleanse the free space on a logical disk. SDelete accepts wild card characters as part of the directory or file specifier.

所以,总结一下,正确的方法应该是这样:

1,  在guest os 中清理系统, windows的话可以再硬盘碎片整理一下

2,  在 guest os 中 使用 sdelete -z  ; linux 使用 zerofree

3,  VBoxManage modifyhd <uuid>|<filename>  --compact

如果磁盘空间不足,使用如下命令调整磁盘空间

参考链接