一次编译Android-5.1.1_r38源码时,前面都很顺畅,在生成libwebviewchromium.so这个文件时,出现collect2: ld terminated with signal 9 错误。libwebviewchromium.so这个文件相当大,产生错误的原因是由于交换分区被占用完了,只有扩大交换分区,方法如下:
一、扩大交换分区之前的大小:
goembed@Goembed:~$ free -m
total used free shared buffers cached
Mem: 1987 1919 67 0 3 1369
-/+ buffers/cache: 545 1441
Swap: 2046 302 1744
goembed@Goembed:/opt/swap$ sudo swapon -s
Filename Type Size Used Priority
/dev/sda5 partition 2096124 309860 -1
二、扩大分区
1. 创建swapfile:
goembed@Goembed:~$ mkdir -p /opt/swap/
goembed@Goembed:~$ cd /opt/swap/
goembed@Goembed:/opt/swap$ sudo dd if=/dev/zero of=swapfile bs=1024 count=3145728
3145728+0 records in
3145728+0 records out
3221225472 bytes (3.2 GB) copied, 58.8664 s, 54.7 MB/s
goembed@Goembed:/opt/swap$ sync
goembed@Goembed:/opt/swap$ du -sh swapfile
3.1G swapfile
goembed@Goembed:/opt/swap$ sudo mkswap swapfile
Setting up swapspace version 1, size = 3145724 KiB
no label, UUID=f989bfd3-1a35-4370-986d-7989b3f835bb
oembed@Goembed:/opt/swap$ sudo swapon swapfile
2. 创建成功后的swap分区:
goembed@Goembed:/opt/swap$ free -m
total used free shared buffers cached
Mem: 1987 1911 75 0 4 1360
-/+ buffers/cache: 546 1440
Swap: 5118 302 4816
goembed@Goembed:/opt/swap$ sudo swapon -s
Filename Type Size Used Priority
/dev/sda5 partition 2096124 309748 -1
/opt/swap/swapfile file 3145724 0 -2
注:这个创建的好像是临时swap分区,客户机关机重启之后,创建的swap分区会消失。要关闭windows的时候,可以先挂起客户机,或是不要关闭客户机。。其他方法没有尝试过,有待测试。