{"id":1000,"date":"2019-08-05T14:38:17","date_gmt":"2019-08-05T20:38:17","guid":{"rendered":"https:\/\/wmbuck.net\/blog\/?p=1000"},"modified":"2020-02-15T09:23:10","modified_gmt":"2020-02-15T16:23:10","slug":"setting-up-arch-on-uefi-laptop","status":"publish","type":"post","link":"https:\/\/wmbuck.net\/blog\/?p=1000","title":{"rendered":"Setting up Arch on UEFI laptop"},"content":{"rendered":"\n<p>A good friend had mentioned to me that he used Arch linux in one of his recent installs. I&#8217;ve never tried it. I have this old HP laptop that a different friend gave me, when he replaced it. It isn&#8217;t that old! I decided to try installing Arch on it. <\/p>\n\n\n\n<p>I had a bunch of issues, and ultimately today I resolved to reinstall the thing again, and record my experience. One of the issues &#8211; as usual a self-inflicted wound &#8211; is that this is a UEFI capable laptop, but the disk that is in it is MBR partitioned, not GUID partitioned. It probably would have been smarter to just partition the disk with a GUID table. But I didn&#8217;t. Below is the description of what I did.<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>Here starts an additional edit, recounting how, my first (actually my second, and even my third) attempt went wrong, after appearing to work.  I eventually figured out why, so before describing what worked, it may be useful to review the mistakes for the lessons they give. <\/p>\n\n\n\n<p>I was following an installation guide on the net for installing       Arch, because I had no experience with Arch or pacman. But I had some differences in my environment so I was modifying the instructions as I went along and adapting. I adapted a little too aggressively, and alas incorrectly. <\/p>\n\n\n\n<p>On almost all the boxes I build I have gotten into the habit of       having a separate \/boot partition. I suppose this really isn&#8217;t all       that necessary anymore, particularly if one is using UEFI but I       got into the habit long ago. The instructions I was following did not create a separate \/boot (so I adapted). Also, the instructions were for bios rather than uefi, and this box is uefi so I had to adapt that too &#8211; had to create an efi system partition etc. So early on in my adventure, I partitioned the disk with 4 partitions: an esp a \/boot, \/ and swap. <\/p>\n\n\n\n<p>When one installs the basic arch one apparently doesn&#8217;t automatically get an \/etc\/fstab, and the instructions at one point called for generating one, with a command genfstab, which I have never had to use on any other distribution. Being unfamiliar with it, and because I was unfortunately just following along by rote at that point, I failed to think about the fact that neither the \/boot nor the esp was actually mounted at that point in the instructions. The upshot is that  therefore no fstab record got created in fstab for the \/boot partition. <\/p>\n\n\n\n<p>Later in the instructions I had to &#8220;adapt&#8221; and mount \/boot before I wrote the grub onto the disk, and before I installed the grub config &#8212; and I adapted those parts &#8220;correctly&#8221;, so that the system booted up just fine. However, because there was no automount in fstab for \/boot, it wasn&#8217;t being mounted after a reboot. Well this was fine, the system boots just fine without mounting \/boot. Right up to the time you need to write something on the \/boot partition.&nbsp; <\/p>\n\n\n\n<p>The problem comes when at some point you do some update which updates the kernel (or probably if you install anything that has to build a new initramfs). Because now the &#8220;real&#8221; \/boot partition is not mounted.  When grub or mkinitrd or whatever writes new stuff to reflect the new kernel (or whatever) onto \/boot, it is not writing it on the boot partition but on a local \/boot directory. <\/p>\n\n\n\n<p>So what ends up happening is something like this: a new kernel n+1 (vmlinuz and initramfs) is written on the \/boot local directory, but not on the missing \/boot partition. A \/lib\/modules directory is written with the modules directory for kernel n+1. <\/p>\n\n\n\n<p>Speculation: the \/lib\/modules directory for kernel n seems at this point to have been removed, because it isn&#8217;t there later on, and I&#8217;m guessing that this is because at this point there is no kernel n visible (because the \/boot partition containing it isn&#8217;t mounted). We don&#8217;t need \/lib\/modules\/n if there is not a kernel\/initramfs for release n. I&#8217;m not sure of that part, I just know there was no \/lib\/modules\/n later on. <\/p>\n\n\n\n<p>When the actual boot takes place, grub is still loading from the \/boot partition, and so it actually still loads kernel n. But now there aren&#8217;t any modules for kernel n to load anymore. With no modules the system comes up as a basic module free system, no graphics driver, no network driver, etc. <\/p>\n\n\n\n<p>I am pretty sure this was my problem, although I haven&#8217;t worked through all the details of exactly what happens, and how it gets to the state it is in. But it was certainly true that uname -r gave me a release name which was not present in \/lib\/modules. I am a little surprised that it was able to bring up gdm at all. <\/p>\n\n\n\n<p>After writing this, at one point I lost the laptop again and had to restore. Some of my instructions were wrong, and in any case I changed the laptop over to a GPT partition table, and reinstalled. I had some trouble, so I want to get the revised instructions down. <\/p>\n\n\n\n<p>Partition the  hard disk <\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\/dev\/sda1 \/efi 512MB type efi<\/li><li>\/dev\/sda2 \/root <\/li><li>I didn&#8217;t need a swap<\/li><\/ul>\n\n\n\n<p>Format the disks:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>mkfs.fat -n EFI \/dev\/sda1<\/li><li> mkfs.ext4 \/dev\/sda2<\/li><\/ul>\n\n\n\n<p>And mount the root partition to-be so we can mess with it.  <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mount \/dev\/sda2 \/mnt<\/pre>\n\n\n\n<p>Install the basic system<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">pacstrap \/mnt base base-devel linux \\ \n         linux-firmware emacs NetworkManager<\/pre>\n\n\n\n<p>Create fstab<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">genfstab -U -p \/mnt &gt;&gt; \/mnt\/etc\/fstab<\/pre>\n\n\n\n<p>Now chroot into the newly created root partition<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">arch-chroot \/mnt <\/pre>\n\n\n\n<p>Set the hostname in \/etc\/hosts and hostname and $HOSTNAME<\/p>\n\n\n\n<p>Generate locale info. <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">uncomment US.UTF-8 in \/etc\/locale.gen\nlocale-gen \necho LANG=en_US.UTF-8 &gt; \/etc\/locale.conf\nexport LANG=en_US.UTF-8<\/pre>\n\n\n\n<p>Set the timezone and set hardware clock<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">rm \/etc\/localtime\nln -s \/usr\/share\/zoneinfo\/America\/Denver \\    \n    \/etc\/localtime \nhwclock \u2013systohc \u2013utc <\/pre>\n\n\n\n<p>Update the software: <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">pacman -Syu <\/pre>\n\n\n\n<p>Set password for root <\/p>\n\n\n\n<p>Create user dee<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">useradd -mg users -G wheel,storage,power \\\n   -s \/bin\/bash dee <\/pre>\n\n\n\n<p>Set the password for dee <\/p>\n\n\n\n<p>Now install additional software we need.  I need subversion because I pull a lot of config stuff out of my repository, including a setup script that builds a lot of stuff (sshd, postfix, samba, nfs, and much more).  <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">pacman -S sudo subversion \\ \n   grub os-prober mtools efibootmgr \\ \n   xorg xorg-server networkmanager \\\n   gnome gnome-extra <\/pre>\n\n\n\n<p>I like to not have to type in a password when I sudo. Fix group wheel to be no password. <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">export EDITOR=emacs \nvisudo <\/pre>\n\n\n\n<p>Now the booting stuff. <\/p>\n\n\n\n<p>Mount the efi partition before trying to write grub. <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mkdir \/efi; mount \/dev\/sda1 \/efi <\/pre>\n\n\n\n<p>Install grub onto the new disk<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">grub-install  --target=x86_64-efi \\\n    \u2013efi-directory=\/efi \\\n    \u2013bootloader-id=GRUB \/dev\/sda <\/pre>\n\n\n\n<p>And generate the grub config file for grub to drive off of<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">grub-mkconfig -o \/boot\/grub\/grub.cfg <\/pre>\n\n\n\n<p>Now exit out of the chroot, back to the live image. Then unmount and reboot. <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">exit  \numount -a\nreboot<\/pre>\n\n\n\n<p>When the system comes back up, which it should do unless I screwed something up,  login as root and start gdm. Don&#8217;t enable it yet, be sure everything is working in graphical.target before doing so.  <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">systemctl start gdm <\/pre>\n\n\n\n<p>Log in as dee, be sure everything is working, have network, terminal, sudo, etc., then enable gdm. <\/p>\n\n\n\n<p>Now retrieve the scripts to finish setup. Ensure \/usr\/local\/bin is empty the remove it. Pull in the scripts, ensure everything is executable, use a script to make symlinks for all the &#8220;common&#8221; local bin scripts (used by all my boxes). <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">cd \/usr\/local\nrm bin\nsvn co \\ https:\/\/svn.wmbuck.net\/svn\/adminscripts\/localbin\\\n           \/&lt;hostname> bin\nchmod +x .\/*\ncd common\nchmod +x .\/*\n.\/commonlocalbin\n<\/pre>\n\n\n\n<p>The last step is the script which finishes the setup. <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">box_setup<\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>A good friend had mentioned to me that he used Arch linux in one of his recent installs. I&#8217;ve never tried it. I have this old HP laptop that a different friend gave me, when he replaced it. It isn&#8217;t that old! I decided to try installing Arch on it. I had a bunch of &hellip; <a href=\"https:\/\/wmbuck.net\/blog\/?p=1000\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Setting up Arch on UEFI laptop<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[42,40,4],"tags":[],"class_list":["post-1000","post","type-post","status-publish","format-standard","hentry","category-arch-linux","category-boot-issues","category-linux"],"_links":{"self":[{"href":"https:\/\/wmbuck.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1000"}],"collection":[{"href":"https:\/\/wmbuck.net\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wmbuck.net\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wmbuck.net\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/wmbuck.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1000"}],"version-history":[{"count":11,"href":"https:\/\/wmbuck.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1000\/revisions"}],"predecessor-version":[{"id":1073,"href":"https:\/\/wmbuck.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1000\/revisions\/1073"}],"wp:attachment":[{"href":"https:\/\/wmbuck.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1000"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wmbuck.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1000"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wmbuck.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1000"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}