Solved /dev/null in chroot

Hello,
I'm trying to upgrade packages, using a Boot Environment on FreeBSD 11.3.
So, I use beadm to create a BE:
beadm create upd
and I mount it to /upd:
beadm mount upd /upd
Then I mount /dev to /upd/dev:
mount -t nullfs /dev /upd/dev
and chroot inside:
chroot /upd
Then I update pkg database inside chroot and try to upgrade packages:
pkg update
pkg upgrade
The problem is that (almost) every package upgrade finishes with post-install script with the following command inside:
/usr/sbin/service ldconfig restart > /dev/null
And when I am in chroot - it gives me the following error:
Code:
echo: write error on stdout
echo: write error on stdout
eval: write error on stdout
What should I do to get it working correctly?
 
try: mount -t devfs devfs /upd/dev for me it is mount -t devfs devfs /mnt/arm64zfs/dev
after creating a chroot environment, from outside the chroot, add devfs file system with a mount -t devfs to the chroot environment. see below inside the chroot environment the difference of the files available inside the /dev directory.

TL;DR Okay, 4 years later working on a Raspberry Pi 4B with 8 gigs dram, this piece of information helped me to
time make -j4 buildworld in a chroot environment as a root user.

The boot aarch64 kernel from the 1 TB SSD was overwritten. So I booted from a previous USB Flash Drive aarch64 RPI image on the raspberry pi 4B; zpool imported pool named arm64pool from 1 TB SSD. I created a mount directory point of /mnt/arm64zfs, attached the 1 TB SSD there and then chrooted there to cd /usr/src and run make buildworld and make buildkernel. Those builds needed the /dev directory with special character file, /dev/null. Touch /dev/null a normal file does not work properly for this make buildworld task, yet seems to satisfy the make buildkernel script needs.



Code:
# create a new chroot after:
zpool import -R /mnt/arm64zfs -N -f arm64pool
mkdir /mnt/arm64zfs
mount -t zfs arm64pool/ROOT/default /mnt/arm64zfs
zfs get bootfs
zfs mount -a
 
  chroot  /mnt/arm64zfs /bin/sh
  cd /usr/src
  git -C /usr/src pull --ff-only

This is what I saw inside chroot for the /dev directory from before the command. mount -t devfs devfs /mnt/arm64zfs/dev
Code:
root@generic:/usr/src # ls -l /dev/null
crw-rw-rw-  1 root wheel 0xf00 Sep 19 23:31 /dev/null
root@generic:/usr/src # ls -la /dev
total 10
dr-xr-xr-x   2 root wheel     3 Sep 19 23:31 .
drwxr-xr-x  24 root wheel    29 Sep 22 20:10 ..
crw-rw-rw-   1 root wheel 0xf00 Sep 19 23:31 null
Next, outside the chroot environment, issue the command mount -t devfs devfs /mnt/arm64zfs/dev Do this as root user from outside the chroot terminal. This is what I saw inside chroot for the /dev directory after the mount devfs command executed.
Code:
root@generic:/usr/src # ls -la /dev
total 14
dr-xr-xr-x  12 root wheel     512 Sep 20 00:09 .
drwxr-xr-x  24 root wheel      29 Sep 22 20:10 ..
crw-------   1 root kmem     0x13 Sep 19 09:01 audit
crw-------   1 root wheel    0x12 Sep 19 09:01 auditpipe
crw-------   1 root wheel     0xe Sep 19 09:02 bpf
lrwxr-xr-x   1 root wheel       3 Sep 20 00:09 bpf0 -> bpf
crw-------   1 root wheel     0x4 Sep 19 23:16 console
crw-------   1 root wheel    0x21 Sep 19 09:01 consolectl
crw-rw-rw-   1 root wheel    0x20 Sep 19 09:01 ctty
crw-rw----   1 uucp dialer   0x30 Sep 19 09:01 cuau0
crw-rw----   1 uucp dialer   0x31 Sep 19 09:01 cuau0.init
crw-rw----   1 uucp dialer   0x32 Sep 19 09:01 cuau0.lock
crw-r-----   1 root operator 0x60 Sep 19 09:01 da0
crw-r-----   1 root operator 0x62 Sep 19 09:01 da0s1
crw-r-----   1 root operator 0x63 Sep 19 09:01 da0s2
crw-r-----   1 root operator 0x67 Sep 19 09:01 da0s2a
crw-r-----   1 root operator 0x68 Sep 19 09:01 da0s2b
crw-r-----   1 root operator 0x83 Sep 19 09:31 da1
crw-r-----   1 root operator 0x85 Sep 19 09:31 da1p1
crw-r-----   1 root operator 0x86 Sep 19 09:31 da1p2
crw-r-----   1 root operator 0x87 Sep 19 09:31 da1p3
crw-------   1 root wheel     0xa Sep 19 09:01 devctl
crw-r--r--   1 root wheel     0x7 Sep 19 09:01 devctl2
cr--r--r--   1 root wheel    0x5e Sep 19 09:01 devstat
crwx------   1 root wheel    0x2b Sep 19 09:01 efi
crw-------   1 root wheel    0x34 Sep 19 09:01 fb0
dr-xr-xr-x   2 root wheel     512 Sep 20 00:09 fd
crw-------   1 root wheel    0x24 Sep 19 09:01 fido
crw-rw-rw-   1 root wheel     0xb Sep 19 09:01 full
crw-r-----   1 root operator  0x9 Sep 19 09:01 geom.ctl
crw-------   1 root wheel    0x2c Sep 19 09:01 gpioc0
crw-------   1 root wheel    0x33 Sep 19 09:01 gpioc1
dr-xr-xr-x   2 root wheel     512 Sep 20 00:09 gpt
dr-xr-xr-x   2 root wheel     512 Sep 20 00:09 gptid
dr-xr-xr-x   2 root wheel     512 Sep 20 00:09 input
lrwxr-xr-x   1 root wheel       7 Sep 20 00:09 kbd0 -> kbdmux0
lrwxr-xr-x   1 root wheel       5 Sep 20 00:09 kbd1 -> ukbd0
crw-------   1 root wheel    0x26 Sep 19 09:01 kbdmux0
crw-------   1 root wheel    0x15 Sep 19 09:01 klog
crw-r-----   1 root kmem     0x29 Sep 19 09:01 kmem
dr-xr-xr-x   2 root wheel     512 Sep 20 00:09 label
dr-xr-xr-x   2 root wheel     512 Sep 20 00:09 led
crw-------   1 root wheel    0x4a Sep 19 09:01 mdctl
crw-r-----   1 root kmem     0x28 Sep 19 09:01 mem
crw-rw-rw-   1 root wheel    0x16 Sep 19 09:01 midistat
crw-r-----   1 root operator 0x4e Sep 19 09:01 mlx5ctl
dr-xr-xr-x   2 root wheel     512 Sep 20 00:09 msdosfs
crw-rw-rw-   1 root wheel    0x18 Sep 19 09:01 music0
crw-------   1 root wheel    0x46 Sep 19 09:01 netdump
crw-rw-rw-   1 root wheel     0xc Sep 20 00:00 null
crw-------   1 root wheel    0x11 Sep 19 09:01 openfirm
crw-------   1 root operator 0x5f Sep 19 09:01 pass0
crw-------   1 root operator 0x82 Sep 19 09:31 pass1
crw-r--r--   1 root wheel    0x14 Sep 19 09:01 pci
crw-------   1 root wheel    0x47 Sep 19 09:01 pfil
crw-r--r--   1 root wheel     0x5 Sep 19 09:02 random
dr-xr-xr-x   2 root wheel     512 Sep 20 00:09 reroot
crw-rw-rw-   1 root wheel    0x17 Sep 19 09:01 sequencer0
crw-r--r--   1 root wheel     0x8 Sep 19 09:01 sndstat
lrwxr-xr-x   1 root wheel       4 Sep 20 00:09 stderr -> fd/2
lrwxr-xr-x   1 root wheel       4 Sep 20 00:09 stdin -> fd/0
lrwxr-xr-x   1 root wheel       4 Sep 20 00:09 stdout -> fd/1
crw-------   1 root wheel    0x22 Sep 19 09:01 sysmouse
cr--------   1 root wheel    0x1f Sep 19 09:01 tcp_log
crw-------   1 root wheel    0x2d Sep 20 00:09 ttyu0
crw-------   1 root wheel    0x2e Sep 19 09:01 ttyu0.init
crw-------   1 root wheel    0x2f Sep 19 09:01 ttyu0.lock
crw-------   1 root wheel    0x35 Sep 20 00:09 ttyv0
crw-------   1 root wheel    0x36 Sep 19 09:02 ttyv1
crw-------   1 root wheel    0x37 Sep 19 09:02 ttyv2
crw-------   1 root wheel    0x38 Sep 19 09:02 ttyv3
crw-------   1 root wheel    0x39 Sep 19 09:02 ttyv4
crw-------   1 root wheel    0x3a Sep 19 09:02 ttyv5
crw-------   1 root wheel    0x3b Sep 19 09:02 ttyv6
crw-------   1 root wheel    0x3c Sep 19 09:02 ttyv7
crw-------   1 root wheel    0x3d Sep 19 09:01 ttyv8
crw-------   1 root wheel    0x3e Sep 19 09:01 ttyv9
crw-------   1 root wheel    0x3f Sep 19 09:01 ttyva
crw-------   1 root wheel    0x40 Sep 19 09:01 ttyvb
dr-xr-xr-x   2 root wheel     512 Sep 20 00:09 ufs
crw-------   1 root wheel    0x43 Sep 19 09:01 ufssuspend
lrwxr-xr-x   1 root wheel       9 Sep 20 00:09 ugen0.1 -> usb/0.1.0
lrwxr-xr-x   1 root wheel       9 Sep 20 00:09 ugen0.2 -> usb/0.2.0
lrwxr-xr-x   1 root wheel       9 Sep 20 00:09 ugen0.3 -> usb/0.3.0
lrwxr-xr-x   1 root wheel       9 Sep 20 00:09 ugen0.4 -> usb/0.4.0
lrwxr-xr-x   1 root wheel       9 Sep 20 00:09 ugen0.5 -> usb/0.5.0
lrwxr-xr-x   1 root wheel       9 Sep 20 00:09 ugen0.6 -> usb/0.6.0
crw-r--r--   1 root operator 0x5a Sep 19 09:02 uhid0
crw-------   1 root wheel    0x10 Sep 19 09:01 uinput
crw-------   1 root wheel    0x72 Sep 19 09:01 ukbd0
crw-r--r--   1 root operator 0x5b Sep 19 09:02 ums0
lrwxr-xr-x   1 root wheel       6 Sep 20 00:09 urandom -> random
dr-xr-xr-x   2 root wheel     512 Sep 20 00:09 usb
crw-r--r--   1 root operator 0x48 Sep 19 09:01 usbctl
crw-------   1 root wheel    0x2a Sep 19 09:01 vcio
crw-------   1 root operator 0x49 Sep 19 09:01 xpt0
crw-rw-rw-   1 root wheel     0xd Sep 19 09:01 zero
crw-rw-rw-   1 root operator 0x65 Sep 19 09:31 zfs
root@generic:/usr/src #
This is new /dev directory inside the chroot. Now the make buildworld and make buildkernel commands will finish correctly without missing /dev/null special character file.
Here is my mounted files listed from commands mount and df -h . notice the devfs /mnt/arm64zfs/dev directory
Code:
root@generic:/usr/src # mount
/dev/ufs/rootfs on / (ufs, local, soft-updates)
devfs on /dev (devfs)
/dev/msdosfs/EFI on /boot/efi (msdosfs, local, noatime)
tmpfs on /tmp (tmpfs, local)
arm64pool/ROOT/default on /mnt/arm64zfs (zfs, local, noatime, nfsv4acls)
arm64pool/usr/ports on /mnt/arm64zfs/usr/ports (zfs, local, noatime, nosuid, nfsv4acls)
arm64pool/var/mail on /mnt/arm64zfs/var/mail (zfs, local, nfsv4acls)
arm64pool/tmp on /mnt/arm64zfs/tmp (zfs, local, noatime, nosuid, nfsv4acls)
arm64pool/usr/src on /mnt/arm64zfs/usr/src (zfs, local, noatime, nfsv4acls)
arm64pool/var/tmp on /mnt/arm64zfs/var/tmp (zfs, local, noatime, nosuid, nfsv4acls)
arm64pool/home on /mnt/arm64zfs/arm64pool/home (zfs, local, noatime, nfsv4acls)
arm64pool/var/audit on /mnt/arm64zfs/var/audit (zfs, local, noatime, noexec, nosuid, nfsv4acls)
arm64pool/var/crash on /mnt/arm64zfs/var/crash (zfs, local, noatime, noexec, nosuid, nfsv4acls)
arm64pool/var/log on /mnt/arm64zfs/var/log (zfs, local, noatime, noexec, nosuid, nfsv4acls)
arm64pool/poudriere on /mnt/arm64zfs/arm64pool/poudriere (zfs, local, noatime, nfsv4acls)
arm64pool/poudriere/jails/ghostbsd-13-2-aarch64 on /mnt/arm64zfs/usr/local/poudriere/jails/ghostbsd-13-2-aarch64 (zfs, local, noatime, nfsv4acls)
arm64pool/poudriere/ports/ghostbsd_ports on /mnt/arm64zfs/usr/local/poudriere/ports/ghostbsd_ports (zfs, local, noatime, nfsv4acls)
arm64pool/poudriere/jails on /mnt/arm64zfs/arm64pool/poudriere/jails (zfs, local, noatime, nfsv4acls)
arm64pool/poudriere/ports on /mnt/arm64zfs/arm64pool/poudriere/ports (zfs, local, noatime, nfsv4acls)
devfs on /mnt/arm64zfs/dev (devfs)
root@generic:/usr/src #

root@generic:/usr/src # df -h
Filesystem                                         Size    Used   Avail Capacity  Mounted on
/dev/ufs/rootfs                                     13G    2.9G    8.7G    25%    /
devfs                                              1.0K      0B    1.0K     0%    /dev
/dev/msdosfs/EFI                                    50M     25M     25M    51%    /boot/efi
tmpfs                                              3.5G    4.0K    3.5G     0%    /tmp
arm64pool/ROOT/default                             779G     22G    758G     3%    /mnt/arm64zfs
arm64pool/usr/ports                                777G     20G    758G     3%    /mnt/arm64zfs/usr/ports
arm64pool/var/mail                                 758G    192K    758G     0%    /mnt/arm64zfs/var/mail
arm64pool/tmp                                      758G     10M    758G     0%    /mnt/arm64zfs/tmp
arm64pool/usr/src                                  759G    1.3G    758G     0%    /mnt/arm64zfs/usr/src
arm64pool/var/tmp                                  758G     96K    758G     0%    /mnt/arm64zfs/var/tmp
arm64pool/home                                     758G     96K    758G     0%    /mnt/arm64zfs/arm64pool/home
arm64pool/var/audit                                758G     96K    758G     0%    /mnt/arm64zfs/var/audit
arm64pool/var/crash                                758G     96K    758G     0%    /mnt/arm64zfs/var/crash
arm64pool/var/log                                  758G    508K    758G     0%    /mnt/arm64zfs/var/log
arm64pool/poudriere                                758G    104K    758G     0%    /mnt/arm64zfs/arm64pool/poudriere
arm64pool/poudriere/jails/ghostbsd-13-2-aarch64    760G    2.1G    758G     0%    /mnt/arm64zfs/usr/local/poudriere/jails/ghostbsd-13-2-aarch64
arm64pool/poudriere/ports/ghostbsd_ports           761G    3.1G    758G     0%    /mnt/arm64zfs/usr/local/poudriere/ports/ghostbsd_ports
arm64pool/poudriere/jails                          758G     96K    758G     0%    /mnt/arm64zfs/arm64pool/poudriere/jails
arm64pool/poudriere/ports                          758G     96K    758G     0%    /mnt/arm64zfs/arm64pool/poudriere/ports
devfs                                              1.0K      0B    1.0K     0%    /mnt/arm64zfs/dev
 
Back
Top