Solved /proc/ is not mounted error when I try to chroot ubuntu 23.10 installed inside the Linuxulator...

I know this old thread but my problem is connected to: So after ubuntu lts 24 upgrade I tried tricks above and got rid from systemd errors, but reached standstill of pulseaudio; be more detailed it's service share works inside chroot only, and need manually intervene to point to socket everytime.. Also is there a non-systemd ubuntu distribution?

 
You want to use Rocky Linux because it doesnt have the systemd issues that Ubuntu has

I would also recommend using Rocky Linux Podman containers or a Rocky Linux jail
instead of using a chroot

This is my freebsd-cuda project that enables Cuda on using Rocky Linux Podman containers
which has a pulseaudio socket for apps that need it


This is the nix package manager in a Podman container
( which doesnt have cuda support )


Here is Davinci Resolve running in a Rocky Linux Jail with pulseaudio


If you have a look through those projects you should get the idea

Forget about Ubuntu on Freebsd using a chroot, jail or podman container
you will just get lots of systemd errors

You want to set up Rocky Linux as the default for the Linuxulator
then use Rocky Linux Podman containers and they work perfectly together that my advice
I don't use chroot, I complain about pulseaduio no more auto connect like before (works only inside chroot sessions). also forgot to mention, I can't use rocky linux nor debian; need specific packages available for ubuntu.
 
I can't use rocky linux nor debian; need specific packages available for ubuntu.
What packages? Backports?

You shouldn't need any particular distro's packages unless you're dealing with some real hot garbage. Even then you should be easily able to extract what is within the packages and get them running on another distro. Assuming the whole "Don't break userspace" promise on the Linux side still holds true.

But here is the thing about that promise: They never promised userspace wouldn't break userspace and lately a certain piece of cancer running as PID1 everywhere in the Linux world has been hell bent on doing that. So maybe you need a bunch of shims to make it work on an actual Linux distro and not what is basically Fedora with a skin on it like modern Ubuntu and pretty much everything else from ArchLinux to Gentoo is.

It's only going to get worse in the near future. We have a about 1 year on the current LTS linux kernel which is the last real release in my opinion. Since the LKML just changed some major rules and dropped lots of hardware support/drivers. Which are now marked "abandoned" and "possible security exploit because some AI said it might be and no one bothered to check for real". They're "abandoned" because all the Russians and other people unlucky enough to be born in the wrong country who were removed from contributing for no other reason than Linus doesn't want to lose his DoD paycheck were the people that were maintaining them. By old hardware I mean a lot of stuff released between 1999-2015 by the way. Even freakin' drivers for old mice were yanked out in the latest merge window.

Oh and now they're letting anyone submit code generated with AI who are no longer being required to tag it as so. They voted to remove that rule in the last few weeks. Even Linus submitted a new large diff generated fully with AI. Along with all the documentation and even the emails he sent to the mailing lists about it. Real expert engineering happening over there wouldn't you agree?

Save yourself the headache and 1) Use a different distro for your linuxemu/VM needs and 2) Figure out some other way to get the userspace software you need (I suggest building it from source code).
 
I don't use chroot, I complain about pulseaduio no more auto connect like before (works only inside chroot sessions). also forgot to mention, I can't use rocky linux nor debian; need specific packages available for ubuntu.

Thanks to Claude,some year ago I've been able to fix all the problems given by Ubuntu installed inside the chroot. Claude creates some concatenated and iterative patches that fixed the Ubuntu problems as soon as they are produced again and again. Not sure where I saved it.
 
Thanks to Claude,some year ago I've been able to fix all the problems given by Ubuntu installed inside the chroot. Claude creates some concatenated and iterative patches that fixed the Ubuntu problems as soon as they are produced again and again. Not sure where I saved it.
I will be really grateful :)
 
I will be really grateful :)

Code:
#!/bin/bash
# Script V2 - Fix completo per Ubuntu su FreeBSD Linux Emulation
# Include: systemd, udev, snapd, desktop apps, chrome, brave
# Autore: Mario - Versione 2.0

set -e

echo "╔═══════════════════════════════════════════════════════════════╗"
echo "║  Fix SystemD + Desktop Apps per FreeBSD - Versione 2.0       ║"
echo "╚═══════════════════════════════════════════════════════════════╝"

# 1. Crea lo script principale aggiornato
cat > /usr/local/sbin/fix-systemd-freebsd.sh << 'MAINSCRIPT'
#!/bin/bash
# Script V2 per risolvere problemi systemd e desktop apps su FreeBSD

set -e

BOLD='\033[1m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
BLUE='\033[0;34m'
NC='\033[0m'

log_info() {
    echo -e "${GREEN}[INFO]${NC} $1"
}

log_warn() {
    echo -e "${YELLOW}[WARN]${NC} $1"
}

log_error() {
    echo -e "${RED}[ERROR]${NC} $1"
}

log_step() {
    echo -e "${BLUE}[STEP]${NC} $1"
}

check_freebsd_emulation() {
    if grep -q "linprocfs" /proc/mounts 2>/dev/null || [ -f "/.freebsd_chroot" ]; then
        log_info "✓ Rilevata Linux emulation su FreeBSD"
        return 0
    fi
    log_warn "Non sembra essere un ambiente FreeBSD Linux emulation"
    return 1
}

fix_locales() {
    log_step "Configurazione locale..."
    
    if ! locale -a 2>/dev/null | grep -q "it_IT.utf8"; then
        log_info "Installazione locale it_IT.UTF-8..."
        DEBIAN_FRONTEND=noninteractive apt-get install -y locales 2>/dev/null || true
        locale-gen it_IT.UTF-8 2>/dev/null || true
        update-locale LANG=it_IT.UTF-8 2>/dev/null || true
    fi
    
    export LANG=it_IT.UTF-8
    export LC_ALL=it_IT.UTF-8
    log_info "✓ Locale configurato"
}

remove_stale_locks() {
    log_step "Rimozione lock stale..."
    
    local locks=(
        "/etc/passwd.lock"
        "/etc/group.lock"
        "/etc/shadow.lock"
        "/etc/gshadow.lock"
        "/etc/.pwd.lock"
        "/var/lib/dpkg/lock"
        "/var/lib/dpkg/lock-frontend"
        "/var/cache/apt/archives/lock"
    )
    
    local removed=0
    for lock in "${locks[@]}"; do
        if [ -f "$lock" ]; then
            rm -f "$lock"
            removed=$((removed + 1))
        fi
    done
    
    if [ $removed -gt 0 ]; then
        log_info "✓ Rimossi $removed lock"
    else
        log_info "✓ Nessun lock stale trovato"
    fi
}

handle_snapd() {
    log_step "Gestione snapd..."
    
    # Rimuovi hook APT di snap
    rm -f /etc/apt/apt.conf.d/20snapd.conf
    rm -f /etc/apt/apt.conf.d/*snap* 2>/dev/null || true
    
    if dpkg -l | grep -q "^ii.*snapd"; then
        log_warn "snapd installato - metto in hold (non funziona su FreeBSD)"
        apt-mark hold snapd 2>/dev/null || true
        
        # Crea wrapper per evitare errori
        if [ -f "/var/lib/dpkg/info/snapd.postinst" ]; then
            cp /var/lib/dpkg/info/snapd.postinst /var/lib/dpkg/info/snapd.postinst.bak 2>/dev/null || true
            cat > /var/lib/dpkg/info/snapd.postinst << 'EOF'
#!/bin/bash
# Wrapper per FreeBSD - snapd non supportato
exit 0
EOF
            chmod +x /var/lib/dpkg/info/snapd.postinst
        fi
        log_info "✓ snapd in hold con wrapper"
    else
        log_info "✓ snapd non installato"
    fi
}

backup_problematic_scripts() {
    log_step "Backup script postinst problematici..."
    
    local scripts=(
        "systemd"
        "systemd-timesyncd"
        "systemd-resolved"
        "systemd-networkd"
        "udev"
        "desktop-file-utils"
        "brave-browser"
        "google-chrome-stable"
    )
    
    local backed_up=0
    for script in "${scripts[@]}"; do
        local postinst="/var/lib/dpkg/info/${script}.postinst"
        local backup="${postinst}.freebsd-backup"
        
        if [ -f "$postinst" ] && [ ! -f "$backup" ]; then
            cp "$postinst" "$backup"
            backed_up=$((backed_up + 1))
        fi
    done
    
    log_info "✓ Backup di $backed_up script"
}

create_systemd_wrappers() {
    log_step "Creazione wrapper per systemd e servizi correlati..."
    
    local scripts=(
        "systemd"
        "systemd-timesyncd"
        "systemd-resolved"
        "systemd-networkd"
        "udev"
    )
    
    local created=0
    for script in "${scripts[@]}"; do
        local postinst="/var/lib/dpkg/info/${script}.postinst"
        local backup="${postinst}.freebsd-backup"
        
        if [ -f "$backup" ]; then
            cat > "$postinst" << 'WRAPPER_EOF'
#!/bin/bash
# Wrapper per FreeBSD Linux emulation - systemd/udev
set +e
export SYSTEMD_IGNORE_CHROOT=1

rm -f /etc/passwd.lock /etc/group.lock /etc/shadow.lock 2>/dev/null

SCRIPT_NAME="$(basename $0)"
BACKUP_SCRIPT="${SCRIPT_NAME}.freebsd-backup"
BACKUP_PATH="$(dirname $0)/$BACKUP_SCRIPT"

if [ -f "$BACKUP_PATH" ]; then
    timeout 30s bash "$BACKUP_PATH" "$@" 2>&1 | \
        grep -v "Failed to take /etc/passwd lock" | \
        grep -v "Invalid argument" || true
fi

exit 0
WRAPPER_EOF
            chmod +x "$postinst"
            created=$((created + 1))
        fi
    done
    
    log_info "✓ Creati $created wrapper systemd/udev"
}

create_desktop_wrappers() {
    log_step "Creazione wrapper per applicazioni desktop..."
    
    local apps=(
        "desktop-file-utils"
        "brave-browser"
        "google-chrome-stable"
    )
    
    local created=0
    for app in "${apps[@]}"; do
        local postinst="/var/lib/dpkg/info/${app}.postinst"
        local backup="${postinst}.freebsd-backup"
        
        if [ -f "$backup" ]; then
            cat > "$postinst" << 'WRAPPER_EOF'
#!/bin/bash
# Wrapper per FreeBSD Linux emulation - desktop apps
set +e

SCRIPT_NAME="$(basename $0)"
BACKUP_SCRIPT="${SCRIPT_NAME}.freebsd-backup"
BACKUP_PATH="$(dirname $0)/$BACKUP_SCRIPT"

if [ -f "$BACKUP_PATH" ]; then
    bash "$BACKUP_PATH" "$@" > /dev/null 2>&1 || true
fi

exit 0
WRAPPER_EOF
            chmod +x "$postinst"
            created=$((created + 1))
        fi
    done
    
    log_info "✓ Creati $created wrapper desktop"
}

fix_google_chrome() {
    log_step "Fix google-chrome-stable files list..."
    
    if dpkg -l | grep -q "google-chrome-stable" && \
       [ ! -f "/var/lib/dpkg/info/google-chrome-stable.list" ]; then
        log_warn "Files list mancante per google-chrome-stable"
        
        # Crea un files list vuoto per evitare warning
        touch /var/lib/dpkg/info/google-chrome-stable.list
        
        # Aggiungi alcuni percorsi comuni
        cat > /var/lib/dpkg/info/google-chrome-stable.list << 'EOF'
/opt/google/chrome
/usr/bin/google-chrome
/usr/bin/google-chrome-stable
/usr/share/applications/google-chrome.desktop
EOF
        log_info "✓ Files list ricreato"
    else
        log_info "✓ google-chrome OK"
    fi
}

restore_original_scripts() {
    log_step "Ripristino script originali..."
    
    local scripts=(
        "systemd"
        "systemd-timesyncd"
        "systemd-resolved"
        "systemd-networkd"
        "udev"
        "desktop-file-utils"
        "brave-browser"
        "google-chrome-stable"
    )
    
    local restored=0
    for script in "${scripts[@]}"; do
        local postinst="/var/lib/dpkg/info/${script}.postinst"
        local backup="${postinst}.freebsd-backup"
        
        if [ -f "$backup" ]; then
            cp "$backup" "$postinst"
            chmod +x "$postinst"
            restored=$((restored + 1))
        fi
    done
    
    log_info "✓ Ripristinati $restored script"
}

fix_dpkg_database() {
    log_step "Verifica database dpkg..."
    
    dpkg --configure -a --force-confold 2>&1 | \
        grep -v "Failed to take /etc/passwd lock" | \
        grep -v "xdg-icon-resource" | \
        grep -v "Operation not permitted" || true
    
    apt-get -f install -y 2>&1 | \
        grep -v "Failed to take /etc/passwd lock" | \
        grep -v "xdg-icon-resource" || true
    
    log_info "✓ Database dpkg verificato"
}

disable_systemd_services() {
    log_step "Disabilitazione servizi systemd incompatibili..."
    
    mkdir -p /etc/systemd/system-preset
    cat > /etc/systemd/system-preset/99-freebsd.preset << 'EOF'
# Preset per FreeBSD Linux emulation
disable systemd-timesyncd.service
disable systemd-networkd.service
disable systemd-resolved.service
disable systemd-tmpfiles-setup.service
disable systemd-tmpfiles-clean.timer
disable snapd.service
disable snapd.socket
EOF
    
    local services=(
        "systemd-tmpfiles-setup.service"
        "systemd-tmpfiles-clean.timer"
        "snapd.service"
        "snapd.socket"
    )
    
    for service in "${services[@]}"; do
        systemctl mask "$service" 2>/dev/null || true
    done
    
    log_info "✓ Servizi disabilitati"
}

create_freebsd_marker() {
    touch /.freebsd_chroot
    cat > /.freebsd_chroot << EOF
FreeBSD Linux Emulation Chroot
Created: $(date)
Script Version: 2.0
EOF
}

show_summary() {
    echo ""
    echo "╔═══════════════════════════════════════════════════════════╗"
    echo "║                    RIEPILOGO FIX                          ║"
    echo "╚═══════════════════════════════════════════════════════════╝"
    echo ""
    echo -e "${GREEN}Pacchetti gestiti:${NC}"
    echo "  ✓ systemd, systemd-*, udev"
    echo "  ✓ snapd (hold/disabled)"
    echo "  ✓ desktop-file-utils"
    echo "  ✓ brave-browser"
    echo "  ✓ google-chrome-stable"
    echo ""
    echo -e "${YELLOW}Note:${NC}"
    echo "  • I wrapper intercettano automaticamente gli errori"
    echo "  • Gli hook APT si attivano ad ogni upgrade"
    echo "  • Snapd è in hold (non funziona su FreeBSD)"
    echo ""
}

main() {
    echo ""
    echo -e "${BOLD}=== Fix SystemD + Desktop per FreeBSD Linux Emulation V2 ===${NC}"
    echo ""
    
    check_freebsd_emulation || log_warn "Continuo comunque..."
    
    case "${1:-}" in
        --pre-upgrade)
            log_info "Modalità PRE-UPGRADE"
            create_freebsd_marker
            fix_locales
            remove_stale_locks
            handle_snapd
            backup_problematic_scripts
            create_systemd_wrappers
            create_desktop_wrappers
            fix_google_chrome
            disable_systemd_services
            log_info "${GREEN}✓ Sistema preparato per l'upgrade${NC}"
            ;;
            
        --post-upgrade)
            log_info "Modalità POST-UPGRADE"
            remove_stale_locks
            fix_dpkg_database
            # Non ripristinare gli script - lasciali wrappati
            log_info "${GREEN}✓ Post-upgrade completato${NC}"
            ;;
            
        --restore)
            log_info "Modalità RESTORE (ripristino originali)"
            restore_original_scripts
            log_info "${GREEN}✓ Script originali ripristinati${NC}"
            ;;
            
        *)
            log_info "Modalità COMPLETA (setup iniziale)"
            create_freebsd_marker
            fix_locales
            remove_stale_locks
            handle_snapd
            backup_problematic_scripts
            create_systemd_wrappers
            create_desktop_wrappers
            fix_google_chrome
            disable_systemd_services
            show_summary
            echo -e "${GREEN}Sistema pronto per l'upgrade!${NC}"
            echo ""
            echo "Comandi disponibili:"
            echo "  apt update && apt upgrade"
            ;;
    esac
    
    echo ""
    echo -e "${BOLD}${GREEN}=== Completato ===${NC}"
}

main "$@"
MAINSCRIPT

chmod +x /usr/local/sbin/fix-systemd-freebsd.sh
echo "✓ Script principale V2 creato"

# 2. Crea hook APT completo
cat > /etc/apt/apt.conf.d/99freebsd-systemd-fix << 'EOF'
// Hook automatico per fix systemd su FreeBSD - V2

// PRE-UPGRADE: prepara il sistema
DPkg::Pre-Install-Pkgs {
    "if [ -f /usr/local/sbin/fix-systemd-freebsd.sh ]; then echo '[FreeBSD Fix V2] PRE-UPGRADE'; /usr/local/sbin/fix-systemd-freebsd.sh --pre-upgrade 2>&1 | logger -t apt-freebsd-v2; fi";
};

// POST-UPGRADE: pulisce
DPkg::Post-Invoke {
    "if [ -f /usr/local/sbin/fix-systemd-freebsd.sh ]; then echo '[FreeBSD Fix V2] POST-UPGRADE'; /usr/local/sbin/fix-systemd-freebsd.sh --post-upgrade 2>&1 | logger -t apt-freebsd-v2; fi";
};
EOF

echo "✓ Hook APT V2 creato"

# 3. Esegui il fix iniziale
echo ""
echo "╔═══════════════════════════════════════════════════════════╗"
echo "║            Esecuzione fix iniziale V2...                  ║"
echo "╚═══════════════════════════════════════════════════════════╝"
echo ""
/usr/local/sbin/fix-systemd-freebsd.sh

echo ""
echo "╔═══════════════════════════════════════════════════════════╗"
echo "║          ✓✓✓ INSTALLAZIONE V2 COMPLETATA ✓✓✓             ║"
echo "╚═══════════════════════════════════════════════════════════╝"
echo ""
echo "Funzionalità V2:"
echo "  ✓ Fix automatico systemd, udev"
echo "  ✓ Gestione snapd (hold/disabled)"
echo "  ✓ Fix desktop-file-utils, brave, chrome"
echo "  ✓ Hook APT automatici pre/post upgrade"
echo "  ✓ Fix google-chrome files list"
echo ""
echo "Comandi disponibili:"
echo "  • Setup completo:    /usr/local/sbin/fix-systemd-freebsd.sh"
echo "  • Pre-upgrade:       /usr/local/sbin/fix-systemd-freebsd.sh --pre-upgrade"
echo "  • Post-upgrade:      /usr/local/sbin/fix-systemd-freebsd.sh --post-upgrade"
echo "  • Ripristina orig:   /usr/local/sbin/fix-systemd-freebsd.sh --restore"
echo ""
echo "Ora puoi eseguire tranquillamente:"
echo "  ${GREEN}apt update && apt upgrade${NC}"
echo ""
 
Back
Top