Skip to content

Instantly share code, notes, and snippets.

@richardjortega
Last active August 29, 2015 14:04
Show Gist options
  • Save richardjortega/b7c5435f2cd1f8f75298 to your computer and use it in GitHub Desktop.
Save richardjortega/b7c5435f2cd1f8f75298 to your computer and use it in GitHub Desktop.
CuBox i4-Pro - Debian Wheezy (Serial Only) with Ruby 2.1.2, Rails 4.1.2, Expanded FS,Networking

This tutorial assists users of the CuBox i4-Pro (using Freescale's iMX6 SoC) stand up a stable, serial-only version (no desktop/GUI) of Debian Wheezy with working Networking (Ethernet and WiFi) with Ruby/Rails. Information collected from various forum posts, blog posts, etc. Attribution added where I could remember. Using a Windows 8.1 machine, please provide comments for update regarding Mac/Linux tutorial translations (for the most part it shouldn't matter except for how you write ISOs to microSD cards).

Note: Relatively new at this level of Linux usage, if there are better ways to do something please mention in comments so I can update

Download Debian Wheezy ISO image

Note: The password for root is cubox-i on this linked Debian image

Write Debian Wheezy ISO image to microSD Card

  • On Windows you can use Win32 Disk Imager (confirmed), on Mac it looks like Disk Utility (unconfirmed) would work, and on Linux CloneZilla looks like a similar software (unconfirmed).
    • Select ISO image
    • Select mounted drive that has microSD card
    • Write to microSD card
    • Click ok for any prompts

Expanding the microSD card's partitions to full card size

Must logged in as root

Note: If you like to clone the microSD filesystem to an ISO image (using aforementioned tool) to have a baseline copy, this will increase your total image size.

Inspired from: BeagleBoard wiki

View parition volumes
$ ls -l /dev/mmcblk*
Show partition table and start fdisk program
$ fdisk /dev/mmcblk0
  • Enter p to print the partition table
Delete partition block 2
  • Enter d to delete partition, then enter 2 for partition 2 /dev/mmcblk0p2
  • Enter p again to show you have deleted /dev/mmcblk0p2
Create new partition block 2
  • Enter n for new partition
  • Enter p for a primary partition
  • Enter 2 for partition block 2
  • Press Enter for default First and Last sector values
  • Enter p to view newly added partition
Commit changes to partition table
  • Enter w to write changes to partition table
Reboot your system to take affect
$ reboot
Expand file system

Report file system disk space usage

$ df -H

Resize file system

$ resize2fs /dev/mmcblk0p2
# Note: This command can take a few minutes to complete, be patient and don't unplug anything now ;)

Review updated file system was succesfully expanded

$ df -H

Update and upgrade packages

$ apt-get update
$ apt-get upgrade

Add some common packages

All can be installed via apt-get install <package-name>. This install is specifically setup to use the armhf type of packages which will work with ARM architecture systems rather than x86/x64 systems.

  • openssl
  • less
  • curl
  • usbutils
  • sudo
  • git
  • build-essential

Setting Up Ethernet

Credit: fguitart post on CuBox Forums

An IP Address hasn't yet been configured for eth0

$ nano /etc/network/interfaces # Add corresponding config from below

# For DHCP config:
auto eth0
iface eth0 inet dhcp

# Static IP config:
auto eth0
iface eth0 inet static
address A.B.C.D
netmask A.B.C.D
gateway A.B.C.D
dns-nameservers A.B.C.D A.B.C.D

And restart the network card:

$ ifdown eth0
$ ifup eth0

Test connection with Google.com

$ ping www.google.com

Setup/configure NTP Server

Note: NTP is required to be setup in order for rvm or rbenv to properly configure Ruby. Otherwise you'll run into a similar issue RPi users had: rvm/rvm#2524

Install ntp package

$ apt-get install ntp
# Configuration file at /etc/ntp.conf

$ service ntp stop
$ service ntp start

Install Ruby 2.1.2 and Rails 4.1.0

Important Note: ntpd must be running and setup in order to pass configuration section of rbenv/rvm. Use service ntp status to verify its running.

Total install time can fluctuate but I clocked it around 20-30 minutes for installing, fetching configuring Ruby 2.1.2 (with requirements already installed) and Rails 4.1.0 (without rdocs) using RVM.

I realize thatrvm has flags to do all-in-one install RVM/Ruby/Rails, but I've had issues with Rails rDoc stopping so I've separated the commands below and it works.

I'm assuming you've had experience doing RVM install on a standard server, so same things apply. RVM doesn't use a system ruby so you'll need to setup RVM under the account you plan to use (likely something other than root).

Install RVM with requirements and Ruby 2.1.2 (or latest stable)

Note: Do not run this command with the --rails flag as this will get stuck in install rDoc for Rails. This issue has happened to numerous people, but likely an rdoc issue: rails/rails#11814

Add the --debug flag to see what's happening under the hood to ensure it hasn't stalled out. The backslash ensures it skips any curl alias you may have setup and runs the curl binary.

$ \curl -sSL https://get.rvm.io | bash -s stable --ruby --debug
$ source /home/<user>/.rvm/scripts/rvm
Install Rails 4.1.2 (or latest stable without rdocs)
$ gem install rails --no-ri --no-rdoc

If you prefer a rbenv install please see the docs here: https://www.digitalocean.com/community/tutorials/how-to-install-ruby-on-rails-with-rbenv-on-debian-7-wheezy

Add Python 2 package (required for some gem builds)
$ sudo apt-get install python
Add NodeJS as Javascript runtime for Rails

We'll add nodejs but you could use other's allowed by execjs.

Add execjs to Gemfile via: $ nano Gemfile

gem 'execjs'

Install nodejs by first adding wheezy-backports repo to your source.list. This not necessary in Jessie/Sid Debian once those are stable. Check out the backports documentation for more information.

$ sudo nano /etc/apt/sources.list

Add the following lines:

# Backports repository
deb http://ftp.debian.org/debian wheezy-backports main contrib non-free

Update apt-get:

$ sudo apt-get update

Install nodejs package via wheezy-backports repo:

$ sudo apt-get -t wheezy-backports install nodejs

Bundle all gems:

$ bundle install

Test Rails Installation

Inspired from: http://elinux.org/RPi_Ruby_on_Rails

Other tools for Wireless

  • wicd-curses
  • wireless-tools
  • wpasupplicant
@aerodame
Copy link

aerodame commented Jan 5, 2015

Nice capture of the CuBox install Richard. Now on to Docker!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment