RPi:ArchLinux: Difference between revisions
(Added Tweaks section) |
mNo edit summary |
||
(6 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{DISPLAYTITLE:Raspberry Pi : Arch Linux | {{DISPLAYTITLE:Raspberry Pi: Arch Linux Installation}} | ||
{{UnderConstruction}} | |||
{{Back|Raspberry Pi}} {{SeeAlso|ArchLinux:Installation|Arch Linux Installation}} | |||
<div id="tocalign">__TOC__</div> | <div id="tocalign">__TOC__</div> | ||
Line 7: | Line 9: | ||
= Image SD Card = | = Image SD Card = | ||
For use in the creation of this tutorial I used the following environment: | For use in the creation of this tutorial I used the following environment: | ||
{{Note|1= | {{Note|icon=false|1={{Icon|computer}} Raspberry Pi Model B<br/>{{Icon|disc-blue}} ArchLinuxARM-2014-06-rpi.img}} | ||
{{Icon|computer}} Raspberry Pi Model B | |||
{{Icon|disc-blue}} ArchLinuxARM-2014-06-rpi.img}} | |||
Download and image your SD Card with the image located at <span class="plainlinks">[http://archlinuxarm.org/platforms/armv6/raspberry-pi Arch Linux ARM]</span>. | Download and image your SD Card with the image located at <span class="plainlinks">[http://archlinuxarm.org/platforms/armv6/raspberry-pi Arch Linux ARM]</span>. | ||
Line 16: | Line 16: | ||
If you are using a Linux machine you can simply search for the device node of the SD card you have inserted with the {{mono|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 {{mono|fdisk}} (e.g. {{mono|/dev/sdd}}). | If you are using a Linux machine you can simply search for the device node of the SD card you have inserted with the {{mono|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 {{mono|fdisk}} (e.g. {{mono|/dev/sdd}}). | ||
{{Console|1=# dd bs{{=}}1M if{{=}}/path/to/ArchLinuxARM-2014-06-rpi.img of{{=}}''<device node>''}} | {{Console|prompt=false|1=# dd bs{{=}}1M if{{=}}/path/to/ArchLinuxARM-2014-06-rpi.img of{{=}}''<device node>''}} | ||
'''Windows''' | '''Windows''' | ||
Line 28: | Line 28: | ||
First, run <span class="plainlinks">{{Mono|[https://www.archlinux.org/pacman/pacman.8.html pacman(8)]}}</span> to update the system. After this it is safe to reboot to enact the changes. | First, run <span class="plainlinks">{{Mono|[https://www.archlinux.org/pacman/pacman.8.html pacman(8)]}}</span> to update the system. After this it is safe to reboot to enact the changes. | ||
{{Console|1=[root@alarmpi ~]$ pacman -Syu<br/><br/>''...''<br/><br/>[root@alarmpi ~]$ systemctl reboot}} | {{Console|prompt=false|1=[root@alarmpi ~]$ pacman -Syu<br/><br/>''...''<br/><br/>[root@alarmpi ~]$ systemctl reboot}} | ||
With the system is up to date, edit the {{Mono|/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. | With the system is up to date, edit the {{Mono|/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. | ||
{{Console|1=[root@alarmpi ~]$ vi /etc/pacman.d/mirrorlist<br/><span style="color:#555"> | {{Console|prompt=false|1=[root@alarmpi ~]$ vi /etc/pacman.d/mirrorlist<br/><span style="color:#555">———</span><br/># Server = <nowiki>http://mirror.archlinuxarm.org/$arch/$repo</nowiki><br/><br/>''...''<br/><br/>Server = <nowiki>http://wa.us.mirror.archlinuxarm.org/$arch/$repo</nowiki><br/><span style="color:#555">———</span>}} | ||
You can also take this time to enable the {{Mono|Color}} option in the {{Mono|/etc/pacman.conf}} if you like. | You can also take this time to enable the {{Mono|Color}} option in the {{Mono|/etc/pacman.conf}} if you like. | ||
{{Console|1=[root@alarmpi ~]$ vi /etc/pacman.conf<br/><span style="color:#555"> | {{Console|prompt=false|1=[root@alarmpi ~]$ vi /etc/pacman.conf<br/><span style="color:#555">———</span><br/># Misc options<br/>#UseSyslog<br/>Color<br/>#TotalDownload<br/>CheckSpace<br/>#VerbostPkgLists<br/><span style="color:#555">———</span>}} | ||
Next, install <span class="plainlinks">{{Mono|[https://aur.archlinux.org/packages/packer/ packer]}}</span> and update the RPi firmware/kernel to the latest version. In addition to this we will be installing <span class="plainlinks">{{Mono|[https://github.com/bavison/arm-mem arm-mem]}}</span> which are ARM-accelerated versions of selected functions from string.h. Then again reboot the machine to enact the changes. | Next, install <span class="plainlinks">{{Mono|[https://aur.archlinux.org/packages/packer/ packer]}}</span> and update the RPi firmware/kernel to the latest version. In addition to this we will be installing <span class="plainlinks">{{Mono|[https://github.com/bavison/arm-mem arm-mem]}}</span> which are ARM-accelerated versions of selected functions from string.h. Then again reboot the machine to enact the changes. | ||
{{Console|1=[root@alarmpi ~]$ pacman -S packer arm-mem-git linux-raspberrypi-latest linux-raspberrypi-latest-headers vim<br/><br/>''...''<br/><br/>[root@alarmpi ~]$ systemctl reboot}} | {{Console|prompt=false|1=[root@alarmpi ~]$ pacman -S packer arm-mem-git linux-raspberrypi-latest linux-raspberrypi-latest-headers vim<br/><br/>''...''<br/><br/>[root@alarmpi ~]$ systemctl reboot}} | ||
== Configuration == | == Configuration == | ||
With the system updated to the latest kernel it is | With the system updated to the latest kernel it is now time to configure the system for our needs. We can first start with the network. | ||
=== Network === | === Network === | ||
Line 52: | Line 52: | ||
For a wired network card first copy a template and then edit the template to modify your IP address and your chosen DNS server. | For a wired network card first copy a template and then edit the template to modify your IP address and your chosen DNS server. | ||
{{Console|1=[root@alarmpi ~]$ cd /etc/netctl<br/>[root@alarmpi ~]$ cp examples/ethernet-static eth0<br/>[root@alarmpi ~]$ vim eth0<br/><span style="color:#555"> | {{Console|prompt=false|1=[root@alarmpi ~]$ cd /etc/netctl<br/>[root@alarmpi ~]$ cp examples/ethernet-static eth0<br/>[root@alarmpi ~]$ vim eth0<br/><span style="color:#555">———</span><br/>IP{{=}}static<br/>Address{{=}}('192.168.1.30/24')<br/>Gateway{{=}}'192.168.1.1'<br/>DNS{{=}}('4.2.2.1' '4.2.2.2')<br/>ExecUpPost{{=}}'/usr/bin/ntpd -gq || true'<br/><span style="color:#555">———</span>}} | ||
'''Wireless''' | '''Wireless''' | ||
Line 58: | Line 58: | ||
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. | 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. | ||
{{Console|1=[root@alarmpi ~]$ cd /etc/netctl<br/>[root@alarmpi ~]$ cp examples/wireless-wpa eth0<br/>[root@alarmpi ~]$ vim eth0<br/><span style="color:#555"> | {{Console|prompt=false|1=[root@alarmpi ~]$ cd /etc/netctl<br/>[root@alarmpi ~]$ cp examples/wireless-wpa eth0<br/>[root@alarmpi ~]$ vim eth0<br/><span style="color:#555">———</span><br/>IP{{=}}static<br/>Address{{=}}('192.168.1.30/24')<br/>Gateway{{=}}'192.168.1.1'<br/>DNS{{=}}('4.2.2.1' '4.2.2.2')<br/>ESSID='MyWirelessNetworkSSID'<br/>Key='MyWirelessPassword'<br/>#Hidden=yes<br/>ExecUpPost{{=}}'/usr/bin/ntpd -gq || true'<br/><span style="color:#555">———</span><br/>[root@alarmpi ~]$ chmod 640 eth0}} | ||
Feel free to change either of these to {{mono|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 {{mono|netctl}}. | Feel free to change either of these to {{mono|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 {{mono|netctl}}. | ||
{{Console|1=[root@alarmpi ~]$ netctl enable eth0}} | {{Console|prompt=false|1=[root@alarmpi ~]$ netctl enable eth0}} | ||
=== Hostname === | === Hostname === | ||
Set the hostname for use with networks, I will be using the hostname {{mono|hex.kyau.net}}. | Set the hostname for use with networks, I will be using the hostname {{mono|hex.kyau.net}}. | ||
{{Console|1=[root@alarmpi ~]$ hostnamectl set-hostname hex.kyau.net}} | {{Console|prompt=false|1=[root@alarmpi ~]$ hostnamectl set-hostname hex.kyau.net}} | ||
=== Timezone === | === Timezone === | ||
Set the timezone, for me this is {{mono|US/Pacific}} as I am located on the west coast of the United States. Then enable {{mono|ntpd}} for internet time syncing capabilities. | Set the timezone, for me this is {{mono|US/Pacific}} as I am located on the west coast of the United States. Then enable {{mono|ntpd}} for internet time syncing capabilities. | ||
{{Console|1=[root@alarmpi ~]$ timedatectl set-timezone US/Pacific<br/>[root@alarmpi ~]$ systemctl enable ntpd}} | {{Console|prompt=false|1=[root@alarmpi ~]$ timedatectl set-timezone US/Pacific<br/>[root@alarmpi ~]$ systemctl enable ntpd}} | ||
=== Locale === | === Locale === | ||
Setup the appropriate locale. First edit {{mono|/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. | Setup the appropriate locale. First edit {{mono|/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. | ||
{{Console|1=[root@alarmpi ~]$ vim /etc/locale.gen<br/><span style="color:#555"> | {{Console|prompt=false|1=[root@alarmpi ~]$ vim /etc/locale.gen<br/><span style="color:#555">———</span><br/>en_US ISO-8859-1<br/>en_US.UTF-8<br/><span style="color:#555">———</span><br/>[root@alarmpi ~]$ locale-gen<br/>Generating locales...<br/> en_US.UTF-8<br/> en_US.ISO-8859-1<br/>Generation complete.<br/>[root@alarmpi ~]$ localectl set-keymap us<br/>[root@alarmpi ~]$ localectl set-locale LANG{{=}}"en_US.UTF-8"}} | ||
== User Management == | == User Management == | ||
With the system configuration out of the way it is time to create a user account, install {{mono|sudo}}, give the user full access to {{mono|sudo}} and then relog into your new account. I will be using the username {{mono|kyau}} for the extent of this tutorial. Finally we can change the default root password. | With the system configuration out of the way it is time to create a user account, install {{mono|sudo}}, give the user full access to {{mono|sudo}} and then relog into your new account. I will be using the username {{mono|kyau}} for the extent of this tutorial. Finally we can change the default root password. | ||
{{Console|1=[root@alarmpi ~]$ useradd -m -g users -s /bin/bash kyau<br/>[root@alarmpi ~]$ passwd kyau<br/>Enter new UNIX password:<br/>Retype new UNIX password:<br/>passwd: password updated successfully<br/>[root@alarmpi ~]$ pacman -S sudo<br/><br/>''...''<br/><br/>[root@alarmpi ~]$ visudo<br/><span style="color:#555"> | {{Console|prompt=false|1=[root@alarmpi ~]$ useradd -m -g users -s /bin/bash kyau<br/>[root@alarmpi ~]$ passwd kyau<br/>Enter new UNIX password:<br/>Retype new UNIX password:<br/>passwd: password updated successfully<br/>[root@alarmpi ~]$ pacman -S sudo<br/><br/>''...''<br/><br/>[root@alarmpi ~]$ visudo<br/><span style="color:#555">———</span><br/>root ALL=(ALL) ALL<br/>kyau ALL=(ALL) ALL<br/><span style="color:#555">———</span><br/>[root@alarmpi ~]$ passwd<br/>Enter new UNIX password:<br/>Retype new UNIX password:<br/>passwd: password updated successfully<br/>[root@alarmpi ~]$ systemctl reboot}} | ||
= Partition Management = | = Partition Management = | ||
Line 90: | Line 90: | ||
Moving the Arch install to a USB drive will increase overall speed of the RPi and give you the option of overclocking as you will no longer be limited by SD card corruption. Start by plugging in your USB drive to the RPi and pulling up a list of all drives on the machine again with the {{mono|fdisk}} command. | Moving the Arch install to a USB drive will increase overall speed of the RPi and give you the option of overclocking as you will no longer be limited by SD card corruption. Start by plugging in your USB drive to the RPi and pulling up a list of all drives on the machine again with the {{mono|fdisk}} command. | ||
{{Console|1=[kyau@hex ~]$ sudo fdisk -l<br/>''...''<br/>Device Boot Start End Blocks Id System<br/>/dev/sda1 32 31266815 15633392 c W95 FAT32 (LBA)}} | {{Console|prompt=false|1=[kyau@hex ~]$ sudo fdisk -l<br/>''...''<br/>Device Boot Start End Blocks Id System<br/>/dev/sda1 32 31266815 15633392 c W95 FAT32 (LBA)}} | ||
Notice the USB drive in the list, execute {{mono|fdisk}} on the USB drive. Create two partitions: a 1GB swap partition and then fill the rest of the disk with the root partition. | Notice the USB drive in the list, execute {{mono|fdisk}} on the USB drive. Create two partitions: a 1GB swap partition and then fill the rest of the disk with the root partition. | ||
{{Console|1=[kyau@hex ~]$ sudo fdisk /dev/sda<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/>Command (m for help): o<br/>Created a new DOS disklabel with disk identifier 0x51248fbd.<br/><br/>Command (m for help): n<br/><br/>Partition type:<br/> p primary (0 primary, 0 extended, 4 free)<br/> e extended<br/>Select (default p): p<br/>Partition number (1-4, default 1):<br/>First sector (2048-31266815, default 2048):<br/>Last sector, +sectors or +size{K,M,G,T,P} (2048-31266815, default 31266815): +1G<br/><br/>Created a new partition 1 of type 'Linux' and of size 1 GiB.<br/><br/>Command (m for help): t<br/>Selected partition 1<br/>Hex code (type L to list all codes): 82<br/>Changed type of partition 'Linux' to 'Linux swap / Solaris'.<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):<br/><br/>Using default response p.<br/>Partition number (2-4, default 2):<br/>First sector (2099200-31266815, default 2099200):<br/>Last sector, +sectors or +size{K,M,G,T,P} (2099200-31266815, default 31266815):<br/><br/>Created a new partition 2 of type 'Linux' and of size 13.9 GiB.<br/><br/>Command (m for help): w<br/>The partition table has been altered.<br/>Calling ioctl() to re-read partition table.<br/>Syncing disks.}} | {{Console|prompt=false|1=[kyau@hex ~]$ sudo fdisk /dev/sda<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/>Command (m for help): o<br/>Created a new DOS disklabel with disk identifier 0x51248fbd.<br/><br/>Command (m for help): n<br/><br/>Partition type:<br/> p primary (0 primary, 0 extended, 4 free)<br/> e extended<br/>Select (default p): p<br/>Partition number (1-4, default 1):<br/>First sector (2048-31266815, default 2048):<br/>Last sector, +sectors or +size{K,M,G,T,P} (2048-31266815, default 31266815): +1G<br/><br/>Created a new partition 1 of type 'Linux' and of size 1 GiB.<br/><br/>Command (m for help): t<br/>Selected partition 1<br/>Hex code (type L to list all codes): 82<br/>Changed type of partition 'Linux' to 'Linux swap / Solaris'.<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):<br/><br/>Using default response p.<br/>Partition number (2-4, default 2):<br/>First sector (2099200-31266815, default 2099200):<br/>Last sector, +sectors or +size{K,M,G,T,P} (2099200-31266815, default 31266815):<br/><br/>Created a new partition 2 of type 'Linux' and of size 13.9 GiB.<br/><br/>Command (m for help): w<br/>The partition table has been altered.<br/>Calling ioctl() to re-read partition table.<br/>Syncing disks.}} | ||
Next you need to format and mount the partitions you just created. | Next you need to format and mount the partitions you just created. | ||
{{Console|1=[kyau@hex ~]$ sudo mkfs.ext4 /dev/sda2<br/>mke2fs 1.42.10 (18-May-2014)<br/>Creating filesystem with 3645952 4k blocks and 912128 inodes<br/>Filesystem UUID: 3292220f-c043-4ec2-af21-4eb23fea345a<br/>Superblock backups stored on blocks:<br/> 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208<br/><br/>Allocating group tables: done<br/>Writing inode tables: done<br/>Creating journal (32768 blocks): done<br/>Writing superblocks and filesystem accounting information: done<br/><br/>[kyau@hex ~]$ sudo mkswap /dev/sda1<br/>Setting up swapspace version 1, size {{=}} 1048572 KiB<br/>no label, UUID=8e1a765b-f4df-4f2d-a799-e0a4d8fc6544}} | {{Console|prompt=false|1=[kyau@hex ~]$ sudo mkfs.ext4 /dev/sda2<br/>mke2fs 1.42.10 (18-May-2014)<br/>Creating filesystem with 3645952 4k blocks and 912128 inodes<br/>Filesystem UUID: 3292220f-c043-4ec2-af21-4eb23fea345a<br/>Superblock backups stored on blocks:<br/> 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208<br/><br/>Allocating group tables: done<br/>Writing inode tables: done<br/>Creating journal (32768 blocks): done<br/>Writing superblocks and filesystem accounting information: done<br/><br/>[kyau@hex ~]$ sudo mkswap /dev/sda1<br/>Setting up swapspace version 1, size {{=}} 1048572 KiB<br/>no label, UUID=8e1a765b-f4df-4f2d-a799-e0a4d8fc6544}} | ||
With that finished it is time to clone the current live system. First reboot into rescue mode, then mount the root partitions to temporary directories and then copy over the system. | With that finished it is time to clone the current live system. First reboot into rescue mode, then mount the root partitions to temporary directories and then copy over the system. | ||
{{Console|1=[kyau@hex ~]$ sudo systemctl rescue<br/>''...''<br/>[root@hex ~]$ mkdir /mnt/{blk,sda}<br/>[root@hex ~]$ mount /dev/sda2 /mnt/sda<br/>[root@hex ~]$ mount /dev/mmcblk0p5 /mnt/blk<br/>[root@hex ~]$ cd /mnt/blk<br/>[root@hex ~]$ cp -a * /mnt/sda<br/>systemctl reboot}} | {{Console|prompt=false|1=[kyau@hex ~]$ sudo systemctl rescue<br/>''...''<br/>[root@hex ~]$ mkdir /mnt/{blk,sda}<br/>[root@hex ~]$ mount /dev/sda2 /mnt/sda<br/>[root@hex ~]$ mount /dev/mmcblk0p5 /mnt/blk<br/>[root@hex ~]$ cd /mnt/blk<br/>[root@hex ~]$ cp -a * /mnt/sda<br/>systemctl reboot}} | ||
Once the machine has rebooted it is time to switch over to mounting root off of the USB drive instead of the SD card. | Once the machine has rebooted it is time to switch over to mounting root off of the USB drive instead of the SD card. | ||
{{Console|1=[kyau@hex ~]$ sudo vim /boot/cmdline.txt<br/><span style="color:#555"> | {{Console|prompt=false|1=[kyau@hex ~]$ sudo vim /boot/cmdline.txt<br/><span style="color:#555">———</span><br/>ipv6.disable=1 avoid_safe_mode=1 selinux=0 plymouth.enable=0 smsc95xx.turbo_mode=N dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/sda2 rootfstype=ext4 elevator=noop rootwait<br/><span style="color:#555">———</span><br/>[kyau@hex ~]$ sudo mount /dev/sda2 /mnt<br/>[kyau@hex ~]$ sudo vim /mnt/etc/fstab<br/><span style="color:#555">———</span><br/>#<br/># /etc/fstab: static file system information<br/>#<br/># <file system> <dir> <type> <options> <dump> <pass><br/>/dev/sda2 / ext4 defaults,noatime 0 0<br/>/dev/mmcblk0p1 /boot vfat defaults 0 0<br/>/dev/sda1 none swap defaults 0 0<br/>tmpfs /tmp tmpfs nodev,nosuid,size{{=}}2G 0 0<br/><span style="color:#555">———</span>}} | ||
With all this finished reboot to enact the changes. | With all this finished reboot to enact the changes. | ||
{{Console|1=[kyau@hex ~]$ sudo systemctl reboot}} | {{Console|prompt=false|1=[kyau@hex ~]$ sudo systemctl reboot}} | ||
== SD Card == | == SD Card == | ||
Line 116: | Line 116: | ||
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). | 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}} | {{Console|prompt=false|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. | 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).}} | {{Console|prompt=false|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. | With the partition table updated, reboot the computer to enact the changes. | ||
{{Console|1=[kyau@hex ~]$ sudo systemctl reboot}} | {{Console|prompt=false|1=[kyau@hex ~]$ sudo systemctl reboot}} | ||
Once the machine reboots log back into the machine and resize the filesystem with the {{mono|resize2fs}} command. | Once the machine reboots log back into the machine and resize the filesystem with the {{mono|resize2fs}} command. | ||
{{Console|1=[kyau@hex ~]$ sudo resize2fs /dev/mmcblk0p5<br/>[sudo] password for kyau:<br/><br/>resize2fs 1.42.10 (18-May-2014)<br/>Filesystem at /dev/mmcblk0p5 is mounted on /; on-line resizing required<br/>old_desc_blocks {{=}} 1, new_desc_blocks {{=}} 1<br/>The filesystem on /dev/mmcblk0p5 is now 3814272 blocks long.}} | {{Console|prompt=false|1=[kyau@hex ~]$ sudo resize2fs /dev/mmcblk0p5<br/>[sudo] password for kyau:<br/><br/>resize2fs 1.42.10 (18-May-2014)<br/>Filesystem at /dev/mmcblk0p5 is mounted on /; on-line resizing required<br/>old_desc_blocks {{=}} 1, new_desc_blocks {{=}} 1<br/>The filesystem on /dev/mmcblk0p5 is now 3814272 blocks long.}} | ||
= Tweaks = | = Tweaks = | ||
Line 136: | Line 136: | ||
To enable automatic login to the console after boot you will need to add a service to {{mono|systemd}}. First create the required directories and then the required service unit file. | To enable automatic login to the console after boot you will need to add a service to {{mono|systemd}}. First create the required directories and then the required service unit file. | ||
{{Console|1=[kyau@hex ~]$ sudo mkdir -p /etc/systemd/system/getty@tty1.service.d/<br/>[kyau@hex ~]$ sudo vim /etc/systemd/system/getty@tty1.service.d/autologin.conf<br/><span style="color:#555"> | {{Console|prompt=false|1=[kyau@hex ~]$ sudo mkdir -p /etc/systemd/system/getty@tty1.service.d/<br/>[kyau@hex ~]$ sudo vim /etc/systemd/system/getty@tty1.service.d/autologin.conf<br/><span style="color:#555">———</span><br/>[Service]<br/>ExecStart{{=}}<br/>ExecStart{{=}}-/usr/bin/agetty --autologin kyau --noclear %I 38400 linux<br/>Type{{=}}idle<br/><span style="color:#555">———</span>}} | ||
[[Category:Raspberry Pi]] | [[Category:Raspberry Pi]] |
Latest revision as of 13:54, 19 August 2017
UNDER CONSTRUCTION: The document is currently being modified! |
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 now 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)
Moving the Arch install to a USB drive will increase overall speed of the RPi and give you the option of overclocking as you will no longer be limited by SD card corruption. Start by plugging in your USB drive to the RPi and pulling up a list of all drives on the machine again with the fdisk command.
[kyau@hex ~]$ sudo fdisk -l ... Device Boot Start End Blocks Id System /dev/sda1 32 31266815 15633392 c W95 FAT32 (LBA) |
Notice the USB drive in the list, execute fdisk on the USB drive. Create two partitions: a 1GB swap partition and then fill the rest of the disk with the root partition.
[kyau@hex ~]$ sudo fdisk /dev/sda 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): o Created a new DOS disklabel with disk identifier 0x51248fbd. Command (m for help): n Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): p Partition number (1-4, default 1): First sector (2048-31266815, default 2048): Last sector, +sectors or +size{K,M,G,T,P} (2048-31266815, default 31266815): +1G Created a new partition 1 of type 'Linux' and of size 1 GiB. Command (m for help): t Selected partition 1 Hex code (type L to list all codes): 82 Changed type of partition 'Linux' to 'Linux swap / Solaris'. Command (m for help): n Partition type: p primary (1 primary, 0 extended, 3 free) e extended Select (default p): Using default response p. Partition number (2-4, default 2): First sector (2099200-31266815, default 2099200): Last sector, +sectors or +size{K,M,G,T,P} (2099200-31266815, default 31266815): Created a new partition 2 of type 'Linux' and of size 13.9 GiB. Command (m for help): w The partition table has been altered. Calling ioctl() to re-read partition table. Syncing disks. |
Next you need to format and mount the partitions you just created.
[kyau@hex ~]$ sudo mkfs.ext4 /dev/sda2 mke2fs 1.42.10 (18-May-2014) Creating filesystem with 3645952 4k blocks and 912128 inodes Filesystem UUID: 3292220f-c043-4ec2-af21-4eb23fea345a Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208 Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done [kyau@hex ~]$ sudo mkswap /dev/sda1 Setting up swapspace version 1, size = 1048572 KiB no label, UUID=8e1a765b-f4df-4f2d-a799-e0a4d8fc6544 |
With that finished it is time to clone the current live system. First reboot into rescue mode, then mount the root partitions to temporary directories and then copy over the system.
[kyau@hex ~]$ sudo systemctl rescue ... [root@hex ~]$ mkdir /mnt/{blk,sda} [root@hex ~]$ mount /dev/sda2 /mnt/sda [root@hex ~]$ mount /dev/mmcblk0p5 /mnt/blk [root@hex ~]$ cd /mnt/blk [root@hex ~]$ cp -a * /mnt/sda systemctl reboot |
Once the machine has rebooted it is time to switch over to mounting root off of the USB drive instead of the SD card.
[kyau@hex ~]$ sudo vim /boot/cmdline.txt ——— ipv6.disable=1 avoid_safe_mode=1 selinux=0 plymouth.enable=0 smsc95xx.turbo_mode=N dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/sda2 rootfstype=ext4 elevator=noop rootwait ——— [kyau@hex ~]$ sudo mount /dev/sda2 /mnt [kyau@hex ~]$ sudo vim /mnt/etc/fstab ——— # # /etc/fstab: static file system information # # <file system> <dir> <type> <options> <dump> <pass> /dev/sda2 / ext4 defaults,noatime 0 0 /dev/mmcblk0p1 /boot vfat defaults 0 0 /dev/sda1 none swap defaults 0 0 tmpfs /tmp tmpfs nodev,nosuid,size=2G 0 0 ——— |
With all this finished reboot to enact the changes.
[kyau@hex ~]$ sudo systemctl reboot |
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 resize2fs command.
[kyau@hex ~]$ sudo resize2fs /dev/mmcblk0p5 [sudo] password for kyau: resize2fs 1.42.10 (18-May-2014) Filesystem at /dev/mmcblk0p5 is mounted on /; on-line resizing required old_desc_blocks = 1, new_desc_blocks = 1 The filesystem on /dev/mmcblk0p5 is now 3814272 blocks long. |
Tweaks
None of the following is required and should all be considered optional, as such it is included merely for reference.
Auto Login
To enable automatic login to the console after boot you will need to add a service to systemd. First create the required directories and then the required service unit file.
[kyau@hex ~]$ sudo mkdir -p /etc/systemd/system/getty@tty1.service.d/ [kyau@hex ~]$ sudo vim /etc/systemd/system/getty@tty1.service.d/autologin.conf ——— [Service] ExecStart= ExecStart=-/usr/bin/agetty --autologin kyau --noclear %I 38400 linux Type=idle ——— |