# How to tell what pkgs are installed



## balanga (May 21, 2021)

Is there some way of being able to detect which pkgs have been installed on a disk which is mounted but not booted from?

ie can you create a list by checking a mounted var/cache/pkg or perhaps you can use pkg-info() redirected to mount point, or via chroot...


----------



## SirDice (May 21, 2021)

balanga said:


> Is there some way of being able to detect which pkgs have been installed on a disk which is mounted but not booted from?


You can access the /var/db/pkg/local.sqlite database with sqlite3(1). It's just a database file. 


balanga said:


> ie can you create a list by checking a mounted var/cache/pkg


Not that worthwhile to look at, if they're like me it's going to be empty most of the time (I run `pkg clean -a` regularly).


----------



## T-Daemon (May 21, 2021)

balanga said:


> Is there some way of being able to detect which pkgs have been installed on a disk which is mounted but not booted from?


You can use chroot(8), or use pkg(8):

`pkg -c /mnt info`


----------



## balanga (May 21, 2021)

T-Daemon said:


> You can use chroot(8), or use pkg(8):
> 
> `pkg -c /mnt info`


So easy ?    Is /mnt /dev/daxpy  ?


----------



## T-Daemon (May 21, 2021)

balanga said:


> Is /mnt /dev/daxpy ?


Yes, it is.

I remembered correct. The three of us all, SirDice, you, and me met once on the same topic a year ago  :









						pkg info on non-boot disk/partition
					

If I have FreeBSD installed on a disk/partition from which I am not booting, is it possible to identify which pkgs have been installed?




					forums.freebsd.org


----------



## SirDice (May 21, 2021)

Same answers too, I like the consistency


----------



## balanga (May 21, 2021)

Well, at my age, memory is getting weaker....


----------



## balanga (Jun 1, 2021)

T-Daemon said:


> You can use chroot(8), or use pkg(8):
> 
> `pkg -c /mnt info`


I was trying to find which pkgs had been installed in a jail. Here is what I got:-


```
# pkg -c /mnt/nas/iocage/jails/server/root/var/db/pkg info
pkg: Unable to determine the ABI

pkg: Unable to determine the ABI

pkg: Unable to determine ABI
pkg: Cannot parse configuration file!
```

Need to find some other way.


----------



## SirDice (Jun 1, 2021)

balanga said:


> Need to find some other way.





SirDice said:


> You can access the /var/db/pkg/local.sqlite database with sqlite3(1).


----------



## T-Daemon (Jun 1, 2021)

balanga said:


> `# pkg -c /mnt/nas/iocage/jails/server/root/var/db/pkg info`


That can't work. You are chrooting pkg into directory /mnt/nas/iocage/jails/server/root/var/db/pkg. pkg needs to chrooted into the root directory, wherever root is, jail or otherwise.

It should be:
`# pkg -c /mnt/nas/iocage/jails/server/root info` or

`# pkg -c /mnt/nas/iocage/jails/server info` Not sure why you have a root directory there.


----------



## balanga (Jun 1, 2021)

Thanks the former works. The 'root' directory is something which FreeNAS uses when creating a jail.


----------

