Thursday, March 6, 2025

Is there an equivelent Windows SteadyState for linux


 It's important to clarify that "Windows SteadyState" was a Microsoft tool that allowed administrators to revert a Windows system to a previous state after a reboot. Its primary use was in public computing environments like libraries and schools.

While there isn't a single, direct, 1:1 equivalent in Linux, Linux offers a variety of tools and methods that achieve similar results. Here's a breakdown of relevant concepts and approaches:

Key Linux Capabilities:

  • Snapshots and Virtualization:
    • Linux file systems like Btrfs and ZFS have built-in snapshot capabilities. This allows you to create point-in-time copies of your system, which can be easily restored.
    • Virtualization software (like VirtualBox or KVM) allows you to run a Linux system within a virtual machine. You can then take snapshots of the virtual machine and revert to them as needed. This is a very robust way to achieve a "SteadyState" effect.
  • Overlay File Systems:
    • Overlay file systems (like OverlayFS) allow you to layer a read-write file system on top of a read-only one. This means that changes are written to the read-write layer, and the original read-only layer remains untouched. A reboot can then discard the read-write layer, effectively restoring the system.
  • Configuration Management Tools:
    • Tools like Ansible, Puppet, and Chef can be used to automate system configuration. This ensures that systems are always in a consistent state. While not a direct "revert" mechanism, they provide a strong way to maintain a desired system configuration.
  • Read-Only System Partitions:
    • It is possible to configure linux systems so that the main system partition is mounted as read only. Then a seperate partition can be used for user data. This would mean that any changes to the system partition would be lost upon reboot.

In summary:

Linux provides a range of flexible tools and techniques that can replicate the functionality of Windows SteadyState. The specific approach will depend on your needs and technical expertise.

I hope this information is helpful.

How can i securely delete on an ssd in linux?


Securely deleting data on an SSD in Linux requires a different approach than with traditional hard drives due to the way SSDs store and manage data. Here's a breakdown of the key methods and considerations:

Understanding SSDs and Secure Deletion

  • Wear Leveling:
    • SSDs use wear leveling to distribute write cycles evenly across memory cells, extending their lifespan. This means that data isn't always written to the same physical location.  
    • This makes traditional overwriting methods (like shred) unreliable for secure deletion on SSDs.
  • Over-Provisioning:
    • SSDs often have extra hidden space (over-provisioning) that the operating system can't access. This space might contain remnants of old data.

Recommended Methods

  1. ATA Secure Erase:
    • This is the most reliable method for securely wiping an SSD.
    • It's a command built into the SSD's firmware that clears all data.  
    • Tools like hdparm can be used to issue the Secure Erase command.
    • Important considerations:
      • "Frozen" State: SSDs can sometimes be in a "frozen" security state, preventing Secure Erase. You may need to suspend and resume your computer or use BIOS settings to unfreeze it.
      • Backups: This process erases all data on the drive, so back up anything important.
      • Direct SATA/NVMe Connection: For the most reliable results, connect the SSD directly to a SATA or NVMe port. Avoid using USB adapters.
    • Using hdparm:
      • Install hdparm: sudo apt install hdparm (on Debian/Ubuntu-based systems).
      • Identify your SSD: sudo fdisk -l.
      • Check if Secure Erase is supported: sudo hdparm -I /dev/sdX (replace /dev/sdX with your SSD's device name). Look for "SECURITY ERASE UNIT" in the output.
      • If the drive is frozen, attempt to unfreeze it.
      • Set a temporary password: sudo hdparm --user-master u --security-set-pass mypassword /dev/sdX.
      • Perform the Secure Erase: sudo hdparm --user-master u --security-erase mypassword /dev/sdX.
      • or for a enhanced secure erase use: sudo hdparm --user-master u --security-erase-enhanced mypassword /dev/sdX
      • Afterwards, it is good practice to check that the security is disabled again, using the first hdparm command.
  2. NVMe Format/Sanitize:
    • For NVMe SSDs, the nvme-cli tool provides commands for formatting and sanitizing the drive.
    • nvme format /dev/nvme0n1
    • nvme sanitize /dev/nvme0n1
    • These commands offer secure erasure options.
  3. Full Disk Encryption:
    • If you're concerned about data security, using full disk encryption (like LUKS) is highly recommended.
    • If you need to dispose of the drive, simply deleting the encryption keys renders the data unreadable. This is a very quick and effective method.

Important Notes:

  • Avoid shred: The shred command is not effective on SSDs.
  • File Deletion vs. Drive Wiping: If you only need to delete specific files, full disk encryption is the best approach. Wiping the entire drive is necessary when disposing of the SSD.
  • Firmware Updates: Sometimes, SSD firmware updates can improve secure erase functionality.

By using ATA Secure Erase or NVMe format/sanitize, you can effectively and securely delete data from your SSD in Linux.

Wednesday, December 25, 2024

Does it help or hurt for subs out of phase?


 https://www.youtube.com/watch?v=2veYdDtfJPM

This video is about how to improve the sound of your home theater system. The speaker, Paul McGowan, discusses how to run subwoofers out of phase with the mains. He says that this can help to reduce bass cancellations and standing waves in small rooms. He also recommends using a nearfield subwoofer setup, which can help to improve bass response in problematic rooms. Finally, he suggests looking for his new book, "The Audiophile's Guide to Subwoofers," which will be available in December.


Tuesday, December 24, 2024

Jetbrain's AI Assistant as a helper in PyCharm


 I was recently writing a project in PyCharm that downloaded large video files. I wanted to have a typical progress meter as the download progressed.

I asked this question to the AI Assistant "calculate time left based on start time, current time, total size and current size".

This is the response that it generated.

To calculate the time left for a download based on the start time, current time, total size, and the current size of the file downloaded, you can use the following approach:

Use the Formula

  1. Determine the elapsed time:

    • Elapsed time can be calculated by subtracting the start_time from the current_time.
  2. Calculate the download speed:

  3. Calculate the remaining size:

  4. Estimate the time left:

Here is a Python code snippet implementing this logic:

import time



def calculate_time_left(start_time, current_time, total_size, current_size):

    # Elapsed time in seconds

    elapsed_time = current_time - start_time


    # Avoid division by zero

    if elapsed_time == 0:

        return "Calculating..."


    # Download speed in size per second

    download_speed = current_size / elapsed_time


    # Remaining size

    remaining_size = total_size - current_size


    # Estimate time left in seconds

    if download_speed > 0:

        time_left = remaining_size / download_speed

    else:

        return "Speed is too slow to calculate time left"


    # Return time left in a human-readable format

    minutes, seconds = divmod(time_left, 60)

    return f"{int(minutes)} minutes {int(seconds)} seconds left"


Saturday, August 12, 2023

Follow me on mastodon


Follow me on mastodon 

FLET: A python GUI based on Flutter


I am always on the lookout for new (easier) ways to create GUIs for python. Recently I ran across the FLET. Also available on github.

Their description is

The fastest way to build Flutter apps in Python

Flet enables developers to easily build realtime web, mobile and desktop apps in Python. No frontend experience required.

As an experiment I decided to create a simple login form.

import flet as ft

def main(page: ft.Page):
page.title = "Login"
page.window_height = 200
page.window_width = 500
page.window_always_on_top = True

def cancel_click(e):
page.window_destroy()

def login_click(e):
if txt_user.value == "admin" and txt_pwd.value == "admin":
dlg.content = ft.Text("Login Successful")
else:
dlg.content = ft.Text("Login failed")
dlg.modal = False
dlg.open = True
dlg.update()
page.update()

dlg = ft.AlertDialog(title=ft.Text("Login"), content=ft.Text("---"))
txt_user = ft.TextField(value = "", label="User ID")
txt_pwd = ft.TextField(value = "", password=True, can_reveal_password=True,
label="Password")
btn_cancel = ft.FilledButton(text="Cancel", on_click=cancel_click)
btn_login = ft.FilledButton(text="Login", on_click=login_click)
action_row = ft.Row(controls=[btn_cancel, btn_login])
page.add(txt_user, txt_pwd, action_row, dlg)
page.window_center()

ft.app(target=main)

  This results in the following window


A jupyter notebook is here.