構成

構成

私はchrootの内部にGlusterを配布するためのbashコマンドを書いています。グロストゲン。ホストからchrootへのファイルのマウントに問題があります。 Schrootのマニュアルページでは、以下を提案しています。

$ man schroot.conf | grep -A4 setup.fstab=
    setup.fstab=filename
            The filesystem table file to be used to mount filesystems within the chroot.  The format of this file is the same as for /etc/fstab, documented in fstab(5).  The  only  difference  is
            that  the  mountpoint  path fs_dir is relative to the chroot, rather than the root.  Also note that mountpoints are canonicalised on the host, which will ensure that absolute symlinks
            point inside the chroot, but complex paths containing multiple symlinks may be resolved incorrectly; it is inadvisable to use nested symlinks as mountpoints.

しかし、この設定値を で使用しようとすると、/etc/schroot/chroot.d/glusterchroot.confディレクトリがマウントされないようです。これを行うには追加する必要がありますか?

構成

コンテンツ/etc/schroot/chroot.d/glusterchroot.conf:

user@computer:~$ cat /etc/schroot/chroot.d/glusterchroot.conf
#
#
[glusterchroot]
description=Gluster server chroot
directory=/srv/glusterchroot
root-users=root
setup.fstab=glusterchroot/fstabfile
root-groups=root

コンテンツ/etc/schroot/glusterchroot/fstabfile:

user@computer:~$ cat /etc/schroot/glusterchroot/fstabfile 
/run/udev /run/udev none bind,create=file 0 0
sys /sys sysfs defaults 0 1
proc /proc proc defaults 0 0
/dev/ /dev none bind,create=file 0 0
/run/lvm /run/lvm none bind,create=file 0 0
/run/udev /run/udev none bind,create=file 0 0

glusterchrootについて:

user@computer:~$ schroot -i -c glusterchroot
  ─── Chroot ───
  Name                   glusterchroot
  Description            Gluster server chroot
  Type                   plain
  Message Verbosity      normal
  Users                  
  Groups                 
  Root Users             root
  Root Groups            root
  Aliases                
  Preserve Environment   false
  Default Shell          
  Environment Filter     ^(BASH_ENV|CDPATH|ENV|HOSTALIASES|IFS|KRB5_CONFIG|KRBCONFDIR|KRBTKFILE|KRB_CONF|LD_.*|LOCALDOMAIN|NLSPATH|PATH_LOCALE|RES_OPTIONS|TERMINFO|TERMINFO_DIRS|TERMPATH)$
  Run Setup Scripts      false
  Configuration Profile  default
  Script Configuration   
  Session Managed        false
  Session Cloned         false
  Session Purged         false
  Path                   /srv/glusterchroot
  Directory              /srv/glusterchroot
  Personality            undefined
  User Modifiable Keys   
  Root Modifiable Keys   
  User Data              
    setup.config         default/config
    setup.copyfiles      default/copyfiles
    setup.fstab          glusterchroot/fstabfile
    setup.nssdatabases   default/nssdatabases

setup.fstabまた、以下で説明したのと/etc/schroot/default/fstab同じ問題があるデフォルト値を試してみました。

質問

lschrootにマウントされたディレクトリ:

user@computer:~$ sudo schroot -d / -c glusterchroot -- ls /
bin  boot  dev  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
user@computer:~$ sudo schroot -d / -c glusterchroot -- ls /proc
user@computer:~$ sudo schroot -d / -c glusterchroot -- ls /run
lock  mount
user@computer:~$ sudo schroot -d / -c glusterchroot -- ls /sys

これらのインストールが必要なコマンドの例:

user@computer:~$ sudo schroot -d / -c glusterchroot -- findmnt
findmnt: can't read /proc/mounts: No such file or directory

lsホストの同じディレクトリから:

user@computer:~/Documents/gitRepos/generalK8s/glusterchroot$ ls /proc
1     1186  188   233   2541  2719  2864  3548   4     503    76879  903    96          driver         mdstat         thread-self
10    12    19    2334  2551  2720  2909  3549   40    506    777    90370  96493       dynamic_debug  meminfo        timer_list
100   1223  192   2338  2557  2721  2941  3551   404   507    778    904    96522       execdomains    misc           tty
101   124   1942  234   2561  2722  2965  3565   41    508    782    905    96847       fb             modules        uptime
1017  1254  1964  2344  2570  2723  2997  35710  4194  59014  784    906    97          filesystems    mounts         version
1019  1266  197   2362  2579  2724  3     3581   42    59433  787    907    98          fs             mtrr           version_signature
103   127   2     2366  2580  2725  30    3593   43    59435  788    910    99          interrupts     net            vmallocinfo
1032  13    20    24    2589  2726  3049  36     435   59541  8      913    acpi        iomem          pagetypeinfo   vmstat
1047  135   21    2427  26    2728  3052  3613   4358  6      83498  914    asound      ioports        partitions     zoneinfo
105   14    22    2444  2664  2737  3057  3629   4380  60307  86954  915    bootconfig  irq            pressure
106   15    2268  2477  2668  2743  3075  3639   44    60565  87016  91540  buddyinfo   kallsyms       schedstat
109   157   2281  2484  2678  2747  31    3640   4417  60773  87483  916    bus         kcore          scsi
11    16    2282  2487  2683  2748  3124  367    4498  68293  87490  917    cgroups     keys           self
110   1777  2288  25    2699  2785  32    3676   45    68316  87498  919    cmdline     key-users      slabinfo
1110  18    2289  2500  27    28    3220  37     471   70459  877    92     consoles    kmsg           softirqs
1111  1827  2290  2517  2701  2811  3234  3757   4792  75503  880    920    cpuinfo     kpagecgroup    stat
113   1848  2300  2524  2712  2812  3265  3768   4824  76661  881    922    crypto      kpagecount     swaps
114   185   2310  2525  2714  282   33    3784   4835  76738  883    93     devices     kpageflags     sys
115   186   2321  2532  2716  2821  34    38     4842  76855  884    93656  diskstats   loadavg        sysrq-trigger
1184  187   2329  2537  2717  2830  3545  39     5     76873  89805  94     dma         locks          sysvipc
user@computer:~/Documents/gitRepos/generalK8s/glusterchroot$ ls /sys
block  bus  class  dev  devices  firmware  fs  hypervisor  kernel  module  power
user@computer:~/Documents/gitRepos/generalK8s/glusterchroot$ ls /run
acpid.pid      crond.pid        docker.sock  log             openvpn-client  screen             spice-vdagentd    udev
acpid.socket   crond.reboot     fsck         lvm             openvpn-server  sendsigs.omit.d    sshd              udisks2
alsa           cups             gdm3         motd.d          plymouth        shm                sshd.pid          user
avahi-daemon   dbus             gdm3.pid     mount           pppconfig       sm-notify.pid      sudo              utmp
blkid          dmeventd-client  initctl      netns           rpcbind         snapd              systemd           uuidd
console-setup  dmeventd-server  initramfs    network         rpcbind.lock    snapd-snap.socket  thermald          vpnagentd.pid
containerd     docker           irqbalance   NetworkManager  rpcbind.sock    snapd.socket       tmpfiles.d        wpa_supplicant
credentials    docker.pid       lock         openvpn         rpc_pipefs      speech-dispatcher  ubuntu-advantag

答え1

ここで手がかりRun Setup Scripts falseはの出力にありますschroot -i -c glusterchroot。読んでみると、man schroot.conf次のような行が見えます。

type=type
              The type of the chroot.  Valid types are ‘plain’, ‘directory’, ‘file’, ‘loopback’, ‘block-device’, ‘btrfs-snapshot’, ‘zfs-snapshot’ and ‘lvm-snapshot’.  If empty or omitted,  the  de‐
              fault type is ‘plain’.  Note that ‘plain’ chroots do not run setup scripts and mount filesystems; ‘directory’ is recommended for normal use (see “Plain and directory chroots”, below).

次に更新すると/etc/schroot/chroot.d/glusterchroot.conf問題が解決しました。

[glusterchroot]
description=Gluster server chroot
preserve-environment=true
directory=/srv/glusterchroot
root-users=root
personality=linux
setup.fstab=default/fstab
type=directory
root-groups=root

関連情報