Environment:
Ubuntu 14.04 64-bit desktop, as guest virtual machine in virtual box
Host: MacBook Pro
在64位机器上缺省编译或运行时查找的是64位程序,但如果编译32位程序通常会遇到一些问题,这里做一个说明。
Build 32-bit C/C++ program on 64-bit Linux
sudo apt-get install g++ #to build C++ source files
sudo apt-get install g++-multilib #to build 32-bit executable on 64-bit Linux
g++ -m32 -g -o a.out file1.cpp file2.cpp #specify 32-bit binary
Run 32-bit executable on 64-bit Linux
要运行32位legacy程序,则需要安装相应的32位库文件(ia32-libs)。
首先添加 i386 architecture,然后安装必要的32位库。
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386
sudo ./file-name
以下步骤可能也需要:
sudo apt-get update
sudo apt-get install lib32z1 lib32ncurses5 lib32bz2-1.0
特别的,比如需要libgc library,则需指定i386类型下载:
sudo apt-get install libgc1c2 (for 32-bit linux)
sudo apt-get install libgc1c2:i386 (for 64-bit linux)
可以用命令 “file file_name”查看执行文件类型:
file-name: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV),
dynamically linked (uses shared libs), for GNU/Linux 2.6.8, not
stripped
2015/06/11
2015/06/10
Shrink Virtualbox VM VDI File Size
Virtualbox 的VM image size (.vdi file)有时候会变得很大, 如何缩减文件大小呢?
这里我的host = MacBook Pro, guest = Win7. 虚拟机创建的时候设置的是 “Dynamically Expanding Storage” , 但以后随着增删文件操作而磁盘只会增加不会减少。
- Run defrag in the guest (Windows only)
- Nullify free space:With a Linux Guest run this:
sudo dd if=/dev/zero of=/bigemptyfile bs=4096k sudo rm -rf /bigemptyfile
With a Windows Guest, download SDelete from Sysinternals and run this:sdelete –z c:
- Shutdown the guest VM
- Now run VBoxManage's
modifyhd
command with the--compact
option:With a Linux Host run this:vboxmanage modifyhd /path/to/thedisk.vdi --compact
With a Windows Host run this:VBoxManage.exe modifyhd c:\path\to\thedisk.vdi --compact
With a Mac Host run this:VBoxManage modifyhd /path/to/thedisk.vdi --compact
This reduces the vdi size.
订阅:
博文 (Atom)