# bootc exec-in-host-mount-namespace - Quick Reference ## Command Summary | Command | Purpose | Usage | |---------|---------|-------| | `exec-in-host-mount-namespace` | Execute command in host mount namespace | `bootc exec-in-host-mount-namespace [ARGS]...` | ## Quick Commands ### Basic Operations ```bash # Execute command in host mount namespace bootc exec-in-host-mount-namespace ls / # Execute with arguments bootc exec-in-host-mount-namespace mount /dev/sda1 /mnt # Execute system command bootc exec-in-host-mount-namespace systemctl status ``` ### System Operations ```bash # Check host filesystem bootc exec-in-host-mount-namespace df -h # View host processes bootc exec-in-host-mount-namespace ps aux # Check host system status bootc exec-in-host-mount-namespace systemctl status ``` ### Installation Operations ```bash # Create directories in host filesystem bootc exec-in-host-mount-namespace mkdir -p /var/lib/bootc # Copy files to host filesystem bootc exec-in-host-mount-namespace cp /source/file /host/destination/ # Set permissions bootc exec-in-host-mount-namespace chmod 644 /host/file ``` ## Common Options | Option | Purpose | Example | |--------|---------|---------| | `--help` | Show help | `bootc exec-in-host-mount-namespace --help` | | `--verbose` | Verbose output | `bootc exec-in-host-mount-namespace -v ls /` | | `--quiet` | Quiet output | `bootc exec-in-host-mount-namespace -q ls /` | ## Error Codes | Code | Meaning | Solution | |------|---------|----------| | 1 | General error | Check logs for details | | 2 | Missing command | Provide command to execute | | 3 | Namespace access error | Check /proc/1/ns/mnt exists | | 4 | setns error | Run as root | | 5 | Command not found | Use full path to command | ## Common Issues ### Missing Command ```bash # Error: Missing command # Solution: Provide a command bootc exec-in-host-mount-namespace ls / # Or use a shell bootc exec-in-host-mount-namespace /bin/bash ``` ### Namespace Access Error ```bash # Error: open pid1 mountns: No such file or directory # Solution: Check if /proc/1/ns/mnt exists ls -la /proc/1/ns/mnt # Run as root sudo bootc exec-in-host-mount-namespace ls / ``` ### setns Error ```bash # Error: setns: Operation not permitted # Solution: Run as root sudo bootc exec-in-host-mount-namespace ls / # Check capabilities getcap /usr/bin/bootc ``` ### Command Not Found ```bash # Error: exec: command not found # Solution: Use full path bootc exec-in-host-mount-namespace /bin/ls / # Check command availability bootc exec-in-host-mount-namespace which ls ``` ## Environment Variables | Variable | Purpose | Default | |----------|---------|---------| | `RUST_LOG` | Log level | `info` | | `BOOTC_DEBUG` | Debug mode | `false` | | `BOOTC_CONFIG` | Config file | `/etc/bootc/config.toml` | ## Configuration Files | File | Purpose | Location | |------|---------|----------| | Main config | Bootc configuration | `/etc/bootc/config.toml` | | Namespace info | Namespace information | `/proc/1/ns/mnt` | | Process info | Process information | `/proc/self/ns/mnt` | ## Log Files | File | Purpose | Location | |------|---------|----------| | System logs | System messages | `/var/log/messages` | | Journal logs | Systemd journal | `journalctl -u bootc-*` | | Bootc logs | Bootc specific | `/var/log/bootc/` | ## Performance Tips ### Optimize Operations ```bash # Check system load uptime # Check memory usage free -h # Check namespace overhead time bootc exec-in-host-mount-namespace /bin/true time /bin/true ``` ### Monitor System ```bash # Check namespace availability ls -la /proc/1/ns/mnt # Check namespace differences diff /proc/1/ns/mnt /proc/self/ns/mnt # Check system performance bootc exec-in-host-mount-namespace top -bn1 | head -20 ``` ## Security Considerations ### Root Privileges - All exec-in-host-mount-namespace commands require root privileges - Use `sudo` or switch to root user - Check current user with `whoami` ### Namespace Access - Command accesses host mount namespace through `/proc/1/ns/mnt` - Requires appropriate privileges for namespace switching - Uses `setns` system call for namespace switching ### Process Isolation - Command executes in host mount namespace - Current process is replaced with target command - Provides access to host filesystem view ## Best Practices ### Regular Operations - Use only when host mount namespace access is needed - Check command availability before execution - Implement proper error handling - Monitor system performance ### Development - Use in container environments - Test commands before production use - Document procedures - Monitor system health ### Production - Set up monitoring - Configure alerts - Regular testing - Document procedures ## Troubleshooting Steps 1. **Check command availability** ```bash bootc exec-in-host-mount-namespace which ``` 2. **Check namespace availability** ```bash ls -la /proc/1/ns/mnt ``` 3. **Check privileges** ```bash whoami sudo bootc exec-in-host-mount-namespace ``` 4. **Check logs** ```bash journalctl -u bootc-* --since "1 hour ago" tail -f /var/log/bootc/main.log ``` 5. **Test command execution** ```bash bootc exec-in-host-mount-namespace /bin/true ``` ## Quick Scripts ### Health Check ```bash #!/bin/bash bootc exec-in-host-mount-namespace /bin/true && echo "System healthy" ``` ### Namespace Test ```bash #!/bin/bash bootc exec-in-host-mount-namespace ls / && echo "Namespace access OK" ``` ### Command Test ```bash #!/bin/bash bootc exec-in-host-mount-namespace which "$1" && echo "Command available" ``` ### System Check ```bash #!/bin/bash bootc exec-in-host-mount-namespace uname -a && echo "System check OK" ``` ## Integration Examples ### Systemd Service ```bash # Create service file cat > /etc/systemd/system/bootc-exec-in-host-mount-namespace.service << EOF [Unit] Description=Bootc Exec in Host Mount Namespace Service After=multi-user.target [Service] Type=oneshot ExecStart=/usr/local/bin/bootc-exec-in-host-mount-namespace-script.sh User=root Group=root [Install] WantedBy=multi-user.target EOF # Enable service systemctl daemon-reload systemctl enable bootc-exec-in-host-mount-namespace.service ``` ### Cron Job ```bash # Add to crontab echo "0 2 * * * /usr/local/bin/bootc-exec-in-host-mount-namespace-maintenance.sh" | crontab - ``` ### Monitoring ```bash # Check system health if ! bootc exec-in-host-mount-namespace /bin/true > /dev/null 2>&1; then echo "WARNING: Exec-in-host-mount-namespace failed" # Send alert fi ``` This quick reference provides essential information for using the bootc exec-in-host-mount-namespace system effectively.