You are not logged in.

#1 2020-01-26 16:35:44

stueja
Member
Registered: 2015-10-18
Posts: 44

[Solved] pacman CacheDir on NFS share while remote

On my laptop, /etc/pacman.conf is set up to use a central package share on an NFS server, mounted via fstab.

/etc/pacman.conf
------------------------
...
CacheDir    = /mnt/pkgcache/
CacheDir    = /var/cache/pacman/pkg/
...
/etc/fstab
-------------
192.168.122.11:/cloud/jan/files   /mnt/nfs  nfs  noauto,noatime,nofail,x-systemd.automount,x-systemd.device-timeout=10s,x-systemd.mount-timeout=15s,retry=0,_netdev,intr 0 0

This works wonderfully while the laptop is connected to the local network.
When the laptop, however, does not have connection to the NFS server, any form of upgrade (pacman -Syu) hangs in the "looking for conflicting packages" step

:: Synchronizing package databases...
 core                                                       133,5 KiB   754 KiB/s 00:00 [###################################################] 100%
 extra                                                     1643,2 KiB  3,82 MiB/s 00:00 [###################################################] 100%
 community                                                    4,8 MiB  6,20 MiB/s 00:01 [###################################################] 100%
 multilib                                                   161,7 KiB  12,1 MiB/s 00:00 [###################################################] 100%
:: Starting full system upgrade...
resolving dependencies...
looking for conflicting packages...

Usually, I then go ahead, comment out the line from /etc/pacman.conf and re-do the upgrade.

How can I leave the nfs share in /etc/pacman.conf and nevertheless do an upgrade while remote?

Last edited by stueja (2020-02-01 21:53:18)

Offline

#2 2020-01-26 16:52:18

teckk
Member
Registered: 2013-02-21
Posts: 380

Re: [Solved] pacman CacheDir on NFS share while remote

You could always have 2 pacman.conf files.
/etc/pacman1.conf
/etc/pacman2.conf

if [ -d "/mnt/pkgcache/" ]; then
    conf="/etc/pacman1.conf"
else
    conf="/etc/pacman2.conf"
fi

pacman --config "$conf" -Syu

Or just specify the config file

pacman --config /etc/pacman1.conf -Syu

Look at:
man pacman

Edit:
Fixed pacman --config /etc/pacman1.conf

Last edited by teckk (2020-01-26 17:23:23)

Offline

#3 2020-01-26 18:18:07

eschwartz
Trusted User/Bug Wrangler
Registered: 2014-08-08
Posts: 3,505

Re: [Solved] pacman CacheDir on NFS share while remote

Shouldn't NFS mounting simply fail after a timeout?


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#4 2020-01-26 23:03:51

stueja
Member
Registered: 2015-10-18
Posts: 44

Re: [Solved] pacman CacheDir on NFS share while remote

Oh, thanks for the tip with a second pacman.conf.
I'd probably forget about that always. Also I guess the -d test will return success, because the mount directory _is_ of course there. However it's empty. Need to check that.

As for the failing nfs mount, yes, it will fail after a timeout. 15s probably, as stated in fstab. That's probably the reason why pacman cannot access the directory and stalls.

Offline

#5 2020-02-01 21:52:51

stueja
Member
Registered: 2015-10-18
Posts: 44

Re: [Solved] pacman CacheDir on NFS share while remote

Currently trying the following solution:
a shell script determines the laptop's IP address. If it is not the IP address of my local network, then use a different pacman.conf.

#!/bin/bash

inetint=wlp2s0
ipaddress=$(ip -4 -o addr show dev $inetint | awk '{split($4,a,"/");print a[1]}')
configpath=/etc

echo "IP address is $ipaddress"

if [[ $ipaddress != 192.168.0.* ]]
then
	configfile=pacman-remote.conf
else
	configfile=pacman-local.conf
fi

echo "using config $configfile"

pacman --config=$configpath/$configfile -Syu
#pacman-remote.conf
[options]
# set CacheDir to local ssd
CacheDir = /var/cache/pacman/pkg/
# include remaining configuration items
Include = /etc/pacman-include.conf
# pacman-local.conf
[options]
# set CacheDir to local ssd
CacheDir = /mnt/pkgcache/
# include remaining configuration items
Include = /etc/pacman-include.conf
# pacman-include.conf
#
# /etc/pacman.conf
#
# See the pacman.conf(5) manpage for option and repository directives

#
# GENERAL OPTIONS
#
[options]
# The following paths are commented out with their default values listed.
# If you wish to use different paths, uncomment and update the paths.
#RootDir     = /
#DBPath      = /var/lib/pacman/

# commented out, CacheDir set in pacman-remote.conf / pacman-local.conf
#CacheDir    = /mnt/pkgcache/
#CacheDir    = /var/cache/pacman/pkg/
#LogFile     = /var/log/pacman.log
#GPGDir      = /etc/pacman.d/gnupg/
#HookDir     = /etc/pacman.d/hooks/
HoldPkg     = pacman glibc
#XferCommand = /usr/bin/curl -C - -f %u > %o
#XferCommand = /usr/bin/wget --passive-ftp -c -O %o %u
#CleanMethod = KeepInstalled
#UseDelta    = 0.7
Architecture = auto

# Pacman won't upgrade packages listed in IgnorePkg and members of IgnoreGroup
#IgnorePkg   =
#IgnoreGroup =

#NoUpgrade   =
#NoExtract   =

# Misc options
#UseSyslog
#Color
#TotalDownload
CheckSpace
#VerbosePkgLists

# By default, pacman accepts packages signed by keys that its local keyring
# trusts (see pacman-key and its man page), as well as unsigned packages.
SigLevel = Required DatabaseOptional
LocalFileSigLevel = Optional
#RemoteFileSigLevel = Required

# NOTE: You must run `pacman-key --init` before first using pacman; the local
# keyring can then be populated with the keys of all official Arch Linux
# packagers with `pacman-key --populate archlinux`.

#
# REPOSITORIES
#   - can be defined here or included from another file
#   - pacman will search repositories in the order defined here
#   - local/custom mirrors can be added here or in separate files
#   - repositories listed first will take precedence when packages
#     have identical names, regardless of version number
#   - URLs will have $repo replaced by the name of the current repo
#   - URLs will have $arch replaced by the name of the architecture
#
# Repository entries are of the format:
#       [repo-name]
#       Server = ServerName
#       Include = IncludePath
#
# The header [repo-name] is crucial - it must be present and
# uncommented to enable the repo.
#

# The testing repositories are disabled by default. To enable, uncomment the
# repo name header and Include lines. You can add preferred servers immediately
# after the header, and they will be used before the default mirrors.

#[testing]
#Include = /etc/pacman.d/mirrorlist

[core]
Include = /etc/pacman.d/mirrorlist

[extra]
Include = /etc/pacman.d/mirrorlist

#[community-testing]
#Include = /etc/pacman.d/mirrorlist

[community]
Include = /etc/pacman.d/mirrorlist

# If you want to run 32 bit applications on your x86_64 system,
# enable the multilib repositories as required here.

#[multilib-testing]
#Include = /etc/pacman.d/mirrorlist

[multilib]
Include = /etc/pacman.d/mirrorlist

# An example of a custom package repository.  See the pacman manpage for
# tips on creating your own repositories.
#[custom]
#SigLevel = Optional TrustAll
#Server = file:///home/custompkgs

Offline

#6 2020-03-09 23:29:57

RubenKelevra
Member
Registered: 2013-03-01
Posts: 35

Re: [Solved] pacman CacheDir on NFS share while remote

I wonder why this is an issue, if the mount fails, the folder should be readable, but empty and pacman would just ignore it. I haven't worked with NFS for a long while, so I'm not sure.

A different idea would be to switch to IPFS (I just posted the necessary information in this forum and saw your thread), you can just run IPFS on all computers and they will exchange data, or you could install IPFS on one computer and expose the web-gateway to your local network. If you're not in this network, you'll just get an address not reachable error for each download request.

Keep in mind, that IPFS will still fetch the packages on demand, when requested via the Web-Gateway. You can do a prefetch of the mirror, like ar rsync update (just a bit more efficient) with IPFS, if you want to copy your NFS-setup. The corresponding script to do this is in 'toolset/follow_cluster_parts.sh'.

The repo and all information about my project can be found here: pacman.store


Hope this helps! smile

Offline

Board footer

Powered by FluxBB