HOWTO OlinuXino A20 + SATA + ownCloud

Started by fromcologne, February 13, 2014, 07:04:43 AM

Previous topic - Next topic

fromcologne

HOWTO setup an OlinuXino A20 with RootFS on SATA and ownCloud

- Debian 7 (wheezy)
- Kernel linux-sunxi 3.4.75+
- ownCloud 6.0

1. Step: Prepare a kernel with SATA/AHCI support
To install a rootfs on SATA you have to build your own kernel with sata/ahci drivers inside the kernel and not as a module.

Follow the steps in this excellent description:
How to make bootable SD card with Debian Linux for A20-OLinuXino-MICRO based on Kernel 3.4
http://olimex.wordpress.com/2013/09/18/7795/

During "3. Building kernel sources for Olinuxino-A20-Micro" you have to do some additional work.

The config script for the compiler needs this two parameters:
CONFIG_SATA_AHCI_PLATFORM=y
CONFIG_SW_SATA_AHCI_PLATFORM=y

You can find this parameters in the file olinuxinoa20_defconfig (edit the file) or you can use
# make ARCH=arm menuconfig

After this follow the description again and you will get a bootable microSD card.

Remarks:
--------
Because I had to develop this on a headless OlinuXino A20 [didn´t found a display working with the onboard HDMI port  :( ] I need some special editing.
I mounted the second partition of the microSD (with the rootfs) on my Debian development system
# mount /dev/mmcblk0p2 /mnt/sd
and did this patches:

1. IP address
Default kernel don´t use DHCP client. You have to edit the file /etc/network/interfaces
# nano /mnt/sd/etc/network/interfaces
it should look like this:
...
auto eth0
iface eth0 inet dhcp
...

   
or if you don´t have DHCP server in your network:
...
auto eth0
iface eth0 inet static
   address 192.168.1.104
   netmask 255.255.255.0
   gateway 192.168.1.1
   dns-nameservers 192.168.1.1
...

I use a static IP address and additional I had to edit the file /etc/resolv.conf
# nano /mnt/sd/etc/resolv.conf
it should look like this:
...
domain yourdomain.local
nameserver xxx.xxx.xxx.xxx
nameserver yyy.yyy.yyy.yyy
...

(I´m not sure if this is necessary if you use DHCP. Try it.)

2. (optional for headless server)
I connect with SSH to the OlinuXino A20 I get an error by xfce. The reason is that my SSH login tries a second start of xfce triggered by a command in /.bashrc
# nano /mnt/sd/root/.bashrc
insert a comment character. It should look like this:
...
#startxfce4&
...

   
If you are ready, unmount the microSD from your development system:
# sync
# umount /dev/mmcblk0p2

   
2. Step: First boot and test
Boot your OlinuXino A20 with the new microSD card and do testing.

3. Step: Install rootfs in SATA
We need partitions on the harddisk /dev/sata.
I followed the description above "How to make bootable SD card... "
# fdisk /dev/sda
Like in the description delete any old partition and create two new partitions.
Format the two partitions:
# mkfs.vfat /dev/sda1
# mkfs.ext4 /dev/sda2

(I´m not sure but I think it makes no difference if you use ext3 instead)

Download the file debian_34_fs.tgz to /home

Mount the second partition of the harddisk and untar the rootfs
# mount /dev/sda2 /mnt/hdd
# tar xzvf /home/debian_34_fs.tgz -C /mnt/hdd


Remark: during my first try to untar I got error messages time stamps are in the future. Reason was wrong time/date of the OlinuXino A20. You can set the time/date manually with:
# date 021117562014
the syntax is MMDDhhmmYYYY



Now you have to do the same steps like in the kernel build description. First delete modules with wrong version an wrong firmware files. Then copy the right on from your microSD to /dev/sata2:
# rm -rf /mnt/hdd/lib/modules/3.4.43+/
# rm -rf /mnt/hdd/lib/firmware/
# cp -rfv /lib/modules/3.4.75+/ /mnt/hdd/lib/modules/
# cp -rfv /lib/firmware/ /mnt/hdd/lib/


Copy your patched config files from microSD to /dev/sda2:
# cp -fv /etc/network/interfaces /mnt/hdd/etc/network/interfaces
# cp -fv /etc/resolv.conf /mnt/hdd/etc/resolv.conf
# cp -fv /root/.bashrc /mnt/hdd/root/.bashrc


Umnount harddisk:
# sync
# unmount /dev/sda2


Now you have to change the boot process to use rootfs on /dev/sda2. The boot information is in the first partition of the microSD.
# mount /dev/mmcblk0p1 /mnt/sd

Create a file uEnv.txt with only one line content (with the nano editor):
root=/dev/sda2
In other descriptions about uEnv.txt you find a lot of other parameters, but I only need this one.

Unmount:
# sync
# umount /dev/mmcblk0p1


Reboot:
# shutdown -r now

After the reboot the df command should looks like this:
# df
Filesystem     1K-blocks    Used Available Use% Mounted on
rootfs         307648976 2685100 289336188   1% /
/dev/root      307648976 2685100 289336188   1% /
devtmpfs          446572       0    446572   0% /dev
tmpfs              89348     228     89120   1% /run
tmpfs               5120       0      5120   0% /run/lock
tmpfs             178680       0    178680   0% /run/shm


Congratulations. Your rootfs is on the harddisk and microSD is only used during boot process.

4. Step: preparations for owncloud installation
The next steps are intellectual property of owncloud.org  :) and you can find more informationes here:
http://software.opensuse.org/download/package?project=isv:ownCloud:community&package=owncloud

More and detailled information you can find here:
http://doc.owncloud.org/server/4.5/admin_manual/installation.html

Installation:
# echo 'deb http://download.opensuse.org/repositories/isv:/ownCloud:/community/Debian_7.0/ /' >> /etc/apt/sources.list.d/owncloud.list
# wget http://download.opensuse.org/repositories/isv:ownCloud:community/Debian_7.0/Release.key
# apt-key add - < Release.key 
# apt-get update
# apt-get install owncloud


I prefere MySQL database
# apt-get install mysql-server
During installation you are asked for a mysql root password. You will need it for the first start of owncloud later.

The first start of your new ownCloud server (be patient !)
http://[yourIPaddress]/owncloud

Click on the Advanced options to show the database configuration options.
Enter MySQL admin password, any DB name you want, MySQL instance is localhost.

Ready !!!

Now you have an excelllent system to sync calender, contacts and files of all your gadgets like PC, tablets, smartphones etc. Read the desription on their homepage www.owncloud.org and you will be impressed. Forget all the "big brother" cloud solutions.

sanzoghenzo

thanks fromcologne for this great tutorial! Only one thing: is it necessary to make the fat partition on the data disk? I think it should suffice to have it on the SD.
Now I have to manage how to convert my hfs+ 2TB seagate goflex in ext4 without losing all the data :P

fromcologne

Quote from: sanzoghenzo on February 16, 2014, 10:27:02 PM
is it necessary to make the fat partition on the data disk?

You are right. It´s not necessary because the A20 can´t boot from sata.
But it is easier to describe if these steps are analogous to the preparation of the SD card ;-)

barish

Actually, for me it was not necessary to compile the kernel. I found out by accident. I connected a prepared SATA-disk and added the setting to load Linux from this disk (by putting uEnv.txt with content "root=/dev/sda2" into the boot partition), and forgot to replace the kernel. But it worked, the A20 is now using the SATA disk as rootFS. Maybe Olimex changed the kernel to support SATA by default now?

kooth

Hello everyone.  This is my first post on this forum.  I have looked for days on how to turn on the power for a SATA drive, but I have only found with pin controls it.  The schematics and data sheets say that pin 22 controls the 5-volt SATA power connector; however, I'm new to this board and I have no idea how to set this.

Is there a command, or do I need to patch the kernel?

Sorry if this has been answered.

Gerrit

Quote from: kooth on May 10, 2015, 09:23:20 PM
Hello everyone.  This is my first post on this forum.  I have looked for days on how to turn on the power for a SATA drive, but I have only found with pin controls it.  The schematics and data sheets say that pin 22 controls the 5-volt SATA power connector; however, I'm new to this board and I have no idea how to set this.

Is there a command, or do I need to patch the kernel?

Sorry if this has been answered.

If you use the image provided Olimux you should not have to do anything, just connect the drive with the right connectors.

Check for the next lines in script.fex if you don't have 5 volt at the power connector
[sata_para]
sata_used = 1
sata_power_en = port:PC03<1><default><default><0>

kooth

Thanks Gerrit:

Well, I do have an image provided by Olimex, and it's not enabled by default.  All of the data sheets and schematics only mention that there is a way to turn it on, or to modify the jumper to permanently turn it on.  I do not want to modify the hardware, so hence my question about the kernel or a command.

You seemed to have answered my question by stating that I need to modify the kernel, so thanks for that.  I have been working on the Nitrogen6x boards from Boundary Systems and the Yocto tool chain.  Those boards in that project used Fedora for the OS -- I know nothing about Debian.  I guess it's time to hit the books.

JohnS

If it's just the fex you don't need to change the kernel.

John

kooth


Thanks JohnS, but what the flux is a fex? ;)  Just kidding -- I'll read up on it.

Thanks again ...

Kooth

Gerrit

#9
Well, I do have an image provided by Olimex, and it's not enabled by default.

I use the Image provided by them and and it just worked, so i am almost sure that something else is wrong.

Some things to check

- Does the drive need 12 Volt, if yes then it wont work, you only have 5 Volt
- Look for the Amperage on the disk, is this within the limits from your power source combined with the what the board is using.
- Check with the dmesg command for any errors on sata

kooth

OK: You win.  My new drive is a 2.5" 120GB solid-state drive (my first of this type) is so quiet that I didn't think it was running.  That should prove to me that the instructions don't always say what I think I read.

Thanks to everyone for your help (even the snarky posts.)  This is an awesome board!