Skip to content

Miscellaneous

A collection of system configurations, tweaks and quick fixes for Linux environments.


Laptop optimization

This ensures your laptop stays awake with the lid closed, maintains a stable network connection and boots quickly by ignoring unused network interfaces.

  1. Lid and sleep configuration

    These steps prevent the system from suspending or shutting down when the lid is closed or the power button is pressed.

    1. Open logind config

      Terminal window
      sudo nano /etc/systemd/logind.conf
    2. Update config

      Update the following lines to ignore to keep the system awake.

      /etc/systemd/logind.conf
      HandleSuspendKey=ignore
      HandleLidSwitch=ignore
      HandleLidSwitchDocked=ignore
    3. Restart logind

      Terminal window
      sudo systemctl restart systemd-logind
  2. Disable system-wide sleep

    To prevent the kernel from attempting to sleep even if triggered by software, create a “no-sleep” override.

    1. Create nosuspend config

      Terminal window
      sudo mkdir -p /etc/systemd/sleep.conf.d/ && sudo nano /etc/systemd/sleep.conf.d/nosuspend.conf
    2. Add config

      /etc/systemd/sleep.conf.d/nosuspend.conf
      [Sleep]
      AllowSuspend=no
      AllowHibernation=no
      AllowSuspendThenHibernate=no
      AllowHybridSleep=no
    3. Reload daemon

      Terminal window
      sudo systemctl daemon-reload

Configure ethernet and Wi-Fi

This process configures your server to use Netplan and systemd-resolved to manage both ethernet and Wi-Fi connections through a single, unified configuration file.

  1. Install network driver (if applicable)

    Terminal window
    lspci -nnk | grep -iA 3 net

    If the network controller says “Broadcom” and “BCM43xx”, install the drivers below; otherwise, skip to step 2.

    Terminal window
    sudo apt update && sudo apt install linux-headers-$(uname -r) -y && sudo apt install bcmwl-kernel-source -y

    For changes to take effect, reboot the system.

    Terminal window
    sudo reboot

    Verify the driver is active by running ip link. A wireless interface, typically wlan0, should now appear in the list.

  2. Install and enable wpa_supplicant

    Terminal window
    sudo apt install wpasupplicant -y && sudo systemctl enable --now wpa_supplicant
  3. Terminal window
    sudo ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
  4. Open Netplan config

    Terminal window
    sudo nano /etc/netplan/50-cloud-init.yaml
  5. Update config

    • Replace enp3s0 with your ethernet ID from ip link.
    • Replace wlan0 with your Wi-Fi ID from ip link.
    • Replace Your_SSID_Name and Your_Password under access-points.
    /etc/netplan/50-cloud-init.yaml
    network:
    version: 2
    renderer: networkd
    ethernets:
    enp3s0:
    dhcp4: true
    optional: true
    dhcp4-overrides:
    route-metric: 100
    wifis:
    wlan0:
    dhcp4: true
    optional: true
    dhcp4-overrides:
    route-metric: 600
    access-points:
    "Your_SSID_Name":
    password: "Your_Password"
  6. Apply the config

    Terminal window
    sudo netplan apply
  7. Restart systemd-resolved

    Terminal window
    sudo systemctl restart systemd-resolved

Expand storage to full capacity

This process extends the logical volume and resizes the filesystem to utilize all remaining unallocated space on your primary hard drive.

  1. Extend the logical volume

    Terminal window
    sudo lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
  2. Resize the filesystem

    Terminal window
    sudo resize2fs /dev/ubuntu-vg/ubuntu-lv
  3. Verify

    Terminal window
    df -h /

Wake-on-LAN (WOL)

If your computer supports Wake-on-LAN, you can send a “magic packet” to wake it from a powered-down state. This is primarily supported on Ethernet connections.

  1. Identify network interface

    Find the name of your Ethernet adapter. Look for names starting with e (e.g., eth0 or enp3s0).

    Terminal window
    ip link show
  2. Install ethtool

    Install the utility required to manage network hardware settings.

    Terminal window
    sudo apt update && sudo apt install ethtool -y
  3. Check support

    Verify if your hardware supports the magic packet. Look for g in the “Supports Wake-on” line.

    Terminal window
    sudo ethtool $INTERFACE_NAME
  4. Enable WOL (temporary)

    Enable WOL manually to test the configuration. This setting will reset after a reboot.

    Terminal window
    sudo ethtool -s $INTERFACE_NAME wol g
  5. Persist with systemd

    Create a service to ensure WOL is re-enabled automatically on every boot.

    /etc/systemd/system/wol.service
    [Unit]
    Description=Enable Wake On Lan
    [Service]
    Type=oneshot
    ExecStart=/usr/sbin/ethtool -s $INTERFACE_NAME wol g
    [Install]
    WantedBy=basic.target
  6. Enable the service

    Reload systemd and enable the new service.

    Terminal window
    sudo systemctl daemon-reload && sudo systemctl enable wol.service
  7. Send Wake-up packet

    From another device on the network, trigger the boot sequence using the target’s MAC address.

    Terminal window
    wakeonlan $MAC_ADDRESS