Outils pour utilisateurs

Outils du site


article:gestion_energie

Ceci est une ancienne révision du document !


<html lang=“fr”> <head>

  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Désactiver la Veille au Fermeture du Couvercle - Debian</title>
  <style>
      * { margin: 0; padding: 0; box-sizing: border-box; }
      body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; line-height: 1.6; color: #333; max-width: 1200px; margin: 0 auto; padding: 20px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
      .container { background: white; border-radius: 10px; padding: 30px; box-shadow: 0 10px 40px rgba(0,0,0,0.2); }
      h1 { color: #667eea; border-bottom: 3px solid #667eea; padding-bottom: 10px; margin-bottom: 20px; }
      h2 { color: #764ba2; margin-top: 25px; margin-bottom: 15px; border-left: 4px solid #764ba2; padding-left: 10px; }
      h3 { color: #555; margin-top: 20px; margin-bottom: 10px; font-weight: 600; }
      code { background: #f4f4f4; padding: 2px 6px; border-radius: 3px; font-family: 'Courier New', monospace; color: #d63384; }
      pre { background: #1e1e1e; color: #d4d4d4; padding: 15px; border-radius: 5px; overflow-x: auto; margin: 10px 0; font-size: 0.95em; }
      pre code { background: none; padding: 0; color: inherit; }
      ul, ol { margin-left: 25px; margin-bottom: 15px; }
      li { margin-bottom: 5px; }
      table { width: 100%; border-collapse: collapse; margin: 15px 0; font-size: 0.95em; }
      th, td { border: 1px solid #ddd; padding: 12px; text-align: left; }
      th { background: #667eea; color: white; }
      tr:nth-child(even) { background: #f9f9f9; }
      .warning { background: #fff3cd; border-left: 4px solid #ffc107; padding: 15px; margin: 15px 0; }
      .success { background: #d4edda; border-left: 4px solid #28a745; padding: 15px; margin: 15px 0; }
      .note { background: #e7f3ff; border-left: 4px solid #007bff; padding: 15px; margin: 15px 0; }
      .error { background: #f8d7da; border-left: 4px solid #dc3545; padding: 15px; margin: 15px 0; }
      .footer { margin-top: 30px; padding-top: 20px; border-top: 2px solid #eee; font-size: 0.9em; color: #666; text-align: center; }
      a { color: #667eea; text-decoration: none; }
      a:hover { text-decoration: underline; }
      .step { background: #f8f9fa; border-left: 4px solid #667eea; padding: 15px; margin: 15px 0; }
      .step-number { display: inline-block; width: 30px; height: 30px; background: #667eea; color: white; text-align: center; border-radius: 50%; line-height: 30px; margin-right: 10px; font-weight: bold; }
      .badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 0.8em; font-weight: bold; color: white; }
      .bg-green { background-color: #28a745; }
      .bg-red { background-color: #dc3545; }
      .bg-blue { background-color: #007bff; }
      .comparison { display: flex; gap: 20px; margin: 15px 0; }
      .comparison-item { flex: 1; padding: 15px; border-radius: 5px; }
      .before { background: #fff3cd; border: 2px solid #ffc107; }
      .after { background: #d4edda; border: 2px solid #28a745; }
  </style>

</head> <body>

  <div class="container">
      <h1>🔌 Désactiver la Veille au Fermeture du Couvercle sur Debian</h1>
      <div class="note">
          <strong>Contexte :</strong> Sur un ordinateur portable utilisé comme serveur de virtualisation, la fermeture du couvercle déclenche par défaut une mise en veille. Cela interrompt les VM et coupe la connexion SSH. Ce guide explique comment désactiver ce comportement.
      </div>
      <h2>1. Problématique</h2>
      <div class="error">
          <strong>⚠️ Comportement par défaut :</strong> Lorsque le couvercle est fermé, <code>systemd-logind</code> lance une suspension (veille) du système.
      </div>
      <h3>Conséquences indésirables :</h3>
      <ul>
          <li>❌ Les machines virtuelles (KVM/QEMU) sont suspendues ou arrêtées</li>
          <li>❌ La connexion WiFi est coupée</li>
          <li>❌ La session SSH est interrompue</li>
          <li>❌ Impossible de se reconnecter à distance sans intervention physique</li>
      </ul>
      <h3>Logs typiques du problème :</h3>
      <pre><code>mai 22 08:03:03 tijlf systemd-logind[655]: Lid closed.

mai 22 08:03:03 tijlf systemd-logind[655]: Suspending… mai 22 08:03:03 tijlf systemd[1]: Reached target sleep.target - Sleep. mai 22 08:03:03 tijlf systemd[1]: Starting systemd-suspend.service - System Suspend…</code></pre>

      <h2>2. Solution : Modifier <code>logind.conf</code></h2>
      <p>Le fichier <code>/etc/systemd/logind.conf</code> contrôle le comportement de l'alimentation et des événements matériels (couvercle, bouton power, etc.).</p>
      <div class="step">
          <span class="step-number">1</span>
          <strong>Éditer le fichier de configuration</strong>
          <pre><code>sudo nano /etc/systemd/logind.conf</code></pre>
      </div>
      <div class="step">
          <span class="step-number">2</span>
          <strong>Modifier les paramètres du couvercle</strong>
          <p>Recherchez les lignes <code>HandleLidSwitch</code> et modifiez-les comme suit :</p>
          <div class="comparison">
              <div class="comparison-item before">
                  <strong>❌ Avant (Problématique)</strong>
                  <pre><code>HandleLidSwitch=suspend

HandleLidSwitchExternalPower=suspend HandleLidSwitchDocked=ignore</code></pre>

              </div>
              <div class="comparison-item after">
                  <strong>✅ Après (Solution)</strong>
                  <pre><code>HandleLidSwitch=ignore

HandleLidSwitchExternalPower=ignore HandleLidSwitchDocked=ignore</code></pre>

              </div>
          </div>
      </div>
      <div class="step">
          <span class="step-number">3</span>
          <strong>Sauvegarder et quitter</strong>
          <ul>
              <li><code>Ctrl + O</code> → <code>Entrée</code> (sauvegarde)</li>
              <li><code>Ctrl + X</code> (quitter)</li>
          </ul>
      </div>
      <div class="step">
          <span class="step-number">4</span>
          <strong>Redémarrer le service <code>systemd-logind</code></strong>
          <pre><code>sudo systemctl restart systemd-logind</code></pre>
          <div class="warning">
              ⚠️ <strong>Attention :</strong> Cela va déconnecter votre session SSH actuelle. Le serveur restera allumé, mais vous devrez patienter 10-15 secondes pour vous reconnecter.
          </div>
      </div>
      <h2>3. Explication des Paramètres</h2>
      <table>
          <tr><th>Paramètre</th><th>Valeur</th><th>Comportement</th></tr>
          <tr><td><code>HandleLidSwitch</code></td><td><code>ignore</code></td><td>Ignorer la fermeture du couvercle (batterie ou secteur)</td></tr>
          <tr><td><code>HandleLidSwitchExternalPower</code></td><td><code>ignore</code></td><td>Ignorer même si branché sur secteur</td></tr>
          <tr><td><code>HandleLidSwitchDocked</code></td><td><code>ignore</code></td><td>Ignorer quand le PC est docké</td></tr>
      </table>
      <h3>Autres valeurs possibles :</h3>
      <ul>
          <li><code>suspend</code> : Mettre en veille (comportement par défaut)</li>
          <li><code>hibernate</code> : Hiberner (sauvegarde sur disque)</li>
          <li><code>lock</code> : Verrouiller l'écran (sans veille)</li>
          <li><code>poweroff</code> : Éteindre le système</li>
          <li><code>ignore</code> : Ne rien faire (recommandé pour serveur)</li>
      </ul>
      <h2>4. Vérification</h2>
      <h3>4.1 Confirmer la configuration</h3>
      <pre><code>grep HandleLidSwitch /etc/systemd/logind.conf</code></pre>
      <p>Résultat attendu :</p>
      <pre><code>HandleLidSwitch=ignore

HandleLidSwitchExternalPower=ignore HandleLidSwitchDocked=ignore</code></pre>

      <h3>4.2 Tester la fermeture du couvercle</h3>
      <ol>
          <li>Connectez-vous en SSH sur le serveur</li>
          <li>Ouvrez un second terminal et lancez :</li>
          <pre><code>journalctl -f</code></pre>
          <li>Fermez le couvercle du portable</li>
          <li>Vérifiez les logs :</li>
      </ol>
      <div class="success">
          ✅ <strong>Succès :</strong> Vous verrez <code>Lid closed.</code> suivi de <strong>rien d'autre</strong> (pas de <code>Suspending...</code>)
      </div>
      <div class="error">
          ❌ <strong>Échec :</strong> Vous voyez <code>Suspending...</code> → Retournez à l'étape 2
      </div>
      <h3>4.3 Vérifier que les VM tournent toujours</h3>
      <pre><code>virsh list --all

# Ou systemctl status libvirtd</code></pre>

      <h3>4.4 Vérifier la connexion réseau</h3>
      <pre><code>ping -c 3 8.8.8.8

ip addr show wlp3s0b1</code></pre>

      <h2>5. Dépannage</h2>
      <h3>5.1 Le service ne démarre pas</h3>
      <pre><code># Vérifier l'état

sudo systemctl status systemd-logind

# Voir les erreurs sudo journalctl -u systemd-logind -b</code></pre>

      <h3>5.2 Une autre configuration interfère</h3>
      <p>Si vous utilisez <code>tlp</code> (gestion de batterie), vérifiez sa configuration :</p>
      <pre><code>sudo nano /etc/tlp.conf

# Cherchez : LID_CLOSE_SUSPEND # Doit être : LID_CLOSE_SUSPEND=0 ou commenté</code></pre>

      <h3>5.3 Vérifier les drop-ins</h3>
      <p>Des configurations personnalisées peuvent exister dans :</p>
      <pre><code>ls /etc/systemd/logind.conf.d/

# Vérifiez qu'aucun fichier ne redéfinit HandleLidSwitch</code></pre>

      <h2>6. Logs de Référence</h2>
      <h3>❌ Logs avant correction (problème) :</h3>
      <pre><code>mai 22 08:03:03 tijlf systemd-logind[655]: Lid closed.

mai 22 08:03:03 tijlf systemd-logind[655]: Suspending… mai 22 08:03:03 tijlf systemd[1]: Reached target sleep.target - Sleep. mai 22 08:03:16 tijlf wlp3s0b1: deauthenticating from … by local choice mai 22 08:03:16 tijlf dhcpcd[780]: wlp3s0b1: carrier lost</code></pre>

      <h3>✅ Logs après correction (solution) :</h3>
      <pre><code>mai 22 09:15:00 tijlf systemd-logind[655]: Lid closed.

# Aucun message de suspension suivant # Le système continue de fonctionner normalement</code></pre>

      <h2>7. Résumé des Commandes</h2>
      <table>
          <tr><th>Action</th><th>Commande</th></tr>
          <tr><td>Éditer la config</td><td><code>sudo nano /etc/systemd/logind.conf</code></td></tr>
          <tr><td>Appliquer les changements</td><td><code>sudo systemctl restart systemd-logind</code></td></tr>
          <tr><td>Vérifier la config</td><td><code>grep HandleLidSwitch /etc/systemd/logind.conf</code></td></tr>
          <tr><td>Surveiller les logs</td><td><code>journalctl -f</code></td></tr>
          <tr><td>Vérifier les VM</td><td><code>virsh list --all</code></td></tr>
          <tr><td>Vérifier le réseau</td><td><code>ip addr show wlp3s0b1</code></td></tr>
      </table>
      <div class="note">
          <strong>💡 Conseil :</strong> Cette configuration est idéale pour les serveurs sans interface graphique. Le portable se comporte alors comme une tour de bureau, restant allumé 24h/24 même avec le couvercle fermé.
      </div>
      <div class="footer">
      </div>
  </div>

</body> </html>

article/gestion_energie.1780652222.txt.gz · Dernière modification : de estro

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki