Cubian installation
Copy to SD-card
Download the Cubian image via torrent and unpack it.
Check where your SD-card is located via
sudo lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL
in my case it was /dev/mmcblk0
. Then copy the image to the sd-card via
sudo dd if=Cubian-nano-x1-a20-cubietruck-hdmi.img of=/dev/mmcblk0 bs=4096; sync
Let the machine boot, login via cubie:cubie
and get the IP via ifconfig
. From there on you can operate remotely via SSH. SSH into the machine
ssh [email protected] -p 36000
and first make the necessary updates.
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install cubian-update
sudo cubian-update
Compile custom kernel
Next, we want to compile our custom kernel with the newest version available. Switch to a x86 Debian-based machine (I used a virtual machine via Virtualbox).
Switch to root
su
and create a new directory in which we operate
mkdir /kernel
cd /kernel
Install all necessary dependencies first
dpkg --add-architecture i386
sudo apt-get install libncurses5-dev make build-essential u-boot-tools curl git
and clone the necessary repositories
git clone https://github.com/mmplayer/linux-sunxi.git -b dev/sunxi-3.4 --depth=1
git clone https://github.com/mmplayer/sunxi-kernel-config
git clone https://github.com/cubieplayer/Toolchain.git
Export the toolchain's path to your current path so you can use it's executables.
export PATH="/kernel/Toolchain/bin:$PATH"
Copy the default configuration for cubietruck (or your device)
cp ./sunxi-kernel-config/config-cubian-base-sun7i-3.4 ./linux-sunxi/.config
and enter the kernel directory
cd linux-sunxi
Create the configuration file
make ARCH=arm menuconfig
and select "Load alternative configuration file" in order to open your .config
file. If you plan on using Docker you will need to enable two flags
CONFIG_POSIX_MQUEUE
CONFIG_SECCOMP
You can find these flags by entering /
and search for these parameters. Go back to your main directory
cd /kernel
and start compiling the kernel
make -j4 -C ./linux-sunxi ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- uImage modules
The -j4
flag indicates how many threads to use (i.e. four CPU`s in this case). When the process finishes (which takes a while), you'll create two compressed files needed for copying to your cubie.
mkdir fat
cp ./linux-sunxi/arch/arm/boot/uImage fat/uImage
cd fat
tar -czf kernel-vfat.tar.gz *
md5sum kernel-vfat.tar.gz > kernel-vfat.md5
mv kernel-vfat* ..
cd ..
This stores the kernel image, next you'll need all libraries and headers.
mkdir rootfs
make -C ./linux-sunxi ARCH=arm INSTALL_MOD_PATH=../rootfs modules_install
make -C ./linux-sunxi ARCH=arm INSTALL_HDR_PATH=../rootfs/usr headers_install
cd rootfs
MODULEDIR=lib/modules/$(ls lib/modules)
rm -rf $MODULEDIR/build
rm -rf $MODULEDIR/source
mkdir -p $MODULEDIR/build
ln -sf /usr/include $MODULEDIR/build/include
tar -czf kernel-rootfs.tar.gz *
md5sum kernel-rootfs.tar.gz > kernel-rootfs.md5
mv kernel-rootfs* ..
cd ..
Then copy the two files kernel-rootfs.tar.gz
and kernel-vfat.tar.gz
to your cubie. If you plan on distributing these files, md5
hashes are automatically created with the commands above.
SSH into the cubie, switch to root and switch to the directory in which the files are placed.
su -root
cd /kernel
Create directories and unpack
mkdir vfat
mkdir rootfs
tar zxvf kernel-vfat.tar.gz -C vfat/
tar zxvf kernel-rootfs.tar.gz -C rootfs/
And check where your SD-card is located via
lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT,LABE
Create two mount points and mount the SD-card's partitions
mkdir -p /mnt/p1
mkdir -p /mnt/p2
mount -t ext4 /dev/mmcblk0p1 /mnt/p1/
mount -t ext4 /dev/mmcblk0p2 /mnt/p2/
Then copy over the files you have created, sync and unmount.
cp -r ./vfat/* /mnt/p1/
cp -r ./rootfs/* /mnt/p2/
sync
umount /mnt/p1
umount /mnt/p2
Finally, reboot and enjoy the new kernel
reboot
Moving RootFS to SSD
If you have an SSD and want to increase performance and lifetime of your SD-card, you'll want to boot from the SSD instead. Check where the SSD and SD-card are located
sudo lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL
In my case the SSD is available under /dev/sda1
and the SD-card under /dev/mmcblk0
.
Next, create mount points and format the SSD using ext4. Careful, this deletes all exisiting data on the SSD.
mkfs.ext4 /dev/sda1
mount /dev/sda1 /tmp/target
Then mount the second partiton of the SD-card containing the rootfs.
mkdir /tmp/2 /tmp/target
mount /dev/mmcblk0p2 /tmp/2
Then move the rootfs
(cd /tmp/2; tar --backup -c *) |tar -C /tmp/target -xv
sync and unmount
sync
umount /tmp/2
umount /tmp/target
Mount the first paritions containing the boot loader and kernel parameters
mkdir /tmp/1
mount /dev/mmcblk0p1 /tmp/1
and there change the uEnv.txt
file
nano /tmp/1/uEnv.txt
and adjust the root=
parameter to point to your SSD.
`root=/dev/sda1`
Sync to disk, unmount and reboot
sync
unmount /tmp/1
reboot
The system should now boot from the ssd, you can check the increase read and write performance
sudo dd if=/dev/zero of=/dev/sdb2 bs=1M count=5000
sudo dd if=/dev/sda1 of=/dev/null bs=1M count=5000
which should be around R 100 mb/s, and W 120-140 mb/s
Install Docker
First make updates on the cubie
sudo apt-get update
sudo apt-get upgrade
sudo cubian-update
We will use the Docker ports provided by Hypriot, which greatly facilitate the process.
Install additional dependencies
apt-get install curl apt-transport-https
And add the Hypriot repository, as well as backports and sid (unstable) as the newest Docker version depends on newer libraries.
curl https://packagecloud.io/gpg.key | sudo apt-key add -
udo bash -c 'cat > /etc/apt/sources.list.d/Hypriot_Schatzkiste.list' << EOF
deb https://packagecloud.io/Hypriot/Schatzkiste/debian/ wheezy main
deb http://http.debian.net/debian wheezy-backports main
deb http://ftp.debian.org/debian sid main
EOF
Make updates and install
sudo apt-get update
sudo apt-get -y install --no-install- recommends docker-hypriot
sudo apt-get -y install cgroupfs-mount bridge-utils
Add your current user to the Docker group so you don't have to type sudo
before every docker command.
sudo usermod -aG docker $(whoami)
Install additional dependencies from the unstable repository
sudo apt-get -yqq -t sid install libc6 libc6-dev libc6-dbg libdevmapper-dev
And then remove this repository again
sudo sed -i "/sid main/s/^/#/g" /etc/apt/sources.list.d/Hypriot_Schatzkiste.list
sudo apt-get clean
sudo apt-get update
The -d
daemon flag was removed in the newest Docker version, but is in some cases still used in the Docker upstart script.
sudo nano /etc/init.d/docker
and replace the -d
flag with daemon
. You'll also need to set a different storage driver.
sudo nano /etc/default/docker
And set --storage-driver=devicemapper
. You can check your configured kernel via a shell script provided by Docker
wget https://raw.githubusercontent.com/docker/docker/master/contrib/check-config.sh
sudo chmod +x check-config.sh
./check-config.sh
Reboot the machine, and check the docker version.
docker version
which should resemble something like this
Client:
Version: 1.10.0
API version: 1.22
Go version: go1.4.3
Git commit: 590d5108
Built: Thu Feb 4 20:37:07 2016
OS/Arch: linux/arm
Server:
Version: 1.10.0
API version: 1.22
Go version: go1.4.3
Git commit: 590d5108
Built: Thu Feb 4 20:37:07 2016
OS/Arch: linux/arm
If you get an error about the docker daemon, that means that upstart couldn't start the docker daemon. You can check the status of the service via
sudo service docker status
and check the flog files for errors in
nano /var/log/docker.log
You can then install other libraries such as docker-compose
.
sudo apt-get install docker-compose
And now you have a cubietruck with an up-to-date kernel and Docker installed! Don't forget to change default username and password.