CUBOX -i4 Pro with Arch Linux

DSC_0107

Finally received my Cubox -i4 Pro from Solid-Run and opted to install Arch Linux on it. Arch has no training wheels whatsoever so the goal here was to learn as much about Linux as possible.

First of all you need another Linux system to pull this off. Well there are other ways but this is easiest. Go here

Start with “Using u-boot and SPL”.

Now it just doesn’t say it at all on this page and it drove me nuts for a bit but install the two files in steps 1 and 2 into a folder on the Linux machine NOT the SD card.

Insert your micro SD card into the linux box (usually through a USB adapter). Now open a terminal and type:

blkid

That will tell you the name of your device. Should see a list. Mine ended up being /dev/sdd

If you aren’t sure which one it is take note of your list. Pull out the micro SD card and then run blkid again. Note the one that is not there anymore. Easy.

Now run the two commands:

chmod +x make-sdcard
./make-sdcard /dev/sdX ArchLinuxARM.Cubox-i_20012014.bz2
Where the “X” is the designation of your drive.

Sit and wait a few minutes and you are done. Your Arch installation is complete. Remove your SD card and install into the Cubox -i and plug it in and boot.

Your user name is root and your password is root. Soon as you log in do a

passwd root and change your password.

Now do the post install instructions as noted in the web page above.

pacman -Sy
pacman -Su
pacman -S lxde xf86-video-fbdev xorg-xinit

This installs the LXDE desktop environment. I played around with several of them and they seem to all have some issues. LXDE is lightweight, fast, lean and mean. Yes there are more windows like environments but they run like a dog. Anyway you can change it later.

now you can boot into a graphical environment if you want to by typing:

xinit /usr/bin/lxsession

Now open a terminal

lxde

Time to do some do stuff as root.

You need to get your wifi setup, then set up the date and time, and add a user.

In a terminal type

netctl

This is your network controller. If it doesn’t start or tell you it isn’t there type

pacman -S netctl

This will install it.

Then type

wifi-menu

Here’s what happens:

Image 1-18-15 at 8.14 PM

Note my network’s name is John’s Wi-Fi Network and just take note this is going to be problematic. But anyway select your network and put in your WPA or WPA2 password. BAM - WIFI. You have Arch Linux connected to the internet. Done? Not even close.

Now you have to make it start at boot.

Go to /etc/netctl in your file manager.

Image 1-18-15 at 8.15 PM

See my file called wlan0? Before it was called wlan0-John’s-Wi-Fi-Network. The next step doesn’t like hyphens so rename the file to anything without a hyphen. For ease of use I just called it wlan0

Now to initialize it at boot type this:

netctl enable wlan0

Okay, getting there. Now if you check your system tray you might notice Arch Linux thinks it’s December 1969. That’s cool. I’m going to Southern California to go see The Doors in concert and then I’ll be right back.

Okay time to set the time.

Type
timedatectl status

timedatectl list-timezones

timedatectl set-timezone Asia/Tokyo

Asia/Tokyo is me. Set yours to where you are.

Now set the time.

if you don’t have ntpd type

pacman -S ntp

now type

ntpd -qg

That should set your system time. Now you have to make sure it happens at boot. NTP that is.

timedatectl set-ntp 1

Now to make it all better go to /etc/ntp.conf and add the word “iburst” after each NTP pool server
Image 1-18-15 at 8.16 PM

Save and then go to /etc/netctl folder and open your profile settings as root (remember my profile name was wlan0). Add this to the end.

ExecUpPost=‘/usr/bin/ntpd -qg || true’

Time should set perfectly on every boot.


Okay now you have wifi, and the system time is set. Time to add a user.

This can get complicated and I urge you to seek out the man pages but I’m going to keep it simple here. Users and Groups is tough stuff on Linux and tougher on Arch.

Okay I’m adding the user John.

Type this:

useradd -m -g users -G wheel -s /bin/bash john

Whew!

Now type

passwd john

And set your password.

Now log out.

At the shell type

su john

ok now you want to start your graphical interface again

init /usr/bin/lxsession

Now you are logged in as a user. Now you need to get on the internet probably. I could have had you do this as root but Chromium browser doesn’t work as root. Only a user. I can’t find Firefox presumably they don’t have an ARM7 architecture port of it yet. Maybe. I don’t know. Midori is a good browser as well but I went with Chromium.

Go to your terminal again and do:

su
then add your root password when it asks then:

pacman -S chromium

Okay, now you have a browser. The world is yours.

Every computer I own has to stream music via Logitech Media Server and a player called Squeezelite. For the life of me I haven’t cracked the code on installing logitechmediaserver yet. I has to be compiled and it’s going to be a challenge. For now I already have multiple squeezebox servers in my home so all I need to do is point my browser towards another one and initiate a player on my Arch box. I’ll use squeezelite as the player.

Do this as superuser:
su
cd
mkdir squeezelite
cd squeezelite

wget
https://squeezelite.googlecode.com/files/squeezelite-armv6

Now do this:


mv ./squeezelite-armv6 /usr/bin/squeezelite

This moves the file and renames it. Easier to call, easier to type.

Now this to change the permissions:

chmod ug+x /usr/bin/squeezelite


If you did everything right it will list your output devices when you type this at a terminal (make sure you sill super user):

squeezelite -l

Image 1-18-15 at 8.16 PM
Note near the top it says front:CARD=DAC,DEV=0

Yer gonna need that. Copy it.

Also note there are a lot of devices to choose from on your onboard sound or external USB DAC. Choose the one you intend to use. I always use an external DAC for sound to pump through my stereo. It sounds better.



Now look at what I’m doing. I’m calling squeezelite, telling it what output device to use, giving it a name, and telling it where it lives. Dash o is the output device, dash n is the name, dash s is the server.


Image 1-18-15 at 8.16 PM

Type this:

squeezelite -o front:CARD=DAC,DEV=0 -n ArchSqueeze -s 10.0.1.43 -d all=debug

10.0.1.43 is my server address. You will need to find your own squeezebox server.

To start squeezelite at boot do this. Create a new file in /etc/systemd/system called squeezelite.service and add the following code to it.

[Unit]
Description=Squeezelite

[Service]
ExecStart=/usr/bin/squeezelite -o front:CARD=DAC,DEV=0 -n ArchSqueeze -s 10.0.1.43

[Install]
WantedBy=multi-user.target

Then as root do
chmod 755 /etc/systemd/system/squeezelite.service


Image 1-18-15 at 8.17 PM

Now do this to start it at boot:

systemctl enable squeezelite.service

Hit enter then open your browser and see if the ArchSqueeze name shows up as a player.


Image 1-18-15 at 8.17 PM

Yer doing it.


Now lets set up Samba.

As root:

pacman -S samba

then

systemctl start smbd
systemctl start nmbd

then

systemctl enable smbd
systemctl enable nmbd

Now go here and follow the directions for creating the user share path.

Add a user

pdbedit -a -u john

smbpasswd john

add your password when prompted.

Modify your samba configuration in /etc/samba/smb.conf

Note that I have changed my workgroup name to JOHN. Change yours accordingly. Make sure encrypt passwords (further down, out of sight) is set to “yes”.

Image 1-18-15 at 8.18 PM

now

systemctl restart smbd
systemctl restart nmbd

And here’s what it looks like from my Mac Computer. Works like a champ.


Screen Shot 2014-02-17 at 7.26.56 AM

Samba is complicated and my example is so simplistic as to be ridiculous The Code Monkeys are probably laughing at this but it works.

And it seemed to be a one way street. I could see my Arch Shares on the network but Arch couldn’t see a damn thing.

Not to worry.

pacman -S gvfs-smb

systemctl enable avahi-daemon

And there it is.

Image 1-18-15 at 8.18 PM

Power Management kept kicking in and killing my music so I did this: This stops the screen from blanking and shutting me down.

xset -dpms; xset s off

Ok if you would like to make that persistent where your screen won’t blank then add that line to your /home/yourname/.xinitrc file. Make sure it is BEFORE the active EXEC line (in my case exec startlxde)

Image 1-18-15 at 8.18 PM (1)

Now at some point you have to call a good stopping point. This is a good one for me. Now for God’s sake, shut down and back up your SD card. I’m going to my Mac and inserting the SD card. I open a terminal and type:

diskutil list

It tells me my SD card is /dev/disk3

Now to back up. If you are using Linux you’re on your own and will have to look up the commands yourself or go to a Windows box and use WInDiskImg or something similar.

sudo dd if=/dev/rdisk3 of=/Users/hagensieker/Archive/Temp/cuboxarch.img bs=1m


That makes a bit for bit copy of your card. You will not be sorry. Now when you move on and screw up you can always get back to this point by doing this:

sudo dd if=/Users/hagensieker/Archive/Temp/cuboxarch.img of=/dev/rdisk3 bs=1m

Looks like this now.
desktop

Now if you don’t want this lovely desktop to pop up and you wish to control your Cubox remotely you’ll want to install OpenSSH

pacman -S openssh

This starts sshd

systemctl start sshd

This enables it at boot.

systemctl enable sshd.service

And here’w what it looks like from another computers terminal. (i.e. Mac Terminal, Windows Putty) Note that I am logged in as my user “john”.

Screen Shot 2014-02-25 at 4.43.32 AM