[{"data":1,"prerenderedAt":25},["ShallowReactive",2],{"$f1j60tqkfebsp5":3,"$f1idno6r2la63y":23},[4,10,17],{"id":5,"meta":6,"type":9},"math-ia-notes",{"title":7,"embed":8},"Math IA Notes",true,"typst",{"id":11,"meta":12,"type":16},"archive\u002Farch-on-arm",{"title":13,"date":14,"description":15},"Arch on (generic) ARM","3\u002F9\u002F2023","How to install generic Arch Linux ARM.","markdown",{"id":18,"meta":19,"type":16},"archive\u002Fgentoo-on-arm",{"title":20,"date":21,"description":22},"Gentoo on ARM","3\u002F2\u002F2023","The various hurdles of installing gentoo on an ARM computer.",{"content":24},"---\ntitle: \"Arch on (generic) ARM\"\ndate: \"3\u002F9\u002F2023\"\ndescription: \"How to install generic Arch Linux ARM.\"\n---\n\n## Why?\n\nArch Linux is a good distro, but it doesn't **officially** support ARM. Thus, the unofficial [Arch Linux ARM](https:\u002F\u002Farchlinuxarm.org\u002F) project exists, aiming to support lots of ARM computers. There is a problem however, if you are trying to install it on a generic VM or a computer not explicitly mentioned by their guides then you need to use the generic guide, which is essentially boils down to: \"DIY\".\n\nSo, if you want to install Arch Linux ARM on a **generic** ARM computer (like QEMU or UTM on Apple M1), then read on.\n\n## Note\n\nThis might work or might not. It will only work on UEFI systems and I have only tested this on a VM, be cautious if you are doing it on real hardware. Also, if you are using something like the raspberry pi, you should use the [official documentation](https:\u002F\u002Farchlinuxarm.org\u002Fplatforms) instead. Check the list, and only proceed with this guide if your device is not there.\nThis guide doesn't cover dual-boots. Finally, you should have an ARM v8 (aka. `aarch64`, aka. `arm64`) processor, this guide does not cover older\u002F32 bit ARM CPU's.\n\n## Preparations\n\nYou will need to use another distro to actually do the installation. I used Fedora, but any distro should in theory work.\nFor the rest of this guide (unless explicitly stated), it is assumed you will be root.\nSo, switch over to root:\n\n```sh\nsudo -s\n```\n\n## Partitioning the disks\n\nThis part generally assumes you already know how to partition disks, and it doesn't matter how you do it. I'll use fdisk, but it really doesn't matter. First, list out your drives with:\n\n```sh\nfdisk -l\n```\n\nAnd find the one you want to install with.\nNext, enter that drive like so, replace `\u003Cxxx>` with your drive:\n\n```sh\nfdisk \u002Fdev\u002F\u003Cxxx>\n```\n\nNow that we're in the partitioner, delete all your partitions if you have any by typing `d` and then enter.\nRepeat this until you have no more partitions left.\n\nThen, let's create a new GPT disklabel by pressing `g` and then enter.\n\nNow, let's create our partitions.\nThis will be the UEFI partition, and it will contain our kernels and bootloaders.\n\nPress `n` and then enter twice, and then type in `+500M` to make a partition 500 megabytes in size.\n\nThen, press `t` and type in `1`. This makes our partition have the type of EFI System.\n\nFor our root partition, press `n` and then enter three times to create a root partition which takes up the rest\nof the disk.\n\nFinally, to save our changes, press `w` and then enter.\n\n## Formatting & Mounting our partitions\n\nFirst, format the root partition as `ext4`.\nThe root partition would be the second partition on the drive, for example: `\u002Fdev\u002Fsda2`.\n\n```sh\nmkfs.ext4 \u002Fdev\u002Froot_partition\n```\n\nAnd then format the EFI System partition.\nThe EFI system partition would be the first partition on the drive, for example: `\u002Fdev\u002Fsda1`.\n\n```sh\nmkfs.fat -F 32 \u002Fdev\u002Fefi_system_partition\n```\n\nThen, let's mount the root partition:\n\n```sh\nmount \u002Fdev\u002Froot_partition \u002Fmnt\u002Farch --mkdir\n```\n\nand the EFI partition:\n\n```sh\nmount \u002Fdev\u002Froot_partition \u002Fmnt\u002Farch\u002Fboot --mkdir\n```\n\n## Downloading the OS\n\nIf you've done a typical Arch\u002FGentoo install, you will notice that so far this has been very typical.\nThis is the part where things start to differ from the typical install guide.\nThis is because this guide will use efistub to boot the kernel instead of a conventional bootloader.\nefistub is basically just allows us to boot directly into the kernel without a bootloader.\n\nFirst, cd into the drive like so:\n\n```sh\ncd \u002Fmnt\u002Farch\n```\n\nthen, let's download the rootfs like so:\n\n```sh\nwget http:\u002F\u002Fos.archlinuxarm.org\u002Fos\u002FArchLinuxARM-aarch64-latest.tar.gz\n```\n\nYou can also use curl, or a browser, it doesn't matter.\n\nBeware that this might take a while.\n\nA rootfs is essentially a linux distribution packaged into a tarball. The entire root filesystem is packaged and distributed.\nThis makes it excellent for use in containers or `chroot`'s, but it can be more difficult to use if you are using it\nfor bare metal.\n\nNow that it's done, extract it like so:\n\n```sh\nbsdtar -xpvf ArchLinuxARM-aarch64-latest.tar.gz -C \u002Fmnt\u002Farch\n```\n\nor if you don't have bsdtar:\n\n```sh\ntar xpvf ArchLinuxARM-aarch64-latest.tar.gz --xattrs-include='*.*' --numeric-owner -C \u002Fmnt\u002Farch\n```\n\nwhich will unpack it into our partitions.\n\n## Making the fstab\n\nLet's now generate the fstab, this file tells the operating system what partitions to mount at boot.\nYou can either make it yourself, or, you can use `genfstab`.\nMaking it ourselves is the easier option, so we will do that.\nFirst, get your partition UUID's by running `blkid`. These will also be important later on.\n\nThen, edit the fstab by replacing the UUID's accordingly, with the first UUID being the one of the first partition,\nand the second UUID being the UUID of the second partition.\n\n```sh\ncat > \u002Fmnt\u002Farch\u002Fetc\u002Ffstab \u003C\u003C \"EOF\"\nUUID=XXXX-XXXX                               \u002Fboot    vfat    defaults,noatime    0 2\nUUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX    \u002F        ext4    noatime             0 1\nEOF\n```\n\n## Making the startup script\n\nBecause we are unable to set up **proper** boot functionality without being actually booted into the OS,\nwe have to use a startup.nsh script.\nThis is the UEFI's last resort if there is absolutely nothing else available to boot.\nReplace the UUID with the UUID of the **root** partition, not the boot one.\n\n```sh\ncat > \u002Fmnt\u002Farch\u002Fboot\u002Fstartup.nsh \u003C\u003C \"EOF\"\nImage root=UUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX rw initrd=\\initramfs-linux.img\nEOF\n```\n\n## Getting ready for first boot\n\nFirst, unmount the partitions:\n\n```sh\numount \u002Fmnt\u002Farch\u002Fboot\numount \u002Fmnt\u002Farch\n```\n\nthen, reboot like so:\n\n```sh\nreboot\n```\n\n## Using the startup.nsh\n\nWhile you reboot, enter your UEFI settings by pressing whatever key (different on every computer),\nand attempt to boot with the UEFI Shell. If you can't find it, remove the live media and attempt to reboot.\n\nThen, it should give you a message about pressing escape to skip startup.nsh. Do **not** press escape.\n\nWith any luck, you should be booted into your brand new system! But you're not done yet.\n\n## Networking\n\nAs far as I know, Archlinux ARM only comes with tools for ethernet.\nIf you use ethernet it should work out of the box, if you use wifi, you would have to figure out how to chroot into the new install.\n\nInstructions for chrooting into an Arch install without `arch-chroot` can be found [on the Arch wiki](https:\u002F\u002Fwiki.archlinux.org\u002Ftitle\u002Fchroot#Using_chroot). From there you just have to install a wireless manager and whatever else you might need.\n\nYou can check your internet by running:\n\n```sh\nping google.com\n```\n\n## Getting a proper boot setup\n\nNow that we can boot, let's make this an actual proper system.\n\nLog in as `root` with the password: `root`.\n\nThen, let's setup the keys:\n\n```sh\npacman-key --init\npacman-key --populate archlinuxarm\n```\n\nthen, update the system:\n\n```sh\npacman -Syu\n```\n\nNow, let's install `efibootmgr`:\n\n```sh\npacman -S efibootmgr\n```\n\n### Using efistub\n\nIf you would like to use efistub for all future boots, read on.\nHowever, you can also use grub, which is a bit easier and more familiar, and if you want to read [Using GRUB](#using-grub).\n\nAnd create the boot entry:\nReplace `\u003Cxxx>` with your **disk**, not a partition. So for example, `\u002Fdev\u002Fsda`.\nand the UUID with the UUID of the root partition.\nYou can get the UUID with the `blkid` command.\n\n```sh\nefibootmgr --disk \u002Fdev\u002Fxxx --part 1 --create --label \"Arch Linux ARM\" --loader \u002FImage --unicode 'root=UUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX rw initrd=\\initramfs-linux.img' --verbose\n```\n\nand then reboot:\n\n```sh\nreboot\n```\n\n### Using GRUB\n\nIf you would like to use grub, first, install the grub package:\n\n```sh\npacman -S grub\n```\n\nthen install it to your ESP:\n\n```sh\ngrub-install --target=arm64-efi --efi-directory=\u002Fboot --bootloader-id=Arch\n```\n\nand generate the config:\n\n```sh\ngrub-mkconfig -o \u002Fboot\u002Fgrub\u002Fgrub.cfg\n```\n\nand then finally reboot:\n\n```sh\nreboot\n```\n\n## Finishing up\n\nFirst, install a text editor like `vim` or `nano`:\n\n```sh\npacman -S nano # for nano\npacman -S vim # for vim\n```\n\nyou can also delete the tarball we downloaded to save disk space like so:\n\n```sh\nrm \u002FArchLinuxARM-aarch64-latest.tar.gz\n```\n\n### Hostname\n\nThen, pick a hostname by editing `\u002Fetc\u002Fhostname`, for example:\n\n```txt\nbobs-pc\n```\n\n### Hosts\n\nAnd set the `\u002Fetc\u002Fhosts` file to:\n\n```txt\n127.0.0.1    localhost\n::1          localhost\n```\n\nfor basic aliases.\n\n### Time zone\n\nSet your timezone like so:\n\n```sh\nln -sf \u002Fusr\u002Fshare\u002Fzoneinfo\u002F\u003CRegion>\u002F\u003CCity> \u002Fetc\u002Flocaltime\n```\n\nand run this to generate `\u002Fetc\u002Fadjtime`:\n\n```sh\nhwclock --systohc\n```\n\n### Localization\n\nEdit `\u002Fetc\u002Flocale.gen` and uncomment `en_US.UTF-8 UTF-8` as well as any other locales you want.\n\nTo generate them, run:\n\n```sh\nlocale-gen\n```\n\nYou should also create `\u002Fetc\u002Flocale.conf` and set the LANG variable properly:\n\n```txt\nLANG=en_US.UTF-8\n```\n\n### Users\n\nAdd a new user like so:\nReplace `\u003Cuser>` with the name of the user.\n\n```sh\nuseradd -G wheel,audio,video -m \u003Cuser>\n```\n\nand set the password for the user:\n\n```sh\npasswd \u003Cuser>\n```\n\nas well as setting the root password:\n\n```sh\npasswd\n```\n\nAdditionally, Arch Linux ARM comes with a normal user for ssh (`alarm`), but we do not need them, so we can delete them:\n\n```sh\nuserdel -r alarm\n```\n\n## And you're done\n\nYou can now reboot the system, and login as the user you created.\n\n## What next?\n\nYou can try installing a graphical environment (which may be very challenging), or installing other tools.\nYou may also want to install sudo and some other convenient packages. Maybe try to get graphics working?\n\n## Credits\n\nA massive props goes to [this github gist](https:\u002F\u002Fgist.github.com\u002Fthalamus\u002F561d028ff5b66310fac1224f3d023c12)\nwhich explains how to do some of the same things, just using a different approach.\n",1792699493203]