Nov 5, 2014
TechnologyFirst Time Build
This build failed for I could not get the repository sync.
I setup the environment on 159’s /media/nfs:
$ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
$ export PATH="$PATH":`pwd`/depot_tools
$ echo $PATH
/home/ubuntu/bin:/home/ubuntu/bin:/home/ubuntu/bin:/home/ubuntu/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/media/nfs/ChromiumOS/depot_tools
$ cat script.sh
#!/bin/sh
cat >./sudo_editor<<EOF
#!/bin/sh
echo Defaults !tty_tickets > $1
echo Defaults timestamp_timeout=180 >> $1
EOF
chmod +x ./sudo_editor
sudo EDITOR=./sudo_editor visudo -f /etc/sudoers.d/relax_requirements
$ export BOARD=x86-generic
$ repo init -u https://git.chromium.org/chromiumos/manifest.git
$ repo sync
Second Time Build
Trusty@Linux59:~/Code/ChromiumOS> pwd
/home/Trusty/Code/ChromiumOS
Trusty@Linux59:~/Code/ChromiumOS> git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
Trusty@Linux59:~/Code/ChromiumOS> export PATH=`pwd`/depot_tools:"$PATH"
Trusty@Linux59:~/Code/ChromiumOS> mkdir chromiumos
Trusty@Linux59:~/Code/ChromiumOS> cd chromiumos/
Trusty@Linux59:~/Code/ChromiumOS/chromiumos> repo init -u https://chromium.googlesource.com/chromiumos/manifest.git --repo-url https://chromium.googlesource.com/external/repo.git
Trusty@Linux59:~/Code/ChromiumOS/chromiumos> repo sync
Trusty@Linux59:~/Code/ChromiumOS/chromiumos> cros_sdk
root's password:
(cr) ((c405e7b...)) Trusty@Linux59 ~/trunk/src/scripts $ export BOARD=x86-generic
(cr) ((c405e7b...)) Trusty@Linux59 ~/trunk/src/scripts $ ./setup_board --board=${BOARD}
# ./set_shared_user_password.sh
# ./build_packages --board=${BOARD}
Nov 5, 2014
TechnologyPrepare
Install following packages:
$ sudo apt-get install build-essential subversion git-core libncurses5-dev zlib1g-dev gawk flex quilt libssl-dev xsltproc libxml-parser-perl
Code
Get the source code from OpenWRT.org:
$ git clone git://git.openwrt.org/openwrt.git
Then Prepare for menuconfig:
$ cd openwrt
$ ./scripts/feeds update -a
$ ./scripts/feeds install -a
$ make menuconfig
Select x86 for Target System.
[] ext4–> Target Images –> ext4
[] Build VMware image files (VMDK)
You could also select for VDI or other formats.
Luci- > collection - > select luci.
Then we could type make
for making out the images.
Nov 5, 2014
TechnologyOnly enabled the nfs server and use the max disk for building, the nfs server runs Redhat RHEL6.2, the same procedure could be applied to CentOS Based system.
Steps:
Query for installed packages in server:
$ rpm -qa nfs-utils
$ rpm -qa rpcbind
Edit the nfs based directory:
# cat /etc/exports
/home/Trusty/share/ *(rw,sync,no_subtree_check,no_root_squash)
Start the service and test:
# service rpcbind start
# service nfs start
In client machine, just type following command for mount the remote nfs directory:
$ sudo mount -t nfs 1xx.xxx.xxx.xx:/home/Trusty/share /mnt/
Make nfs server automatically start when system boot:
# chkconfig nfs on
# chkconfig rpcbind on
Client Machine(59), do following for automatically mount nfs:
$ vim /etc/fstab
# Using NFS
1xx.xxx.xxx.xx:/home/Trusty/share /media/nfs/ nfs rsize=8192,wsize=8192,timeo=14,intr 0 0
$ mount -a
Then everytime this clent machine startup the remote nfs directory will be mounted to local directory.
If you are ubuntu client, then you should install nfs-client via;
sudo apt-get install nfs-common
Nov 5, 2014
TechnologyProblem
The mysql server always keep crash, with following log under /var/log/mysql/error.log:
141104 23:06:46 InnoDB: Fatal error: cannot allocate memory for the buffer pool
So this is the memory problem, we should allocate more memory for our VPS.
Solution
Add swap partition:
First check the swap partition:
root@xxx:/var/log# free -m
total used free shared buffers cached
Mem: 490 464 25 28 61 172
-/+ buffers/cache: 230 259
Swap: 0 0 0
root@xxx:/var/log# swapon -s
Filename Type Size Used Priority
Now create a swapfile:
# dd if=/dev/zero of=/swapfile bs=1M count=1024
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB) copied, 2.16285 s, 496 MB/s
# ls /swapfile -l -h
-rw-r--r-- 1 root root 1.0G Nov 5 00:58 /swapfile
Setting the swapfile:
root@xxx:/var/log# chmod 600 /swapfile
root@xxx:/var/log# swapon /swapfile
swapon: /swapfile: read swap header failed: Invalid argument
root@xxx:/var/log# mkswap /swapfile
Setting up swapspace version 1, size = 1048572 KiB
no label, UUID=64b727dd-0d7e-45ff-9235-cd9ba84b062f
root@xxx:/var/log# swapon /swapfile
Now use free command you could check swap file enabled:
root@xxx:/var/log# free -m
total used free shared buffers cached
Mem: 490 458 31 28 25 229
-/+ buffers/cache: 204 285
Swap: 1023 0 1023
Add it permanately into the /etc/fstab:
/swapfile none swap sw 0 0
Configure the parameters:
root@xxx:/var/log# cat /proc/sys/vm/swappiness
60
root@xxx:/var/log# sysctl vm.swappiness=10
vm.swappiness = 10
root@xxx:/var/log# cat /proc/sys/vm/swappiness
10
root@xxx:/var/log# vim /etc/sysctl.conf
vm.swappiness=10
vm.vfs_cache_pressure = 50
root@xxx:/var/log# cat /proc/sys/vm/vfs_cache_pressure
100
root@xxx:/var/log# cat /proc/sys/vm/vfs_cache_pressure
50
Now the mysql server should be good.
Disable wp-admin login password
Disable the login password.
# vim /etc/apache2/apache2.conf
#<DirectoryMatch ^.*/wp-admin/>
# AuthType Basic
# AuthName "Please login to your droplet via SSH for login details."
# AuthUserFile /etc/apache2/.htpasswd
# Require valid-user
#<DirectoryMatch>
root@xxx:~# service apache2 restart
* Restarting web server apache2
Change the password for login details
$ htpasswd .htpasswd user2
Nov 4, 2014
TechnologyCheetsheet For Using NFS
Following configuration use the 192.168.1.221’s tftp server and 192.168.1.11’s nfs server, why I use different nfs server because 192.168.1.11 runs ubuntu and could reached by nfs client easily.
setenv ipaddr 192.168.1.16
setenv serverip 192.168.1.221
tftpboot ${fdtaddr} am335x-boneblack.dtb
tftpboot ${kloadaddr} uImage
setenv bootargs console=ttyO0,115200n8 root=/dev/nfs rw nfsroot=192.168.1.11:/srv/nfs4/BBBrootfs ip=192.168.1.1 rootwait
bootm ${kloadaddr} - ${fdtaddr}
How to start more services
Current we only got following output:
procd: - init -
//.......
procd: - init complete -
From the Kernel Source code we know the init startup sequence:
$ cd /media/y/embedded/BBB/svnco/trunk/build_dir/target-arm_cortex-a9+vfpv3_uClibc-0.9.33.2_eabi/linux-omap/linux-3.14.4
$ cd init
$ vim main.c
if (!try_to_run_init_process("/etc/preinit") ||
!try_to_run_init_process("/sbin/init") ||
!try_to_run_init_process("/etc/init") ||
!try_to_run_init_process("/bin/init") ||
!try_to_run_init_process("/bin/sh"))
return 0;
The preinit is called by /etc/preinit
, while in this file, we found:
for pi_source_file in /lib/preinit/*; do
. $pi_source_file
done
This means all of the preinit script is listed under NFS Server’s /lib/preinit/ folder.
Add our own preinit startup file:
[root@TrustyArch preinit]# ls
02_default_set_state 30_failsafe_wait 70_initramfs_test 90_init_console~
10_indicate_failsafe 40_run_failsafe_hook 80_mount_root 99_10_failsafe_login
10_indicate_preinit 50_indicate_regular_preinit 90_init_console 99_10_run_init
[root@TrustyArch preinit]# vim 90_init_console
#!/bin/sh
# Copyright (C) 2006-2010 OpenWrt.org
# Copyright (C) 2010 Vertical Communications
init_console() {
preinit_echo "Called 90_init_console here!"
if [ "$pi_suppress_stderr" = "y" ]; then
exec <$M0 >$M1 2>&0
else
exec <$M0 >$M1 2>$M2
fi
}
boot_hook_add preinit_essential init_console
[root@TrustyArch preinit]# chmod 777 90_init_console
[root@TrustyArch preinit]# rm -f 90_init_console~
Now restart the BBB, to see if really take effects.
Also add a new file named 50_choose_console, with the setted M0 and M1, you could get your console.
$ cat 50_choose_console
#!/bin/sh
# Copyright (C) 2006-2010 OpenWrt.org
# Copyright (C) 2010 Vertical Communications
choose_console() {
# the shell really doesn't like having stdin/out closed
# that's why we use /dev/pty/m0 and m1 (or equivalent) as replacement
# for /dev/console if there's no serial console available
if grep -q devfs /proc/filesystems; then
M0=/dev/pty/m0
M1=/dev/pty/m1
M2=/dev/pty/m1
elif [ -x /sbin/hotplug2 ]; then
M0=/dev/ptmx
M1=/dev/ptmx
M2=/dev/ptmx
elif [ -x /sbin/udevd ]; then
M0=/dev/pty/ptmx
M1=/dev/pty/ptmx
M2=/dev/pty/ptmx
fi
dd if=/dev/console of=/dev/null bs=1 count=0 >/dev/null 2>/dev/null && {
M0=/dev/console
M1=/dev/console
M2=/dev/console
}
}
boot_hook_add preinit_essential choose_console
But I still cannot get the terminal.