惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

爱范儿
爱范儿
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
美团技术团队
博客园_首页
罗磊的独立博客
WordPress大学
WordPress大学
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
IT之家
IT之家
人人都是产品经理
人人都是产品经理
博客园 - 聂微东
Jina AI
Jina AI
V
V2EX
雷峰网
雷峰网
T
Tailwind CSS Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
J
Java Code Geeks
O
OpenAI News
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 三生石上(FineUI控件)
T
Threatpost
Scott Helme
Scott Helme
Latest news
Latest news
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tor Project blog
S
SegmentFault 最新的问题
Apple Machine Learning Research
Apple Machine Learning Research
C
Cyber Attacks, Cyber Crime and Cyber Security
有赞技术团队
有赞技术团队
大猫的无限游戏
大猫的无限游戏
C
CERT Recently Published Vulnerability Notes
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
宝玉的分享
宝玉的分享
小众软件
小众软件
I
Intezer
The Hacker News
The Hacker News
Project Zero
Project Zero
博客园 - 叶小钗
T
Threat Research - Cisco Blogs
T
The Exploit Database - CXSecurity.com
S
Schneier on Security
阮一峰的网络日志
阮一峰的网络日志
腾讯CDC
NISL@THU
NISL@THU
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Cybersecurity and Infrastructure Security Agency CISA
博客园 - 【当耐特】
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Hugging Face - Blog
Hugging Face - Blog
P
Privacy & Cybersecurity Law Blog
P
Proofpoint News Feed

sakurawald's blog

fix-window-tearing-in-high-monitor-refresh-rate fix-nvidia-drm-issues fix-screen-brightness-too-low Fix sddm black screen issue comparing-emacs-and-idea-in-java-development-environment fix the cpu frequency throttle after bad charging how to let chrome browser auto clean datas on exit make persistent windows 11 usb sticker pin refresh rate of an android phone launch tor browser without tor network rescue a corrupted system after forced shutdown during system upgrade apple magic touch pad review guide to install qubes on qemu optimize minecraft server configuration tweak KDE preferences android emulator methods in linux expression evulation
how to fix corrupted packages in archlinux
2024-07-11 · via sakurawald's blog

Problem

If you machine is force shutdown during the process of pacman -Syu, it’s possible the packages are in partial update state.
To fix this problem, we need to do:

  1. Find out how bad it is. (How many packages are corrupted)
  2. Re-install these corrupted packages.

Solution

Setup the living-os

Insert your living-os sticker (You can make this sticker folloing the arch wiki).

Step:

  • Mount the root partition of your host os into /mnt
  • Connect to the Internet using iwctl.

Check the corrupted package list

Let’s say your pacman in the host os is corrupted, so that you need to use the pacman inside living os.
The command looks like pacman --root /mnt ....

To get the corrupted packages list in the host-os, issue

sudo LC_ALL=C pacman --root /mnt -Qkk >> list_packages.txt 2>&1
awk '/mtree/ {print}' ./list_packages.txt > filter_packages.txt
awk -F ':' '{print $1}' ./filter_packages.txt > collect_packages.txt
grep -v "error" collect_packages.txt > packages.txt

And all the corrupted packages are in packages.txt

Fix the pacman inside host-os

First, we need to update the keyring inside living os using pacman -Sy archlinux-keyring to resolve the outdated gpg keys.
Then, you can use pacman --root /mnt -S $(< packages.txt) to re-install all the corrupted packages.

If you need to modify mirrorlist, then you should modify the mirrorlist in living os, and use pacman -Syy to update databse.

Chroot into the host-os and do a fully-package upgrade again

You need to chroot into the host-os using arch-chroot /mnt
And issue pacman -Syu to upgrade all packages.
If pacman says “there is nothing to do”, then it done.

Fix the bootloader

To fix the bootloader

mount /dev/<root_partition> /mnt
mount /dev/<EFI_system_partition> /mnt/boot
arch-chroot /mnt
grub-mkconfig -o /boot/grub/grub.cfg
grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB
pacman -S linux