Jail question: packages with relative symlinks

Valeri Galtsev galtsev at kicp.uchicago.edu
Wed Aug 26 16:39:20 UTC 2020



> On Aug 26, 2020, at 11:28 AM, Matthew Seaman <matthew at FreeBSD.org> wrote:
> 
> On 25/08/2020 22:30, Valeri Galtsev wrote:
>> I probably didn't explain things detailed enough.
>> 
>> my jail has its root in:
>> 
>> /jail/[jailname]
>> 
>> so all what is inside jail on host filesystem is visible as:
>> 
>> /jail/[jailname]/s/etc
>> /jail/[jailname]/etc --> s/etc
>> /jail/[jailname]/usr
>> /jail/[jailname]/s/usr-local
>> /jail/[jailname]/usr/local --> ../s/usr-local
>> ...
>> 
>> the
>> 
>> /jail/[jailname]
>> 
>> is base system mounted read-only (with symlinks etc pointing to s/etc,
>> and others which point to a single place
>> 
>> /jail/[jailname]/s
>> 
>> which is mounted read-write, and this is the only place inside jail
>> which  is read-write. This is the wonderful idea which inside jail makes
>> base system read-only. And it is convenient, as you maintain only one
>> base system (of given version) for all jails. And as you correctly said,
>> chroot is used (in addition to other things), so inside jail what on
>> host is /jail/[jailname]/ is plainly /
>> 
>> I hope, this provides enough detail to un-confuse things (and the need
>> of symlinks when one sets up jails "by the book", meaning FreeBSD Handbook)
>> 
>> Valeri
> 
> There's a '--relocate' flag to pkg-add(8) which almost does what you
> want.  The idea is that it allows you to prepend an arbitrary path to
> the location where the package is installed.  In your case, that would
> mean running
> 
> pkg add --relocate /jail/[jailname]  some-package
> 

Matthew, thanks for a nice idea! It has never occurred to me. Basically, as package is installed by executing pkg command in jail, pkg already sees /jail/[jailname] as / , but as I care of symlinks, and all writable is in jail mounted as /s/ , relocation of that package to /s may do the trick. I will check that, and will report if it solves my case, I just could not hold myself and answered now being this excited by idea that looks so simple so it is next to genius, and which never occurred to me…

Valeri

> However I'm not sure how well that works for installing the same package
> in several different jails, or in your jail and in the host system --
> you might need to play games with using several different $PKG_DBDIR setups.
> 
> Also, it only works with pkg-add(8), not pkg-install(8) or
> pkg-upgrade(8).  It is an experimental feature intended for use in
> cross-installing packages for a small appliance by mounting its drive
> onto a larger and more capable machine.
> 
> 	Cheers,
> 
> 	Matthew
> 
> 	
> 



More information about the freebsd-questions mailing list