RPi:ArchLinux: Difference between revisions
No edit summary |
|||
Line 92: | Line 92: | ||
Given that we used a pre-made image to install Arch Linux onto our SD Card, it came with predefined partitions that are not sized to your entire SD Card. | Given that we used a pre-made image to install Arch Linux onto our SD Card, it came with predefined partitions that are not sized to your entire SD Card. | ||
Use the {{mono|fdisk}} command to display all of your devices and locate the device node of the | Use the {{mono|fdisk}} command to display all of your devices and locate the device node of the SD Card (it should look similar to below). | ||
{{Console|1=[kyau@hex ~]$ sudo fdisk -l<br/>[sudo] password for kyau:<br/><br/>Disk /dev/mmcblk0: 14.7 GiB, 15719727104 bytes, 30702592 sectors<br/>Units: sectors of 1 * 512 = 512 bytes<br/>Sector size (logical/physical): 512 bytes / 512 bytes<br/>I/O size (minimum/optimal): 512 bytes / 512 bytes<br/>Disklabel type: dos<br/>Disk identifier: 0x417ee54b<br/><br/>Device Boot Start End Blocks Id System<br/>/dev/mmcblk0p1 2048 186367 92160 c W95 FAT32 (LBA)<br/>/dev/mmcblk0p2 186368 3667967 1740800 5 Extended<br/>/dev/mmcblk0p5 188416 3667967 1739776 83 Linux}} | |||
Now that we have located the device node as {{mono|mmcblk0}} we can use {{mono|fdisk}} to resize the partition. First pull up a list of all of the partitions in the table, then remove and recreate the extended partition. | |||
{{Console|1=[kyau@hex ~]$ sudo fdisk /dev/mmbblk0<br/>[sudo] password for kyau:<br/><br/><span style="color:#00a800">Welcome to fdisk (util-linux 2.24.2).</span><br/>Changes will remain in memory only, until you decide to write them.<br/>Be careful before using the write command.<br/><br/><br/>Command (m for help): p<br/>Disk /dev/mmcblk0: 14.7 GiB, 15719727104 bytes, 30702592 sectors<br/>Units: sectors of 1 * 512 {{=}} 512 bytes<br/>Sector size (logical/physical): 512 bytes / 512 bytes<br/>I/O size (minimum/optimal): 512 bytes / 512 bytes<br/>Disklabel type: dos<br/>Disk identifier: 0x417ee54b<br/><br/>Device Boot Start End Blocks Id System<br/>/dev/mmcblk0p1 2048 186367 92160 c W95 FAT32 (LBA)<br/>/dev/mmcblk0p2 186368 3667967 1740800 5 Extended<br/>/dev/mmcblk0p5 188416 3667967 1739776 83 Linux<br/><br/>Command (m for help): d<br/>Partition number (1,2,5, default 5): 2<br/><br/>Partition 2 has been deleted.<br/><br/>Command (m for help): n<br/><br/>Partition type:<br/> p primary (1 primary, 0 extended, 3 free)<br/> e extended<br/>Select (default p): e<br/>Partition number (2-4, default 2):<br/>First sector (186368-30702591, default 186368):<br/>Last sector, +sectors or +size{K,M,G,T,P} (186368-30702591, default 30702591):<br/><br/>Created a new partition 2 of type 'Extended' and of size 14.6 GiB.<br/><br/>Command (m for help): n<br/><br/>Partition type:<br/> p primary (1 primary, 1 extended, 2 free)<br/> l logical (numbered from 5)<br/>Select (default p): l<br/><br/>Adding logical partition 5<br/>First sector (188416-30702591, default 188416):<br/>Last sector, +sectors or +size{K,M,G,T,P} (188416-30702591, default 30702591):<br/><br/>Created a new partition 5 of type 'Linux' and of size 14.6 GiB.<br/><br/>Command (m for help): w<br/>The partition table has been altered.<br/>Calling ioctl() to re-read partition table.<br/><span style="color:#a80000">Re-reading the partition table failed.: Device or resource busy</span><br/><br/>The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8).}} | |||
With the partition table updated, reboot the computer to enact the changes. | |||
{{Console|1=[kyau@hex ~]$ sudo systemctl reboot}} | |||
Once the machine reboots log back into the machine and resize the filesystem with the {{mono|resizefs}} command. | |||
{{Console|1=[kyau@hex ~]$ sudo resizefs /dev/mmcblk0p5}} | |||
[[Category:Raspberry Pi]] | [[Category:Raspberry Pi]] |
Revision as of 10:00, 24 June 2014
The following tutorial is a collection of notes on how to install the Arch Linux distribution on the Raspberry Pi hobbyist device. This tutorial is essentially a replica of my normal Arch Linux: System Installation guide with RPi (Raspberry Pi) specific notes included. As always we will follow the Arch Linux philosophy, meaning these tutorials are geared at being simple and efficient.
Image SD Card
For use in the creation of this tutorial I used the following environment:
Raspberry Pi Model B ArchLinuxARM-2014-06-rpi.img |
Download and image your SD Card with the image located at Arch Linux ARM.
Linux
If you are using a Linux machine you can simply search for the device node of the SD card you have inserted with the fdisk -l command. Then you can format your SD card with the image using the following command, filling in the path of the downloaded image and replacing the device node with the device node you found with fdisk (e.g. /dev/sdd).
# # dd bs=1M if=/path/to/ArchLinuxARM-2014-06-rpi.img of=<device node> |
Windows
Download and install Win32DiskImager. Then proceed to use it to format your SD card with the image you downloaded. Be sure to specify the correct device before hitting the Write button.
Initial Boot & Configuration
Go ahead and plug the SD Card back into the RPi and boot it up. You will eventually be greeted with the Arch Linux login prompt. Login to the system using the root account with the default password of root.
System Update
First, run pacman(8) to update the system. After this it is safe to reboot to enact the changes.
# [root@alarmpi ~]$ pacman -Syu ... [root@alarmpi ~]$ systemctl reboot |
With the system is up to date, edit the /etc/pacman.d/mirrorlist in order to select an Arch Linux ARM (ALARM) download mirror that is closest to your location. I have found that the default auto-selection based off geo-IP data doesn't work all that well. Uncomment the mirror that best suits your location.
# [root@alarmpi ~]$ vi /etc/pacman.d/mirrorlist ——— # Server = http://mirror.archlinuxarm.org/$arch/$repo ... Server = http://wa.us.mirror.archlinuxarm.org/$arch/$repo ——— |
You can also take this time to enable the Color option in the /etc/pacman.conf if you like.
# [root@alarmpi ~]$ vi /etc/pacman.conf ——— # Misc options #UseSyslog Color #TotalDownload CheckSpace #VerbostPkgLists ——— |
Next, install packer and update the RPi firmware/kernel to the latest version. In addition to this we will be installing arm-mem which are ARM-accelerated versions of selected functions from string.h. Then again reboot the machine to enact the changes.
# [root@alarmpi ~]$ pacman -S packer arm-mem-git linux-raspberrypi-latest linux-raspberrypi-latest-headers vim ... [root@alarmpi ~]$ systemctl reboot |
Configuration
With the system updated to the latest kernel it is not time to configure the system for our needs. We can first start with the network.
Network
After you have the RPi running the Linux kernel 3.x you will now have 8188eu wireless support built into the kernel. You can use an 8188eu USB NIC or the built-in wired NIC that comes with the RPi.
Wired
For a wired network card first copy a template and then edit the template to modify your IP address and your chosen DNS server.
# [root@alarmpi ~]$ cd /etc/netctl [root@alarmpi ~]$ cp examples/ethernet-static eth0 [root@alarmpi ~]$ vim eth0 ——— IP=static Address=('192.168.1.30/24') Gateway='192.168.1.1' DNS=('4.2.2.1' '4.2.2.2') ExecUpPost='/usr/bin/ntpd -gq || true' ——— |
Wireless
If you wish to use wireless instead it is pretty much the same process except we use a different template. The only difference is to make sure you secure the file if it contains your wireless password.
# [root@alarmpi ~]$ cd /etc/netctl [root@alarmpi ~]$ cp examples/wireless-wpa eth0 [root@alarmpi ~]$ vim eth0 ——— IP=static Address=('192.168.1.30/24') Gateway='192.168.1.1' DNS=('4.2.2.1' '4.2.2.2') ESSID='MyWirelessNetworkSSID' Key='MyWirelessPassword' #Hidden=yes ExecUpPost='/usr/bin/ntpd -gq || true' ——— [root@alarmpi ~]$ chmod 640 eth0 |
Feel free to change either of these to IP=dhcp in order to use DHCP instead of a static address. Also regardless of which you chose you will need to enable the profile with netctl.
# [root@alarmpi ~]$ netctl enable eth0 |
Hostname
Set the hostname for use with networks, I will be using the hostname hex.kyau.net.
# [root@alarmpi ~]$ hostnamectl set-hostname hex.kyau.net |
Timezone
Set the timezone, for me this is US/Pacific as I am located on the west coast of the United States. Then enable ntpd for internet time syncing capabilities.
# [root@alarmpi ~]$ timedatectl set-timezone US/Pacific [root@alarmpi ~]$ systemctl enable ntpd |
Locale
Setup the appropriate locale. First edit /etc/locale.gen and uncomment the lines that correspond to your language selection, generate the needed locales, set your keymap and finally set the language with the system.
# [root@alarmpi ~]$ vim /etc/locale.gen ——— en_US ISO-8859-1 en_US.UTF-8 ——— [root@alarmpi ~]$ locale-gen Generating locales... en_US.UTF-8 en_US.ISO-8859-1 Generation complete. [root@alarmpi ~]$ localectl set-keymap us [root@alarmpi ~]$ localectl set-locale LANG="en_US.UTF-8" |
User Management
With the system configuration out of the way it is time to create a user account, install sudo, give the user full access to sudo and then relog into your new account. I will be using the username kyau for the extent of this tutorial. Finally we can change the default root password.
# [root@alarmpi ~]$ useradd -m -g users -s /bin/bash kyau [root@alarmpi ~]$ passwd kyau Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully [root@alarmpi ~]$ pacman -S sudo ... [root@alarmpi ~]$ visudo ——— root ALL=(ALL) ALL kyau ALL=(ALL) ALL ——— [root@alarmpi ~]$ passwd Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully [root@alarmpi ~]$ systemctl reboot |
Partition Management
Next you will need to decide what you will be using as the main drive. This choice depends solely on whether or not you want to overclock your RPi or not. If you plan on experimenting with overclocking you will need an external USB hard drive or USB flash drive of adequate size.
USB Drive (Overclock)
SD Card
Given that we used a pre-made image to install Arch Linux onto our SD Card, it came with predefined partitions that are not sized to your entire SD Card.
Use the fdisk command to display all of your devices and locate the device node of the SD Card (it should look similar to below).
# [kyau@hex ~]$ sudo fdisk -l [sudo] password for kyau: Disk /dev/mmcblk0: 14.7 GiB, 15719727104 bytes, 30702592 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0x417ee54b Device Boot Start End Blocks Id System /dev/mmcblk0p1 2048 186367 92160 c W95 FAT32 (LBA) /dev/mmcblk0p2 186368 3667967 1740800 5 Extended /dev/mmcblk0p5 188416 3667967 1739776 83 Linux |
Now that we have located the device node as mmcblk0 we can use fdisk to resize the partition. First pull up a list of all of the partitions in the table, then remove and recreate the extended partition.
# [kyau@hex ~]$ sudo fdisk /dev/mmbblk0 [sudo] password for kyau: Welcome to fdisk (util-linux 2.24.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Command (m for help): p Disk /dev/mmcblk0: 14.7 GiB, 15719727104 bytes, 30702592 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0x417ee54b Device Boot Start End Blocks Id System /dev/mmcblk0p1 2048 186367 92160 c W95 FAT32 (LBA) /dev/mmcblk0p2 186368 3667967 1740800 5 Extended /dev/mmcblk0p5 188416 3667967 1739776 83 Linux Command (m for help): d Partition number (1,2,5, default 5): 2 Partition 2 has been deleted. Command (m for help): n Partition type: p primary (1 primary, 0 extended, 3 free) e extended Select (default p): e Partition number (2-4, default 2): First sector (186368-30702591, default 186368): Last sector, +sectors or +size{K,M,G,T,P} (186368-30702591, default 30702591): Created a new partition 2 of type 'Extended' and of size 14.6 GiB. Command (m for help): n Partition type: p primary (1 primary, 1 extended, 2 free) l logical (numbered from 5) Select (default p): l Adding logical partition 5 First sector (188416-30702591, default 188416): Last sector, +sectors or +size{K,M,G,T,P} (188416-30702591, default 30702591): Created a new partition 5 of type 'Linux' and of size 14.6 GiB. Command (m for help): w The partition table has been altered. Calling ioctl() to re-read partition table. Re-reading the partition table failed.: Device or resource busy The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8). |
With the partition table updated, reboot the computer to enact the changes.
# [kyau@hex ~]$ sudo systemctl reboot |
Once the machine reboots log back into the machine and resize the filesystem with the resizefs command.
# [kyau@hex ~]$ sudo resizefs /dev/mmcblk0p5 |