Skip to content
TheChatArchiveThe Chat Archive
gpt-4o-2024-08-06· OpenAIAi2 WildChat-4.8M (AI2)

nit] Description=VIRT0 chroot mount service After=local-fs.target [Service] Type=oneshot…

  1. User

    nit] Description=VIRT0 chroot mount service After=local-fs.target

    [Service] Type=oneshot ExecStart=/usr/bin/mount --bind /sys /opt/virt0/sys ExecStart=/usr/bin/mount --bind /proc /opt/virt0/proc ExecStart=/usr/bin/mount --bind /dev /opt/virt0/dev

    ExecStop=/usr/bin/umount /opt/virt0/sys ExecStop=/usr/bin/umount /opt/virt0/proc ExecStop=/usr/bin/umount /opt/virt0/dev

    RemainAfterExit=yes

    [Install] WantedBy=multi-user.target

    This service makes 5s delay when system boots. How to make this service not required by anyone else and remove waiting when boot?

  2. Assistant

    To prevent this service from causing a delay during the system boot process, you can modify the configuration to start the service in the background, allowing other boot tasks to continue without waiting for it to finish. Here's what you can do:

    1. Change the Service Type: Update the Type from oneshot to simple to allow the service to run in the background. When using simple, systemd will not wait for the service to complete before moving on to subsequent services.

    2. Add Background Execution: You can use shell commands to run the mounts in the background.

    3. Make Sure it is Not Required by Other Units: Ensure that no service lists this service as a dependency. This means removing it from any Requires= or Wants= directives in other unit files.

    Here's how you could modify the unit file to achieve this:

    [Unit]
    Description=VIRT0 chroot mount service
    After=local-fs.target
    
    [Service]
    Type=simple
    ExecStart=/bin/sh -c '/usr/bin/mount --bind /sys /opt/virt0/sys & \
                          /usr/bin/mount --bind /proc /opt/virt0/proc & \
                          /usr/bin/mount --bind /dev /opt/virt0/dev & wait'
    ExecStop=/bin/sh -c '/usr/bin/umount /opt/virt0/sys; /usr/bin/umount /opt/virt0/proc; /usr/bin/umount /opt/virt0/dev'
    
    RemainAfterExit=yes
    
    [Install]
    WantedBy=multi-user.target
    

    Additional Considerations:

    • Check Dependencies: Double-check any other service files for dependencies on this service. If you find any such dependencies, consider whether they are necessary or if you can adjust those services to avoid waiting for this chroot setup.

    • Review WantedBy: If you are sure that no other system unit or service requires this mount service to finish before starting, retaining WantedBy=multi-user.target should suffice. Otherwise, you might consider adding a custom target if necessary.

    • Testing: After making these changes, remember to reload the systemd configuration using sudo systemctl daemon-reload and then test the service and boot sequence to ensure it behaves as expected without delaying startup.