articles/reflector/index.html (view raw)
1<!doctype html><html><head><meta charset=utf-8><meta http-equiv=x-ua-compatible content="IE=edge"><title>BiRabittoh - Update your mirrors!</title><meta name=viewport content="width=device-width,initial-scale=1"><meta name=description content="Nah, I’m not talking about bluetooth mirrors. Mirrors are what powers all distros: they’re a (de)centralized solution for downloading pre-compiled binaries and scripts for your operating system.
2Suspicion I like always having the most current version of packages, so I usually update my system several times a day. When, after a day, I ran sudo pacman -Syu and it reported the system being up to date, I was pretty weirded out."><meta property="og:image" content><meta property="og:title" content="Update your mirrors!"><meta property="og:description" content="Nah, I’m not talking about bluetooth mirrors. Mirrors are what powers all distros: they’re a (de)centralized solution for downloading pre-compiled binaries and scripts for your operating system.
3Suspicion I like always having the most current version of packages, so I usually update my system several times a day. When, after a day, I ran sudo pacman -Syu and it reported the system being up to date, I was pretty weirded out."><meta property="og:type" content="article"><meta property="og:url" content="https://birabittoh.github.io/articles/reflector/"><meta property="article:section" content="articles"><meta property="article:published_time" content="2023-01-29T12:48:40+01:00"><meta property="article:modified_time" content="2023-01-29T12:48:40+01:00"><meta name=twitter:card content="summary"><meta name=twitter:title content="Update your mirrors!"><meta name=twitter:description content="Nah, I’m not talking about bluetooth mirrors. Mirrors are what powers all distros: they’re a (de)centralized solution for downloading pre-compiled binaries and scripts for your operating system.
4Suspicion I like always having the most current version of packages, so I usually update my system several times a day. When, after a day, I ran sudo pacman -Syu and it reported the system being up to date, I was pretty weirded out."><script src=https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js></script>
5<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital,wght@1,500&display=swap" rel=stylesheet><link href="https://fonts.googleapis.com/css2?family=Fira+Sans&display=swap" rel=stylesheet><link href="https://fonts.googleapis.com/css?family=Roboto+Mono" rel=stylesheet><link rel=stylesheet type=text/css media=screen href=https://birabittoh.github.io/css/main.823a02873f9d13d4e370d9c1cd104ef671b4bdae30491788f8cb01eff700eaf4.css><link id=darkModeStyle rel=stylesheet type=text/css href=https://birabittoh.github.io/css/dark.726cd11ca6eb7c4f7d48eb420354f814e5c1b94281aaf8fd0511c1319f7f78a4.css disabled></head><body><div class=content><header><div class=main><a href=https://birabittoh.github.io/>BiRabittoh</a></div><nav><a href=/articles>Articles</a>
6| <span id=dark-mode-toggle onclick=toggleTheme()></span>
7<script src=https://birabittoh.github.io/js/themetoggle.js></script></nav></header><main><article><div class=title><h1 class=title>Update your mirrors!</h1><div class=meta>Posted 2023-01-29</div></div><section class=body><p>Nah, I’m not talking about <a href=https://www.bathshack.com/blog/bluetooth-mirrors-everything-you-need-to-know-before-you-buy/>bluetooth mirrors</a>. Mirrors are what powers all distros: they’re a (de)centralized solution for downloading pre-compiled binaries and scripts for your operating system.</p><h2 id=suspicion>Suspicion</h2><p>I like always having the most current version of packages, so I usually update my system several times a day. When, after a day, I ran <code>sudo pacman -Syu</code> and it reported the system being up to date, I was pretty weirded out.</p><p>Another day passed, and the system was still up to date. It was not a connection problem, I was connecting to my mirrors and they were reporting absolutely zero updates for my system.</p><h2 id=problem>Problem</h2><p>At the third day of stagnation, I was sure something was up. I looked up the <a href=https://archlinux.org/mirrors/status/>Mirror Status</a> page on ArchLinux’s website and saw that loads of mirrors were out of sync.</p><p>I had never touched my mirrorlist before, it was just generated by the <a href=https://github.com/archlinux/archinstall>archinstall</a> script a few months ago; a lot of Arch-based distros by default ship tools to update your mirrorlist, but I honestly thought I’d never need that.</p><p>Pacman’s mirrorlist is located in <code>/etc/pacman.d/mirrorlist</code>. You can filter out uncommented lines with this command:</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-fallback data-lang=fallback><span style=display:flex><span>grep -v "^#" /etc/pacman.d/mirrorlist
8</span></span></code></pre></div><p>And check the actual status of your mirror(s) on the Mirror Status page linked above.</p><h2 id=solution>Solution</h2><p>This will overwrite your mirrorlist, so you’re advised to make a backup before proceeding:</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-fallback data-lang=fallback><span style=display:flex><span>sudo cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak
9</span></span></code></pre></div><p>I decided to use <a href=https://xyne.dev/projects/reflector/>reflector</a> to fix this problem. I didn’t want to have to deal with this again, so I enabled the provided systemd timer.</p><p>First, install it.</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-fallback data-lang=fallback><span style=display:flex><span>sudo pacman -S reflector
10</span></span></code></pre></div><p>Then, edit <code>/etc/xdg/reflector/reflector.conf</code>. I only needed to edit the <code>--country</code> parameter and select countries next to the one where I reside; you can list available countries by running <code>reflector --list-countries</code>.</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-fallback data-lang=fallback><span style=display:flex><span>--save /etc/pacman.d/mirrorlist
11</span></span><span style=display:flex><span>--protocol https
12</span></span><span style=display:flex><span>--country Italy,Switzerland,France,Germany,Austria
13</span></span><span style=display:flex><span>--latest 5
14</span></span><span style=display:flex><span>--sort age
15</span></span></code></pre></div><p>Finally, start the service and check if it worked.</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-fallback data-lang=fallback><span style=display:flex><span>sudo systemctl start reflector.service
16</span></span><span style=display:flex><span>cat /etc/pacman.d/mirrorlist
17</span></span></code></pre></div><p>If everything went smoothly, enable reflector’s timer so it runs weekly.</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-fallback data-lang=fallback><span style=display:flex><span>sudo systemctl enable reflector.timer
18</span></span></code></pre></div><p>Done!</p><p>Now, by default pacman <em>does</em> update its mirrorlist. It creates a file called <code>mirrorlist.pacnew</code> and it expects you to pick your favorite mirrors each time its generated. You can disable this (now unneeded) behavior by uncommenting and setting <code>NoExtract</code> in <code>/etc/pacman.conf</code>:</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-fallback data-lang=fallback><span style=display:flex><span>...
19</span></span><span style=display:flex><span>NoExtract = /etc/pacman.d/mirrorlist.pacnew
20</span></span><span style=display:flex><span>
21</span></span><span style=display:flex><span># Misc options
22</span></span><span style=display:flex><span>Color
23</span></span><span style=display:flex><span>ILoveCandy
24</span></span><span style=display:flex><span>ParallelDownloads = 3
25</span></span><span style=display:flex><span>...
26</span></span></code></pre></div></section><div class=post-tags><nav class="nav tags"><ul class=tags><li><a href=/tags/foss>foss</a></li><li><a href=/tags/advice>advice</a></li></ul></nav></div></article></main><footer><div style=display:flex><a class=border></a><a class=soc href=/articles/index.xml rel=me title="RSS Feed"><i data-feather=rss></i></a>
27<a class=border></a><a class=soc href=https://github.com/BiRabittoh rel=me title=GitHub><i data-feather=github></i></a>
28<a class=border></a><a class=soc href=https://www.linkedin.com/in/marco-andronaco/ rel=me title=LinkedIn><i data-feather=linkedin></i></a>
29<a class=border></a><a class=soc href=mailto:andronacomarco@gmail.com rel=me title=E-Mail><i data-feather=mail></i></a>
30<a class=border></a></div></footer><script>feather.replace()</script></div></body></html>