Install ubuntu-core-14 minimum core for Banana PI

Source: Internet
Author: User
Tags spl

Banana Pi (BPI) is more powerful than Raspberry Pi, features more, can run Linux and Android
System, and cheaper single-board micro-computer, see: www.bananapi.com

There are several common system IMG available on the BPI official website
For download (http://www.lemaker.org/resources/9-38/image_files.html), can be directly burned to SD
The card is used to start BPI; In this paper, another method of self-built BPI system is tested, which can be customized according to the needs of the system. This article intends to try to build a minimal basic Linux
Server system; For convenience, this article directly selects the mature core provided by Ubuntu which is currently widely used as

Rootfs, this can not only ensure stable and reliable system, but also convenient for later function customization, save time and energy.



= = A. Preparation work = =
First, the required hardware

Need Banana PI Development Board piece;

A computer that is running a Linux system (Linux virtual machines are also OK);
Capacity greater than 1GB SD card, or TF with card sleeve, and the corresponding card reader device;
Also prepare a 4GB SD card for burning the existing. img To start BPI as a secondary operation;

Second, the required software

Download from Ubuntu website http://cdimage.ubuntu.com/ubuntu-core/releases/

ubuntu-core-14.04.1-core-armhf.tar.gz package file (60MB)
From Banana PI website http://www.lemaker.org/resources/9-38/image_files.html
Download the raspbian_for_bananapi_v3_0.img package file
From Sunxi website http://dl.linux-sunxi.org/nightly/u-boot-sunxi/u-boot-sunxi/u-boot-sunxi-latest/

Download U-BOOT-SUNXI-BANANAPI.TAR.XZ Package


= = B. Main steps = =
One, SD card partition
Connect the SD card to the Linux pc to view the device number:

$ sudo fdisk-l

If the system is not connected to another device, usually this SD card device name is:/DEV/SDB; The following assumes that the card is/dev/sdb, to be replaced according to the actual situation, or the consequences of the wrong device name is difficult to material;

into the Fdisk partition program, using n subcommand to divide the card space into two partitions, prompting for the first partition size input +30m, the other parameters are entered to accept the default value;

$ sudo fdisk/dev/sdb

View the partition with the P subcommand, confirm the error, enter the W Sub-command to confirm the partition write card device and exit;

Second, format the partition
The two partitions of SD card are formatted into VFAT and Ext4 file system respectively;

$ sudo mkfs.vfat/dev/sdb1
$ sudo mkfs.ext4/dev/sdb2

Third, write the U-boot boot code
Remove the U-boot-sunxi-with-spl.bin file from the downloaded U-BOOT-SUNXI-BANANAPI.TAR.XZ package;

First, clear the contents of the previous SD card;

$ sudo dd if=/dev/zero of=/dev/sdb bs=1k count=1023 seek=1

Then write the startup code and data at a specific location

$ sudo dd if=/path/to/u-boot-sunxi-with-spl.bin of=/dev/sdb bs=1024 seek=8

Note: The command line here assumes that all downloaded packages are stored in the/path/to virtual directory, and the operation must be replaced by the actual directory;


Iv. Installing kernel boot files
If willing, the Linux kernel files can choose to compile themselves, and here for convenience, directly from the vendor-provided IMG package, which is selected from
Raspbian_for_bananapi_v3_0.img
The kernel file is removed from the package, mainly on these three: (Uimage,script.bin,uenv.txt);

First, look at the initial block position of the first partition in the IMG package, which is assumed to be 8192, multiply it by the 512 result 4194304 into the following command;

$ sudo mkdir/mnt/img
$ fdisk-l/path/to/raspbian_for_bananapi_v3_0.img
$ sudo mount-t vfat-o loop,offset=4194304
/path/to/raspbian_for_bananapi_v3_0.img/mnt/img

After the Mount succeeds, the three kernel files can be copied from the/mnt/img directory;

$ cp/mnt/img/uenv.txt./
$ cp/mnt/img/bananapi/uimage./
$ cp/mnt/img/bananapi/script.bin./
$ sudo umount/mnt/img

Because of the./raspbian_for_bananapi_v3_0.img package, the kernel is placed in a subdirectory./bananapi
, we now intend to put the three kernel files directly in the SD card first partition root directory, so we also need to copy the UEnv.txt content with VI
command to edit a little bit, remove the directory path of the kernel file, so that its contents are written like this, and then save the Exit VI;

bootargs=console=ttys0,115200 console=tty0
Disp.screen0_output_mode=edid:1280x720p50 hdmi.audio=edid:0
Console=tty1 ROOT=/DEV/MMCBLK0P2 ROOTFSTYPE=EXT4 Elevator=deadline
Rootwait
Aload_script=fatload MMC 0 0x43000000 script.bin;
Aload_kernel=fatload MMC 0 0x48000000 uimage; Bootm 0x48000000;
Uenvcmd=run Aload_script Aload_kernel

After the kernel file is extracted, it can be copied to the first partition of SD card;

$ sudo mkdir/mnt/sd
$ sudo mount-o vfat/dev/sdb1/mnt/sd
$ cp uEnv.txt Script.bin UIMAGE/MNT/SD
$ sudo umount/mnt/sd

If you need to adjust the parameters in the Script.bin, such as AV port to connect the TV, you need to first use Bin2fex
Software to convert the file format into a text file, and then make changes, see: Linux-sunxi.org/fex_guide

V. Installation of ROOTFS
Release the downloaded ubuntu-core-14.04.1-core-armhf.tar.gz package file directly to the second partition of the SD card;

$ sudo mount/dev/sdb2/mnt/sd
$ cd/mnt/sd
$ TAR/PATH/TO/XZVF ubuntu-core-14.04.1-core-armhf.tar.gz

Vi. installing modules and firmware files
Using the same method as the previous fourth step, remove the kernel corresponding Modules/firmware file directly from the ready-made raspbian_for_bananapi_v3_0.img;

Find out the starting block position of the second partition in the IMG package, which is assumed to be 122880, multiply it by 512 result 62914560 into the following command;

$ fdisk-l/path/to/raspbian_for_bananapi_v3_0.img
$ sudo mount-t vfat-o loop,offset=62914560
/path/to/raspbian_for_bananapi_v3_0.img/mnt/img

After the mount succeeds, copy the kernel version corresponding Modules/firmware hardware driver related files from the/mnt/img directory to/MNT/SD;

$ sudo cp-r/mnt/img/lib/modules/3.4.90/mnt/sd/lib/modules

Copy DNS server address information from the host system resolv.conf to/MNT/SD/ETC, you may need to install the software online later;

$ sudo cp-p/etc/resolv.conf/mnt/etc

Complete the above steps, the SD card core system required files are basically ready, just wait for the new system configuration can start to work;

Vii. preliminary configuration of the new system
In order to complete the basic configuration of the new system in SD card, it is necessary to use the chroot command to set the root password, install the necessary packages and so on.

Since all of the above procedures are performed on a x86 Linux Master System, and the chroot needs to use the main system of the ARM architecture, the use of another SD
The card starts the Banana PI as the main system, and if you use the main system PC itself as the ARM architecture, you do not have to restart BPI
, can directly benefit the main system for the rest of the operation;

In order to switch to the BPI arm Master System for chroot operation, you must first uninstall the SD card mounted on the x86 system and clear the temporary directory;

$ sync
$ sudo umount/mnt/img
$ sudo umount/mnt/sd
$ sudo rm-r/mnt/img/mnt/sd

Start BPI with another SD card that has been written, and connect the new system SD card to the BPI USB port via the card reader, first check the system for the automatically recognized USB
Device to determine the device name of the new SD card, here is the assumption that the new SD card device name is:/DEV/SDB

$ lsusb
$ lsblk

Mount the second partition of the new SD card to the/MNT directory and enter the chroot state;

$ sudo mount/dev/sdb2/mnt
$ sudo chroot/mnt/bin/bash

After normal entry into chroot, all commands are operated directly against the new system; First, the root password is set;

# passwd

Then configure the host name, set Noatime, add user account, and turn on the network interface;

# echo "Ucore14" >/etc/hostname
# adduser NEWID

Insert a line in the boot command file/etc/rc.local: Mount-o remount-o noatime/To improve performance while preventing frequent erasure of the SD card;

# vi/etc/rc.local

Set the time zone;

# mv/etc/localtime/etc/localtime.0
# ln-s/usr/share/zoneinfo/asia/shanghai/etc/localtime

Enter the NIC configuration in the/etc/network/interfaces, for example, if you intend to connect the router in a DHCP manner, fill in the following:

Auto Lo
Iface Lo inet Loopback

Auto Eth0
Allow-hotplug eth0
Iface eth0 inet DHCP

If you also need to configure WiFi network, you must purchase another compatible USB interface WiFi card, and then through the Wpa_supplicant
Software to configure, for the time being not consider the installation of WiFi network card, the new system to run properly and then configure other subsystems can;

At this point, one of the most basic Ubuntu core system is installed, if everything is OK, you can use this SD card to properly start Banana PI
, but be aware that the downloaded ubuntu-core-14.04.1-core-armhf.tar.gz package file does not have sshd installed
software package, which means that you cannot telnet into the system, if you do not have an HDMI monitor available, or if your Banana PI only operates as a server, exit Chroot
Before the state, it is necessary to install the SSH package, to do this, you need to jump to the next step;

If you do not intend to install the SSH service at this time, and no further configuration and operation, you may consider exiting the chroot state and uninstalling the SD card;

# exit
# Sync
# sudo umount/mnt

Eight, install SSH remote login (no screen required)

Continue to install the SSH package in the chroot state above, and re-enter chroot if you have previously exited chroot;


# Apt-get Update
# apt-get Install SSH

This command requires an online download package, which is also preceded by the need to replicate/etc/resolv.conf to the SD card beforehand Rootfs
, usually a few minutes to download the installation is complete;

Due to the default installation of the Sshd_config configuration, based on security considerations, do not allow password remote login to the root account and the empty password telnet, only allowed to use
Ssh-key telnet root account, here to facilitate login, decided to temporarily turn on password login, edit/etc/ssh/sshd_config configuration file;

# Vi/etc/ssh/sshd_config

Change the value of this setting from "Without-password" to "yes", or comment out the original setting line, and then enter the new setting line as follows:

# Permitrootlogin Without-password
Permitrootlogin Yes

After saving this setting modification, the necessary installation and configuration are complete, exit chroot, uninstall SD card and shut down;

# exit
# Sync
# sudo umount/mnt
# sudo Poweroff

At this point, the SD card already contains a bootable Ubuntu Core 14.04 for Banana PI; Insert this SD card into the Banana
Pi power on, if smooth, soon can be started out, and can ssh telnet into the system, the above configuration Banana PI is automatically obtained from the router by DHCP
IP address, the IP address assigned by the router to BPI can be viewed in the DHCP section of the router management interface before SSH login;

Because Ubuntu core is only a core and does not contain any other applications, such as: APACHE, MYSQL, PHP, X11, OFFICE
Wait, however, can use the Debian Department of Apt-get install xxx very convenient installation of the rest of the required software ...


= = C. Summary = =

The above test steps are implemented in the target SD card from the partition start to configure a bootable Banana PI of Ubuntu Core

System, the operation of more steps, in order to save trouble, you can also use the reverse operation, that is, directly in the SD card burning a ready-made IMG system, and then with the target Rootfs
Replace the original system, there are many rootfs on the internet for ARM architecture
Available, small decompression only about 30M, such as: linaro-image-minimal-initramfs-genericarmv7a; however, in order to facilitate the installation of application software, or choose
Debian Core, Ubuntu core this kind to be convenient, although the size is slightly larger;

In addition, based on the above steps, a little bit of flexibility, you can make your own. IMG System, the process is roughly the same, just replace the SD card with an. img File and

The. img file is mounted as a loop device, and the operation is not detailed here;


This is the end of this article, you are welcome to Exchange ~

----------------------------------------------------------------

Welcome you to reprint my article.

Reprint Please specify: Turn from Yorhom's Game box

Http://blog.csdn.net/yorhomwang

Welcome to follow my blog

Install ubuntu-core-14 minimum core for Banana PI

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.