Booting Raspberry Pi 2 with Arch Linux
I was cleaning my work bench last night and came to see two Raspberry pi boards lying in a cardboard box! One Raspberry Pi 2 and a Raspberry Pi 2 B+. Oh! It's been a while since I used them. I almost forgot about them! Okay then this is the right time to remove the dust from the board as well as from my memory.
Which flavor of GNU/Linux should I load to this board? No Raspbian! It's not fun anymore ,I have done it many times before. Okay lets load Arch Linux. I have never done it in the past. Let me learn something new and share it.
Let's start with a 16GB Sandisk Ultra MicroSDHC UHS-1 Card (Class 10), A card reader and a PC running GNU/Linux (Ubuntu in my case).
When you plug-in the micro SD card, GNU/Linux PC will detect and mount it. You can see this in /dev directory of Linux root file system. Like /dev/sdbX (X is a number representing the partition). To know where it is mounted- Open a terminal (Ctrl+Alt+T) and type lsblk (listing all the bulk devices). In my case it's in /dev/sdb. Probably in your's as well (sda is the primary filesystem of the PC).
Now I need to create two partitions inside. For that I am using fdisk utility.
fdisk /dev/sdb
Now we can enter the commands :
- Type o. This will clear out any partitions on the drive.
- Type p to list partitions. There should be no partitions left.
- Type n, then p for primary, 1 for the first partition on the drive, press ENTER to accept the default first sector, then type +100M for the last sector.
- Type t, then c to set the first partition to type W95 FAT32 (LBA). This partition has to be FAT32 because this is where all the /boot files will go and sit.
- Type n, then p for primary, 2 for the second partition on the drive, and then press ENTER twice to accept the default first and last sector.
- Write the partition table and exit by typing w.
Lets create the filesystems by typing the following commands.
sudo mkfs.vfat /dev/sdb1 sudo mkfs.ext4 /dev/sdb2
Now let's create two temporary partitions on /mnt directory. This will hold boot and root files.
sudo mkdir /mnt/boot sudo mkdir /mnt/root
Now let's mount the /mnt/boot to sdb1 partition and root to the sdb2
sudo mount /dev/sdb1 /mnt/boot sudo mount /dev/sdb2 /mnt/root
Download the latest version of archlinux for Raspberrypi and extract it to /mnt/root
wget http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-2-latest.tar.gz
sudo tar zxvf ArchLinuxARM-rpi-2-latest.tar.gz -C /mnt/root
Now move the boot files from the root files
sudo mv /mnt/root/boot/* /mnt/boot
sudo sync
Sync command will make sure that all the data in the memory will be pushed to the disk.
Our micro SD card is now ready to be inserted to Raspberry Pi. Connect Ethernet cable, Insert the micro SD to the slot and power up the Pi.
Since ssh is enabled by default we can ssh into our newly booted system. Give it few seconds to boot up and type
ssh alarm@xxx.xxx.xxx.xxx
alarm is the default username and password for this build. You can ssh into root also, Password is root.
Bingo! We are inside our new Arch Linux running on a Pi.
Ref:
1) https://archlinuxarm.org/platforms/armv7/broadcom/raspberry-pi-2
2) https://www.youtube.com/watch?v=28-oPIuz-G0
3) https://www.raspberrypi.org/documentation/configuration/boot_folder.md