If your system becomes unbootable, it may be necessary to manually fix it by logging into your installation. This process can be more complex when encrypted drives are involved. Here’s a guide to help you chroot into a LUKS-encrypted Arch Linux install.
To begin, you need a live installation of Arch Linux. Tools like Ventoy are great for creating bootable USB drives. Ensure your system’s firmware is set to boot in the same mode (UEFI or BIOS) as your installed Arch Linux.
If your drive is encrypted with LUKS, use the following command to unlock it:
1sudo cryptsetup luksOpen /dev/<your_disk> luks-partition
cryptsetup
: Utility for managing LUKS encryption.luksOpen
: Opens (unlocks) a LUKS-encrypted partition./dev/<your_disk>
: Replace <your_disk>
with the actual device identifier (e.g., /dev/sda2
). Use lsblk
to list block devices and identify the correct one.luks-partition
: The name you assign to the unlocked partition. This creates a device mapper entry at /dev/mapper/luks-partition
.You will be prompted to enter your encryption passphrase to unlock the drive.
Once the partition is unlocked, you need to mount it:
1sudo mkdir /mnt/arch
2sudo mount /dev/mapper/luks-partition /mnt/arch
Change to the mounted directory and chroot into the system:
1cd /mnt/arch
2sudo arch-chroot .
You are now inside your Arch Linux installation. From here, you can troubleshoot and resolve the issues causing your system to be unbootable. Common tasks include:
GRUB
or systemd-boot
).Once you’re done, exit the chroot environment:
1exit
By following these steps, you should be able to access your encrypted Arch Linux installation and resolve any critical issues effectively.
In the unlikely event that you manage to corrupt your pacman
database, the following commands can help you rebuild and recover it. These steps will ensure all affected or installed packages are correctly reinstalled and the database integrity is restored.
If the database structure is corrupted but the package metadata is still readable, you can use the following command to rebuild it:
1pacman --dbonly -S $(LC_ALL=C pacman -Qkk 2>/dev/null | sed '/no mtree/!d; s/:.*//g')
pacman --dbonly -S
: Reinstalls packages but only modifies the database without extracting files.pacman -Qkk
: Checks the integrity of installed packages.LC_ALL=C
: Ensures consistent locale settings for predictable output.sed '/no mtree/!d; s/:.*//g'
: Filters the output to identify packages with missing mtree
entries (an indicator of database corruption).To force a full refresh of the package database and resolve any conflicting or outdated entries, run:
1pacman -Syy --overwrite $(pacman -Qnq) "*"
pacman -Syy
: Forces a database refresh from all repositories.--overwrite
: Allows files that are already present in the filesystem to be replaced.$(pacman -Qnq)
: Lists all explicitly installed packages to ensure they are included in the refresh."*"
: Matches all files during the reinstallation process.Packages installed from the AUR (e.g., via helpers like yay
) are not managed by pacman
directly. If these packages are affected by the database corruption, you will need to manually rebuild and reinstall them using your AUR helper. For example:
1yay -S <package-name> --overwrite "*"
Clear Package Cache: If corruption persists, clearing the package cache can help:
1sudo pacman -Sc
Reinstall Base System: For severe cases, consider reinstalling the base system:
1sudo pacman -S base
By following these steps, you should be able to recover from most cases of Pacman database corruption effectively. For further details, consult the Arch Wiki.
Signing your Git commits with a GPG key can help verify the authenticity of your changes. Instead of manually specifying the -S
flag with each commit, you can configure Git to automatically sign your commits.
To set this up globally, run the following commands:
1git config --global user.signingKey <yourSigningKey>
2git config --global commit.gpgSign true
user.signingKey
: Specifies the GPG key you want to use for signing commits. Replace <yourSigningKey>
with the actual GPG key ID.commit.gpgSign
: Enables automatic signing of all commits.Once configured, Git will sign all your commits by default, making it easier to ensure your commits are properly authenticated without needing to manually specify the -S
flag each time.
When switching between branches in Git, it’s possible that files you have open in Vim may have been modified outside of the editor, without you realizing it. This can lead to a situation where the buffer in Vim becomes stale and no longer reflects the current state of the file on disk.
To handle this more effectively, you can configure Vim to automatically detect and reload files when they change on disk. Here’s how you can set this up in your .vimrc
:
1set autoread
2au CursorHold * checktime
set autoread
: This tells Vim to automatically reload a file if it has been modified externally.au CursorHold * checktime
: This creates an auto-command that triggers a check whenever the cursor is idle for a brief moment (CursorHold
). It checks whether the file has changed since it was last read.With these settings in place, Vim will automatically reload the buffer if the file changes on disk, helping you stay in sync with the latest changes.
If you’ve made local changes to the file and haven’t saved them, Vim will alert you that the file has been modified externally. You’ll then have the option to either:
This ensures that you can make informed decisions about how to handle the state of your file, avoiding conflicts between the file on disk and your in-memory buffer.
Welcome to my new microblog! This space is inspired by Julia Evans’ recent post on starting a microblog (link), and I plan to use it as a place to jot down quick notes, discoveries, and solutions to technical problems. It’ll also serve as a way to publish some long-term draft posts that may have otherwise stayed unfinished.
My first attempt here accidentally turned into a full-length blog post: How to Delay Application Startup in Xfce.
So, I guess I’ll need to work on keeping things short and to the point!
BTW: There’s a separate RSS feed for the microblog here.