Weekend with ArchLinuxARM

Jason Charney
8 min readApr 29, 2019

--

This story will be in parts, mostly because parts of this story are not finished.

Update (6/22/19): Turns out I don’t have any 3B+s, they are 3B Rev 1.2s. This story has been updated to reflect that.

On Wednesday, my beloved Sombra (the nickname I gave my most recent Raspberry Pi 3B) had an untimely death when the micro SD card would not longer let Raspbian run.

I had a good run with Sombra. Hopefully, I will figure out how to clone the SD card image and move all the stuff that still works to a better more functioning microSD card. (It’s a good time to invest in MicroSD cards. The most recent one I picked up last month was 128GB which the prices have been slashed that I got it for $20 at Micro Center. Later this week, I might get two 64GB cards for about the same price, but big 128GB would be great to back up all the M.A.M.E. games I stored for my RetroPie.)

Fortunately, I have another Raspberry Pi that I’ve had around the house, Topaz, which not only let me check to see if Sombra’s files were in tact, but to work on trying out ArchLinux ARM.

ArchLinux ARM works like ArchLinux but is designed to work on ARM processors. I really like working with the ARM devices, despite their early limitations. It is expected that ARM may surpass Intel as the top chip maker in the 2020s as the Internet of Things (IoT) matures. Even Apple is planning on swapping Intel for ARM in the next few years. So the past few years of tinerking with Raspberry Pi have started to pay off as the next MacBook may be the Hacktop I made from a Motorola Atrix Lapdock and a Raspberry Pi.

Of course, I did experiment with other things like an Odroid sometime around 2015, as somebody bragged about how for about $50 (with about $25 of other accessories, and another $20 of parts I picked up from eBay and Amazon) I had made an even more powerful hacktop until the overvoltaging/undervoltaging had wore out that machine.

Was it as an easier experience as using a Raspberry Pi? No, probably because it was using Debian. Was is an endearing learning experience? Totally.

This brings me to likely trying that experiment again only this time with an Odroid XU4 considering, the whole point of my trying to get something like this to work is to get all those retro video games I missed out on in my youth to play on a computer no bigger than a deck of cards.

In fact, if you bought a laptop in the past few years, yo may have seen Solid State Drives (SSDs) in a form called M.2 which look no bigger than a stick of Laptop RAM. That’s how small things are now. This is allowing more room for other stuff even though most of it is getting smaller, making room for batteries and heat dissipation.

But all that is the future. This post is about the past few days.

Writing a New MicroSD Card

The thing about ArchLinux ARM is that in order to “burn it” to another microSD card, you need a system that already has Linux. In fact, count your blessing, Raspberry Pi users, you can do this your current device, provided you have a good USB microSD card reader, which I so happened to have one.

The burn process is not like Raspbian or Ubuntu where you can download a .iso file, use Etcher and and flash the microSD card. It’s more complicated than that. In order for you to get ArchLinux ARM set up, you need to have another Linux system set up, and there will be some dangerous commands that will be used, especially if you have to reflash. (Which you WILL reflash. So you better learn how to make a backup. Aren’t you glad microSD cards are so cheap right now?)

I’ve wrote down EVERY command that I could. This article, and the ones that follow, will be a document listing those instructions, at least the ones that work. So if it ends at a cliffhanger, its because it was at that point things fell apart. (Should I use netctl or wpa_supplicant for WiFi? That’s honestly where things went to hell in a handbasket. (Update: Turns out netctl but with wifi-menu -o. I’ll get into the details in the next article.)

So, let’s knock out the easy parts…or hard parts depending on your point of view. These instruction apply the the Raspberry Pi 3B Rev 1.2 using the Raspberry Pi 2/3 files, because the Raspberry Pi 3 image actually abandoned. (Update: It just didn’t work with the 3Bs I had.) (I don’t know why I keep saying “image” when there are no images, just a big .tar.gz file with all the files on it. So if I say “image” I mean “files”.) If you use the image explicitly for RPi3, you won’t be able to use the official 7" touch screen accessory for a display. It took me at least two other attempt to figure that out. (Update: I tried do the Pi 2 image on my hacktop. I’ll post pictures about that later if I haven’t done it somewhere else already.)

It is also recommended to use a microSD card no larger than 32GB, since we need to set up a FAT32 partition as the boot sector. I’m pretty sure you can’t do that with 64GB or larger, unless somebody knows how to set this up for an EXFAT filesystem. You might want to talk to the ArchLinux ARM guys about what to do for larger disk sizes. (I would. Just don’t badger them about it.)

UPDATE: If you have a large SD Card (32GB+, you should definely install the exfat-utils package. This link should help with that as well as mounting if you need to do that by hand.)

If You Have To Reflash…be very careful!

A new card is preferred, but if you want, or if you messed up, knowing how to reformat is helpful, but is it VERY DANGEROUS! I mean, there is the dd command here. The UNIX and Linux community has a nickname for the dd command: “disk destroyer” because if you use it incorrectly, you could wipe out the wrong files.

  1. Find your microSD card on fdisk. You’ll want to run sudo fdisk -l first to find out where the microSD card is. Typically, it should be something like /dev/sda, but we’ll say /dev/sdX where X is a letter. At the bottom of all the disk partitions that fdisk shows should be your /dev/sdX. In some cases, you may have two /dev/sdX's because you tried using the card before for a Linux disk. They might be /dev/sdX1 and /dev/sdX2. A small one that is used as the boot partition and a large one used as the root partition. But I’m getting ahead of myself. You’ll want to know this later when we talk about installation.
  2. Format the microSD card. Once you’ve identified your microSD card in the fdisk table, you’ll want to use dd to blank it. BE VERY CAREFUL HERE! YOU ONLY GET ONE SHOT! There is no “undo” if you mess this up.
sudo dd if=/dev/zero of=/dev/sdX bs=1M status=progress

Once those steps are done, and the dd process has completed successfully, we can go on to the next step.

A couple of helpful hints:

  • Setting the block size to 4 megabytes (bs=4M) can make this step go faster.
  • There is another way to display the progress of the format, but the above way is recommended. This older way was to use a program called Pipe Viewer (pv). If by chance you are using a Linux distribution where dd doesn’t have status=progress, you can try doing this command instead.
sudo dd if=/dev/zero bs=4M | pv | sudo dd of=/dev/sdX bs=4M

Installation

As with any new Linux distro one of the scary parts of the process is how to partition. Fortunately, the ArchLinux ARM folks gave some very clear instructions on how to partition on the installation page (the second tab), worth restating here. Unlike that previous section where you had to do dd to blank a microSD card, until you reach Step 7, you can always use ^C (CTRL+C) to stop the fdisk table partitioning process and redo it if you mess up, but after that step, any mistakes will likely require a dd to start over again.

  1. Open fdisk. Use sudo fdisk /dev/sdX (where X is the same letter as before) to begin the partitioning process.
  2. Type o (followed by Enter) to clear out any partitions on /dev/sdX. (Assume that after each command I mention, you have to type Enter.)
  3. Type p to list partitions. There should be no partitions.
  4. Set the boot partition size. Type n, then p for primary, then 1 (one) to set up the first partition. Press Enter to accept the default first sector (2048) , then type +100M to allocate 100 megabytes as the last sector. We have allocated the space for our boot partition.
  5. Set the boot partition type. Type t, then c. This will set it to a W95 FAT32 (LBA) type. With than, /dev/sdX1 should be almost ready. We still have a couple of other things to do it it, but we’ll need to do that after we set up our root partition.
  6. Set the root partition size. Type n, then p, then 2 to set up the second partition. Press Enter twice to accept the default first and last sectors. The first sector should be where that 100 megabyte limit left off, while the last sector will be the remainder of the microSD card. This is the partition where the rest of our files will likely be stored. (I’m pretty sure full ArchLinux has a more elaborate partitioning set up to separate system files from user files, but the two-partition setup works fine for something like this.) We don’t need to set the partition type here. Eventually the filesystem type will be set as ext4 in a later step.
  7. Confirm the new partition table. After this step, there is no going back. So if you want to ^C and back out, this is the step to do it. Otherwise, confirm the new partition table by typing w.
  8. Create and Mount the boot partition. The boot partition, /dev/sdX1, will be a FAT32 file system mounted to /media/sdcard/boot. (We need to be literal about the paths here since the system you are working on is a Linux system that has its own /boot and /root directories, which we do not want to touch.)
    sudo mkfs.vfat /dev/sdX1
    sudo mkdir -p /media/sdcard/boot
    sudo mount /dev/sdX1 /media/sdcard/boot
  9. Create and Mount the root partition. The root partition, /dev/sdX2, will be a ext4 file system mounted to /media/sdcard/root. The mkfs command here may take a little longer because there is more space that needs to be formatted.
    sudo mkfs.ext4 /dev/sdX2
    sudo mkdir -p /media/sdcard/root
    sudo mount /dev/sdX2 /media/sdcard/root
  10. Download ArchLinuxARM for Raspberry Pi 2. Even if you have a Raspberry Pi 3, you should download the Raspberry Pi 2 file tarball. (Note: I’m pretty sure you should use the RPi2 image for Raspberry Pi Zero, but I haven’t tried it. So, YMMV if you are doing that.) We’ll put this file in the ~/Downloads directory.
    cd ~/Downloads
    curl -SLO os.archlinuxarm.org/os/ArchLinuxARM-rpi-2-latest.tar.gz
  11. Extract all the files to the boot partition. Using tar, we will extract the file to the boot partition. This will be followed by a sync command.
    sudo tar -xzf ArchLinuxARM-rpi-2-latest.tar.gz -C /media/sdcard/root
    sudo sync
  12. Move the boot directory to the boot partition. This should be in the first partition. Everything else goes in the second partition.
    sudo mv /media/sdcard/root/boot/* /media/sdcard/boot
  13. Unmount the /dev/sdX partitions. We’re almost done with this section. We first need to unmount the boot and root partitions.
    sudo umount /media/sdcard/boot
    sudo umount /media/sdcard/root
  14. Clean up /media/sdcard. Let’s clean up this directory. If you want you can ignore this step until you can verify that everything is working like it should.
    sudo rmdir /media/sdcard/boot
    sudo rmdir /media/sdcard/root
  15. Fire it up! Put the ArchLinux ARM microSD card in the Raspberry Pi you want to use. Preferably a Pi 2B or Pi 3B. Power it up with the proper power supply! Using something strange could damage the system.

This brings us to the end of the first part. In the next part I will cover the set up process, all of which must be done as root.

The second part is posted here.

--

--