{"id":5229,"date":"2026-08-30T11:20:34","date_gmt":"2026-08-30T02:20:34","guid":{"rendered":"https:\/\/donguri3.net\/server-tech\/ubuntu24-suspend-wifi-fix-surfacepro5-2\/"},"modified":"2026-08-30T11:20:35","modified_gmt":"2026-08-30T02:20:35","slug":"ubuntu24-suspend-wifi-fix-surfacepro5","status":"publish","type":"post","link":"https:\/\/donguri3.net\/en\/server-tech\/linux-server-network\/ubuntu24-suspend-wifi-fix-surfacepro5\/","title":{"rendered":"Ubuntu 24.04: Workaround for Wi-Fi Disconnecting When Closing the Laptop Lid"},"content":{"rendered":"<p>Although the Surface Pro 5 (CPU: Core i7-7660U) is still powerful enough for daily use, it is restricted by not being officially supported by Windows 11.<br \/>\nWhile there are ways to forcefully install Windows 11, it carries risks regarding drivers and security, so this time I decided to take the plunge and install Ubuntu 24.04 LTS.<\/p>\n<p>As a result, Ubuntu runs snappily and is ideal for development purposes.<br \/>\nHowever, there was one catch\u2014<br \/>\nClosing the Type Cover automatically puts it to sleep, which disconnects the Wi-Fi.<\/p>\n<p>This is caused by the Surface-specific specification where the &#8220;Type Cover = lid,&#8221; but actually, this behavior is a common phenomenon on other laptops as well.<\/p>\n<h2>Objective: Maintain Communication Even with the Lid Closed<\/h2>\n<ul>\n<li>Prevent the device from sleeping when closing the Type Cover or lid<\/li>\n<li>Maintain Wi-Fi connectivity to prevent SSH and VPN connections from dropping<\/li>\n<li>Ensure stable communication by adding a USB wired LAN adapter if necessary<\/li>\n<\/ul>\n<h2>Goal: Turn the Surface Pro 5 into a &#8220;Use-While-Closed Laptop&#8221; with Ubuntu<\/h2>\n<ul>\n<li>Disable suspend so operations continue even when closed<\/li>\n<li>Eliminate waiting for Wi-Fi reconnection<\/li>\n<li>Enhance communication pathways using a USB wired LAN<\/li>\n<\/ul>\n<h2>Issue: Ubuntu&#8217;s Lid Event and Wi-Fi Power-Saving Behavior<\/h2>\n<p>Ubuntu detects &#8220;lid close&#8221; events via ACPI (Advanced Configuration and Power Interface), and <br \/>\nsystemd-logind automatically executes a suspend.<br \/>\nWhile this feature is convenient for mobile use, it is inconvenient when you want to use the device like a server.<\/p>\n<p>During sleep, the Wi-Fi device loses power, and re-recognition and reconnection processes occur upon wake-up, causing temporary communication drops.<br \/>\nThis can also cause SSH sessions and remote work to be forcibly disconnected.<\/p>\n<hr \/>\n<h2>Solution: Disable the Lid Switch via systemd-logind.conf Settings<\/h2>\n<h3>\u2460 Edit the configuration file<\/h3>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">sudo nano \/etc\/systemd\/logind.conf<\/pre>\n<h3>\u2461 Modify the following 3 lines<\/h3>\n<div>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">HandleLidSwitch=ignore\nHandleLidSwitchExternalPower=ignore\nHandleLidSwitchDocked=ignore<\/pre>\n<\/div>\n<p>This ensures that closing the lid will not trigger sleep mode, allowing operations to continue.<\/p>\n<h3>\u2462 Apply the settings<\/h3>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">sudo systemctl restart systemd-logind<\/pre>\n<p>With this state, even if you close the Type Cover, Ubuntu will not go to sleep and the Wi-Fi will be maintained.<br \/>\nThe Surface-specific &#8220;cover-linked suspend&#8221; issue is thus resolved.<\/p>\n<h3>\u2463 Verify Wi-Fi communication<\/h3>\n<p>Confirm that responses do not stop with the following command while the lid is closed:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">ping -c 5 8.8.8.8<\/pre>\n<p>If communication continues, it is a success.<\/p>\n<h3>\u2464 Configure USB Wired LAN (Netplan)<\/h3>\n<p>In environments with weak Wi-Fi, using a wired LAN adapter provides stability.<\/p>\n<p>Check the device name<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">ip link<\/pre>\n<p>Names starting with enx (e.g., enx00e04c123456) are USB wired LAN adapters.<\/p>\n<p>Add the configuration<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">sudo vim \/etc\/netplan\/01-netcfg.yaml<\/pre>\n<p>Content:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">network:\n  version: 2\n  renderer: networkd\n  ethernets:\n    enx00e04c123456:\n      dhcp4: true\n      optional: true<\/pre>\n<p>Fix permissions:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">sudo chmod 600 \/etc\/netplan\/01-netcfg.yaml<\/pre>\n<p>Apply:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">sudo netplan apply<\/pre>\n<p>Verify:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">ip addr show enx00e04c123456<\/pre>\n<p>If inet 192.168.x.x is displayed, the connection is complete.<\/p>\n<p>\u2465 Control Priority Between Wi-Fi and Wired LAN<\/p>\n<p>When using both simultaneously, set the priority using route-metric.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">ethernets:\n  enx00e04c123456:\n    dhcp4: true\n    dhcp4-overrides:\n      route-metric: 100\nwifis:\n  wlan0:\n    dhcp4: true\n    dhcp4-overrides:\n      route-metric: 200<\/pre>\n<p>Lower numbers indicate higher priority.<br \/>\nWith this setting, wired LAN is prioritized, and Wi-Fi can be operated as a backup.<\/p>\n<h2>Summary: Key Points for Reviving a Surface with Ubuntu<\/h2>\n<p>Item | Configuration File | Content<br \/>\nAction when lid is closed | \/etc\/systemd\/logind.conf | HandleLidSwitch=ignore<br \/>\nMaintain Wi-Fi | Netplan \/ wpa_supplicant | Prevent suspend<br \/>\nWired LAN setup | \/etc\/netplan\/01-netcfg.yaml | Auto-connect with dhcp4: true<br \/>\nPriority | route-metric | Use wired connection preferentially<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Although the Surface Pro 5 (CPU: Core i7-7660U) is still powerful enough for daily use, it is restricted by no [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":2226,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_locale":"en_US","_original_post":"https:\/\/donguri3.net\/?p=2223","footnotes":""},"categories":[1170],"tags":[24,291,10,310,251],"class_list":["post-5229","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux-server-network","tag-vpn","tag-yaml","tag-server","tag-310","tag-251","en-US"],"_links":{"self":[{"href":"https:\/\/donguri3.net\/wp-json\/wp\/v2\/posts\/5229","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/donguri3.net\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/donguri3.net\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/donguri3.net\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/donguri3.net\/wp-json\/wp\/v2\/comments?post=5229"}],"version-history":[{"count":1,"href":"https:\/\/donguri3.net\/wp-json\/wp\/v2\/posts\/5229\/revisions"}],"predecessor-version":[{"id":5232,"href":"https:\/\/donguri3.net\/wp-json\/wp\/v2\/posts\/5229\/revisions\/5232"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/donguri3.net\/wp-json\/wp\/v2\/media\/2226"}],"wp:attachment":[{"href":"https:\/\/donguri3.net\/wp-json\/wp\/v2\/media?parent=5229"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/donguri3.net\/wp-json\/wp\/v2\/categories?post=5229"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/donguri3.net\/wp-json\/wp\/v2\/tags?post=5229"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}