Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

d77orphaned Docs

This is the community documentation of d77orphaned: a Void Linux live system for recovery, diagnostics and careful forensics, with a small set of tools for authorized security testing. It boots from a USB stick or DVD, runs entirely from memory and the stick, and does not change the disks of the computer it runs on unless you ask it to.

The model is closer to Grml than to Kali: a toolbox for when a system will not boot, a disk is failing or you need to look at data without changing it.

Prototype. d77orphaned is a proof of concept. It has been tested in virtual machines (QEMU, BIOS and UEFI) and is being tried on real hardware; each page says what has and has not been verified.

Where to start

Not affiliated with Void Linux

d77orphaned is not affiliated with or endorsed by the Void Linux project or its maintainers. For general Void Linux topics, the Void Linux Handbook applies; these pages only cover what is different here.

What d77orphaned is

d77orphaned is a live ISO built on Void Linux (glibc, x86_64) with runit. You boot it, use it, and switch it off; nothing is installed. It is meant for:

  • Recovery: copying data off a failing disk, repairing partition tables and file systems, reinstalling the boot loader of a system that no longer boots, restoring backups.
  • Diagnostics: disk health (SMART, NVMe), hardware inventory, memory test, network checks.
  • Careful forensics: imaging disks and examining file systems without changing them.
  • Secure erasure: wiping disks before reuse or disposal, only when you ask (see Secure erasure and sanitization).
  • Authorized security testing: a few network tools (nmap, tcpdump, arp-scan, …), only for networks you are allowed to test.

The full list is in Tools in the image. When something has gone wrong, start with the Emergency procedures.

What it does not do on its own

d77orphaned is careful with the disks of the computer it runs on. Out of the box, it:

  • does not mount any disk;
  • does not assemble software RAID (MD) or activate LVM volumes;
  • does not unlock encrypted (LUKS) volumes;
  • does not use swap partitions it finds;
  • has no automounting (no udisks2, udiskie or gvfs);
  • runs no SSH server and listens on no network port.

All of this was checked in a virtual machine with test disks holding ext4 and XFS (with unfinished journals), NTFS, LUKS2, MD RAID 1, LVM and swap. The disks’ contents were identical, byte for byte, before and after booting and using a graphical session.

Reading a disk is still not the same as preserving evidence. See Working safely with disks before you mount anything.

Logging in

UserPasswordNotes
anonvoidlinuxthe live user; sudo without a password
rootvoidlinux

The passwords are the same on every copy of the ISO. Change them before connecting to a network you do not trust, and always before turning on SSH (see Network).

Nothing is kept, unless you ask

Everything you change while it runs lives in memory and is gone at the next boot. To keep files and settings on the USB stick, you can add an encrypted partition: see Persistence. Otherwise, saving work means copying it somewhere on purpose.

Source code

Every ISO comes with a SOURCES.txt file, next to it on the download page and inside the system at /usr/share/doc/d77orphaned/SOURCES.txt. It lists every package in the image, with its version and license, and says where to get its source:

  • Void Linux packages: https://sources.voidlinux.org/<package>-<version>/;
  • d77void packages: d77void/srcpkgs-d77 and each project’s own page.

The same file contains a written offer of the source code of every program in the image. Requests go to the d77orphaned issues on GitHub.

The image contains one package that is not free software in the strict sense: nmap, under the Nmap Public Source License (Void ships it in its “nonfree” repository).

What it is not

  • Not a d77void variant to install: there is no installer.
  • Not a replacement for Kali, Parrot or BlackArch: it has a short, chosen list of tools, not hundreds of offensive ones.
  • Not a forensic product with a chain-of-custody workflow. It gives you tools that do not write to disks unless told to; the procedure is yours.

Download

Prototype. d77orphaned is a proof of concept. It has been tested in virtual machines and on a few real computers. Do not rely on it as your only way to recover something that matters.

Files are in the ISO-x86_64 folder on SourceForge, next to the d77void ISOs. Each version has three files, named with its date:

FileWhat it is
d77orphaned-live-x86_64-<date>.isothe system (about 2 GB, x86_64)
d77orphaned-live-x86_64-<date>.iso.sha256the hash, to check the download
d77orphaned-live-x86_64-<date>.SOURCES.txtwhere to get the source of every package

Check the download

With the .iso and the .sha256 in the same folder:

sha256sum -c d77orphaned-live-x86_64-<date>.iso.sha256

It must say OK.

Write it to a USB stick

You need a stick of at least 4 GB. Everything on it is erased. Find its name first, by its size and model:

lsblk -d -o NAME,SIZE,MODEL,TRAN

Then, replacing /dev/sdX with the whole stick (not a partition such as /dev/sdX1):

sudo dd if=d77orphaned-live-x86_64-<date>.iso of=/dev/sdX bs=4M conv=fsync status=progress

Choosing the wrong device overwrites that disk, so check it twice. Then boot the computer from the stick, and see The boot menu.

If the system where you plug in the stick offers to unlock an encrypted partition, it is your own automounter seeing a persistence partition; you can cancel it.

The boot menu

The same entries appear on BIOS computers (isolinux menu) and on UEFI computers (GRUB menu). The default entry starts after a short timeout.

EntryWhat it doesWhen to use it
d77orphanedNormal boot: the pwm session starts on its ownmost of the time
(RAM)Copies the whole system into memory first (rd.live.ram)to remove the USB stick after booting; the system image is about 1.4 GB, so it needs more RAM than that (not verified on real hardware)
(graphics disabled)Boots with nomodeset: no graphics driver, basic VESA/framebuffer displaywhen the normal entry shows a black or garbled screen
(console only)Boots with d77.nogui: no graphical session at allfor text-only work, or when graphics do not work at all
(firmware tools)Normal boot, plus iomem=relaxed: lets flashrom reach the firmware chiponly to read or write firmware
Memtest86+Memory test, without starting Linuxto check RAM

The BIOS menu also has Boot first HD found by BIOS, Reboot and Power Off. The UEFI menu has UEFI Firmware Settings, System restart and System shutdown.

What every entry has in common

Every Linux entry passes these options to the kernel:

rd.luks=0 rd.md=0 rd.dm=0 rd.lvm=0

They stop the early boot stage from unlocking LUKS, assembling RAID or activating LVM and device-mapper volumes on the computer’s disks. After boot, d77orphaned also disables the rules that would do this later. See Working safely with disks.

Keyboard layout and language

The ISO boots with the us keyboard layout and en_US.UTF-8. To change them for one boot, edit the entry (Tab in the BIOS menu, e in GRUB) and change vconsole.keymap= and locale.LANG=, for example vconsole.keymap=pt-latin1.

In the graphical sessions, Kantele (the settings program for pwm and wasp) sets the keyboard layout. From an X11 terminal, setxkbmap pt also works for the current session.

Not verified yet: changing the layout from the boot menu. Kantele’s keyboard setting was tested on real hardware.

Sessions and logging in

d77orphaned has two optional graphical environments. The console (TTYs 1 to 6, Ctrl+Alt+F1 to F6) works with or without them, except with the graphics disabled entry (see below).

SessionDisplay systemWhat you get
pwmX11a tiling window manager with a status bar, the st terminal and dmenu
wasp + UtumnoWaylanda tiling compositor with the Utumno bar and launcher, the alacritty terminal and wmenu

Both come from the d77void project. Kantele, the settings program for pwm and wasp (keyboard, theme, shell, …), is installed for both. In both sessions there is sound (PipeWire), the battery level (UPower), Mullvad Browser, and this documentation: run d77-docs (it works offline).

pwm

  • The wallpaper follows the pwm theme; changing the theme in Kantele changes the wallpaper too.
  • A panel at the bottom left (conky) shows the kernel, CPU, memory, network address, disks and pwm’s main keys.
  • super+return terminal, super+d dmenu, super+q close a window, super+x log out or power off, super+1…9 workspaces.
  • The screen locks after 5 minutes without use, or with super+t. Unlock with the live user’s password, voidlinux.
  • On laptops, tapping the touchpad clicks.

wasp + Utumno

  • super+y opens Utumno’s wallpaper picker; the images are in ~/Wallpaper. super+space opens the launcher.
  • Utumno’s bar shows the network (NetworkManager), sound and battery.

What happens at boot

  1. With the normal entry, pwm starts on its own as the user anon. pwm is the default because X11 works on the widest range of hardware.
  2. When you leave pwm, the login screen (greeter) appears on the same screen (TTY 7). Type anon and voidlinux, then choose the session: pwm or wasp.
  3. From then on, each time you leave a session you return to the greeter.

The automatic login happens only once per boot.

Without a graphics driver (nomodeset)

With the graphics disabled entry, there is no graphics driver. X runs on the basic VESA or framebuffer display. In this mode:

  • pwm starts on its own. Leaving pwm starts it again, rather than ending the session. To finish, use shutdown or reboot in the menu (super+x).
  • Ctrl+Alt+F1…F6 do nothing. On some computers, switching the display mode back from VESA leaves a black screen that only the power button gets out of (seen on a Toshiba with Intel HD 4000 and legacy BIOS). Open a terminal in pwm (super+return), or boot the console only entry to work on the text console.
  • Avoid suspend from the menu in this mode: it is not verified, and it also has to switch display modes.
  • wasp is not available.
  • If pwm keeps failing at once, the session ends and a text login appears on computers that can show it.

Console only (d77.nogui)

With the console only entry, no graphical session starts. Log in on any TTY. The greeter service (greetd) is stopped; sudo sv up greetd starts it if you change your mind.

Without a GPU

wasp normally needs a GPU. d77orphaned allows it to fall back to software rendering (WLR_RENDERER_ALLOW_SOFTWARE=1, set in /etc/profile.d/d77orphaned-wlr.sh), so it also starts in virtual machines. It is slower, and you may see leftovers of the greeter in the background.

Both sessions have been tested on real hardware, with a GPU.

Persistence

By default d77orphaned keeps nothing: every boot starts clean. If you want to keep files and settings on the USB stick, d77-persist adds an encrypted partition to it. This is optional; without it, the system works exactly the same.

d77-persist create            # once: add the encrypted partition to the stick
d77-persist open              # unlock: your files, and your settings come back
d77-persist open --data-only  # unlock: your files only
d77-persist status            # what is there, and what is open
d77-persist close             # lock it; do this before removing the stick

The commands ask for sudo by themselves, which needs no password on the live system.

What is kept

  • Your files, in /mnt/d77-data.
  • Settings, unless you use --data-only:
WhatWhere it lives
Saved Wi-Fi networks/etc/NetworkManager/system-connections
pwm, including the theme set in Kantele~/.config/pwm
wasp, including the theme and keyboard set in Kantele~/.config/wasp
Kantele~/.config/kantele
Utumno’s theme and wallpaper~/.config/d77, ~/.cache/d77, ~/.cache/quickshell/wallpaper
SSH keys~/.ssh

The first open copies what the session has at that moment; from then on, changes in those folders are saved on the stick while it is open.

pwm picks up its settings at once. wasp and Utumno read theirs when they start, so log out and back in for those to apply.

What is not kept

The system itself: packages installed with xbps-install, and anything else outside the list above, are gone at the next boot, as always. This is on purpose: the system you boot is always the one in the ISO. The browser’s profile is not kept either; Mullvad Browser is designed to forget.

Creating it

d77-persist create works only on the device the system booted from, and never on the computer’s disks. It shows that device, and writes only after you type its name. The existing partitions are not changed, and the new one takes all the free space after them (at least 256 MiB are needed).

The encryption (LUKS2) is not optional. The passphrase cannot be recovered: without it, the data is lost.

Writing a new ISO erases it

Writing a new ISO to the stick replaces the partition table, so the persistence partition and its data are lost. Copy your files elsewhere first. Persistence is not a backup: keep copies of anything important.

Removing the stick without closing

Run d77-persist close before removing the stick or switching off. If the power goes first, what was already saved survives, but files written in the last moments can be lost, even if they were listed just before: Linux keeps writes in memory for a while. After saving something important, run sync.

Checked with a power cut in a virtual machine (a file saved with sync survived, one without it did not, and the file system was fine), and with a forced power-off on real hardware (nothing that was already there was lost).

Safety

  • Nothing happens at boot: the partition stays locked and unmounted until you run d77-persist open, and the system boots the same with or without it.
  • A passphrase is never stored, and nothing is unlocked automatically.
  • Other disks are not involved, even if one of them has a partition with the same name.

Verified in a virtual machine with a simulated USB stick: creating, closing, wrong passphrase, reopening after a reboot, and booting with BIOS and UEFI with the new partition table; another disk’s hash did not change.

Not verified yet on every firmware. If a machine stops booting the stick after create, write the ISO again (this erases the persistence).

Working safely with disks

d77orphaned does not touch the computer’s disks by itself (see What d77orphaned is). This page is about not touching them by accident once you start working.

In the commands below, replace /dev/sdX (whole disk) and /dev/sdX1 (partition) with your devices. lsblk -f lists disks, partitions and file systems without changing anything.

“Read-only” is not one thing

Mounting a file system with -o ro is not enough to leave a disk untouched:

  • ext4 and XFS replay their journal even when mounted read-only, if it was not closed cleanly. That writes to the disk.
  • LVM, RAID and LUKS have metadata that some commands update.
  • Your own commands (fsck, testdisk, a wrong dd) can write anywhere.

Two habits cover most of this:

  1. Mark the block devices read-only in the kernel before anything else.
  2. Whenever you can, work on an image of the disk instead of the disk.

1. Mark the devices read-only

sudo blockdev --setro /dev/sdX
sudo blockdev --setro /dev/sdX1      # each partition you will use, too
sudo blockdev --getro /dev/sdX1      # 1 = read-only

This flag lasts until the device is removed or the computer reboots.

2. Mount without replaying the journal

File systemCommand
ext4 (and ext3)sudo mount -o ro,noload /dev/sdX1 /mnt
XFSsudo mount -o ro,norecovery /dev/sdX1 /mnt
otherssudo mount -o ro /dev/sdX1 /mnt

Verified in a virtual machine: with blockdev --setro and these options, ext4 and XFS disks with unfinished journals were mounted. The journals stayed unfinished, and the disks’ SHA-256 hashes did not change.

3. Image the disk instead

For damaged disks, or anything that might become evidence, copy the disk first and work on the copy. Store the image on another disk that you mount read-write on purpose:

# failing or damaged disk: ddrescue keeps a map, so it can be resumed
sudo ddrescue -d /dev/sdX /mnt/target/disk.img /mnt/target/disk.map

# EWF (E01) image with case notes and built-in hashes
sudo ewfacquire /dev/sdX

# raw image with hashes computed while copying
sudo dcfldd if=/dev/sdX of=/mnt/target/disk.img hash=sha256 hashlog=/mnt/target/disk.sha256

losetup --read-only and the Sleuth Kit (mmls, fls, …) can then examine the image.

Encrypted (LUKS) volumes

Nothing is unlocked at boot. To open a volume read-only:

sudo cryptsetup open --readonly /dev/sdX2 evidence
sudo mount -o ro,noload /dev/mapper/evidence /mnt   # if it holds ext4
sudo umount /mnt && sudo cryptsetup close evidence

Verified in a virtual machine: the mapped device was read-only, writes to it failed, and the LUKS2 container’s hash did not change.

LVM

d77orphaned never activates LVM volumes on its own. To activate one volume group read-only:

sudo vgchange -ay --config 'activation { read_only_volume_list = [ "myvg" ] }' myvg
sudo lvs myvg                        # the attributes start with -R: read-only

Verified in a virtual machine: the logical volumes were active and read-only, writes failed, and the disk’s hash did not change.

Avoid these two commands, which look right but are not:

  • vgchange -ay --readonly activates nothing: --readonly stops the command from making any change, activation included.
  • lvchange -pr (--permission r) writes the new permission into the LVM metadata on the disk. Verified: the disk’s hash changed.

Software RAID (MD)

Arrays are never assembled on their own. To assemble one read-only:

sudo mdadm --assemble --readonly /dev/md0 /dev/sdX1 /dev/sdY1

Not verified yet in d77orphaned. Prefer imaging each member disk first.

Swap

Swap partitions found on the disks are not used. Do not run swapon on a disk you are examining: it writes to it.

Tools in the image

Each area has its own chapter, with a page per tool and its basic commands: Disks, Recovery, File systems and volumes, Forensics, Secure erasure and sanitization, Network, Hardware and boot, Console.

All tools are official Void Linux packages, except nmap (from Void’s nonfree repository) and, from the d77void repository, the graphical sessions, Kantele, Mullvad Browser and d77-slock. A virtual-machine test checks that every program in the image finds all its libraries.

AreaPackages
Disks and storage hardwaregparted util-linux parted gptfdisk smartmontools nvme-cli hdparm sdparm sg3_utils lsscsi f3
Recovery and backupsrestic borg ddrescue testdisk partclone fsarchiver extundelete gpart
File systemse2fsprogs xfsprogs xfsdump btrfs-progs dosfstools exfatprogs fuse-exfat ntfs-3g f2fs-tools jfsutils mtools
Volumes and encryptioncryptsetup lvm2 mdadm dislocker
Secure erasurenwipe parallel, and the firmware commands of hdparm, nvme-cli and sg3_utils
Forensicsdcfldd libewf afflib sleuthkit foremost xmount exiftool yara binwalk hexedit xxd
Boot and EFIgrub grub-x86_64-efi efibootmgr efivar os-prober kexec-tools
NetworkNetworkManager iproute2 iputils dhcpcd wpa_supplicant iw ethtool openssh curl wget lftp links rsync fuse-sshfs nfs-utils cifs-utils wireguard-tools openvpn
Network diagnosticstcpdump nmap traceroute mtr bind-utils testssl.sh ssh-audit whois ldns openbsd-netcat socat arp-scan iperf3 iftop nethogs net-tools ipcalc
Hardware and systemflashrom i2c-tools dmidecode pciutils usbutils hwinfo lshw inxi lm_sensors acpi memtester stress fio cpuid cpupower chntpw lynis
Consoletmux screen mc ranger vim nano less htop iotop sysstat ncdu tree lsof strace ltrace pv mbuffer psmisc moreutils bash-completion
Archiveszstd p7zip zip unzip lz4 lzop cabextract unp squashfs-tools
Othergnupg minicom tio chrony xtools-minimal man-db
Desktoppwm, wasp + Utumno, Kantele, mullvad-browser, feh, conky, zathura, PipeWire (sound), upower (battery), d77-slock

Memtest86+ is in the boot menu, not in the running system.

Some tools write to disks

Several of these tools exist to change disks: parted, gdisk, mkfs.*, fsck.*, testdisk (when you tell it to write), partclone and fsarchiver when restoring, chntpw, efibootmgr. They do what you ask, on the device you name. Check the device twice, and see Working safely with disks.

Security tools

The network tools are here for diagnostics and for testing networks you are authorized to test. Nothing in d77orphaned scans, captures or connects anywhere on its own.

Not included

Left out on purpose: automounting (udisks2, udiskie, gvfs) because it mounts disks by itself; fwupd, which requires udisks2; dmraid and bcache-tools because they activate volumes on their own at boot; ZFS (needs a compiler and a lot of space); Wireshark’s graphical interface (very large).

To install while running, with their sizes: rclone, tshark, termshark, john, clamav. See Install when you need them.

Disks

Tools to identify disks, read their health and look at their partition tables. Most of them only read; the pages say clearly when a command writes.

Start with lsblk to see what is there, then smartctl to see whether a disk is failing. Before anything else on a disk that matters, make it read-only with blockdev and read Working safely with disks.

ToolFor
lsblk and blkidwhich disks, partitions and file systems there are
smartctlhealth of SATA and NVMe drives
nvmeNVMe drive details and health
hdparmSATA drive identification, ATA password state, read speed
lsscsi and sg_inqdisks behind USB adapters and SAS controllers
blockdevthe kernel’s read-only flag, device sizes
losetupusing a disk image as a disk
parted, gdisk and sgdisk, fdiskpartition tables
gpartedpartitions, in a window
f3fake-capacity USB sticks and cards

The commands use /dev/sdX for a whole disk and /dev/sdX1 for a partition; NVMe drives are /dev/nvme0n1 and /dev/nvme0n1p1.

lsblk and blkid: list disks and file systems

Package: util-linux · Writes to disks: no

The first thing to run: which disks and partitions the computer has, how big they are, what is on them and whether anything is mounted.

lsblk                          # disks, partitions, sizes, mount points
lsblk -f                       # with file system type, label and UUID
lsblk -d -o NAME,SIZE,MODEL,SERIAL,TRAN   # one line per disk: model, serial, USB/SATA/NVMe
lsblk -S                       # SCSI/SATA/USB disks with vendor and model
sudo blkid                     # every file system and its UUID, label and type
sudo blkid /dev/sdX1           # one partition

lsblk reads what the kernel already knows; blkid reads the start of each partition to find its type. Neither changes anything.

Use the model, size and serial number (lsblk -d -o …) to be sure which disk is which before running anything that writes.

smartctl: disk health (SMART)

Package: smartmontools · Writes to disks: no (a self-test runs inside the drive and does not change data)

Reads the health data that SATA and NVMe drives keep about themselves: reallocated sectors, read errors, temperature, power-on hours.

sudo smartctl -H /dev/sdX            # overall verdict: PASSED or FAILED
sudo smartctl -a /dev/sdX            # everything: identity, attributes, error log, self-tests
sudo smartctl -x /dev/sdX            # even more (extended logs)
sudo smartctl -i /dev/nvme0          # identity: model, serial, firmware, capacity
sudo smartctl -t short /dev/sdX      # start a short self-test (about 2 minutes)
sudo smartctl -t long /dev/sdX       # start a long self-test (can take hours)
sudo smartctl -l selftest /dev/sdX   # results of the self-tests
sudo smartctl -X /dev/sdX            # abort a running self-test

What to look at in -a for a SATA disk: Reallocated_Sector_Ct, Current_Pending_Sector and Offline_Uncorrectable above zero mean the disk is losing sectors; copy the data off it first (see ddrescue). For NVMe, look at Media and Data Integrity Errors and Percentage Used.

USB enclosures sometimes hide SMART; -d sat (for example sudo smartctl -a -d sat /dev/sdX) often gets through.

nvme: NVMe drives

Package: nvme-cli · Writes to disks: only the commands marked below

sudo nvme list                   # NVMe drives: model, serial, size, firmware
sudo nvme smart-log /dev/nvme0   # health: temperature, wear, media errors
sudo nvme error-log /dev/nvme0   # the drive's error log
sudo nvme id-ctrl /dev/nvme0     # everything the controller reports about itself

Writes: nvme format and nvme sanitize erase the drive. Never on a disk you want to keep; to erase one on purpose, see NVMe sanitize and format.

smartctl also reads NVMe health.

hdparm: SATA drive information

Package: hdparm · Writes to disks: only some options (see below)

sudo hdparm -I /dev/sdX     # identification: model, serial, features, security state
sudo hdparm -t /dev/sdX     # time sequential reads from the disk (read-only)
sudo hdparm -T /dev/sdX     # time reads from the cache, for comparison
sudo hdparm -r /dev/sdX     # show the kernel's read-only flag (0 or 1)

hdparm -I shows whether the drive has an ATA password set (“Security: … enabled / locked”), which explains a disk that cannot be read.

Writes: many hdparm options change drive settings or data (for example the security and erase options). Use only the read options above unless you know exactly what an option does.

lsscsi and sg_inq: SCSI, SAS and USB disks

Packages: lsscsi, sg3_utils · Writes to disks: no (commands below)

lsscsi                  # SCSI/SATA/USB devices with vendor, model and /dev name
lsscsi -s               # with sizes
sudo sg_inq /dev/sdX    # the device's own identification (INQUIRY)

Useful when a disk sits behind a USB adapter or a SAS controller and lsblk shows little about it.

blockdev: read-only flag and device size

Package: util-linux · Writes to disks: no

sudo blockdev --report                # every block device: read-only flag, size, sector size
sudo blockdev --setro /dev/sdX        # make the kernel refuse writes to the disk
sudo blockdev --setro /dev/sdX1       # … and to each partition you will use
sudo blockdev --getro /dev/sdX1       # 1 = read-only
sudo blockdev --getsize64 /dev/sdX    # size in bytes

Set disks read-only before mounting or examining them. The flag lasts until the device is removed or the computer restarts. See Working safely with disks.

losetup: use an image file as a disk

Package: util-linux · Writes to disks: no, with -r

Turns a disk image (made with ddrescue or dd) into a device, so that the usual tools can read its partitions.

sudo losetup -r -P -f --show disk.img   # read-only, with partitions; prints /dev/loopN
lsblk /dev/loop0                         # its partitions: /dev/loop0p1, …
sudo mount -o ro,noload /dev/loop0p1 /mnt
sudo umount /mnt
sudo losetup -d /dev/loop0               # detach
losetup -a                               # list loop devices in use

-r makes the loop device read-only, so nothing can change the image.

parted: partition tables

Package: parted · Writes to disks: yes, when changing partitions

sudo parted -l                       # every disk: table type (gpt/msdos) and partitions
sudo parted /dev/sdX unit s print    # one disk, positions in sectors
sudo parted /dev/sdX print free      # including unallocated space

The commands above only read.

Writes: mklabel, mkpart, rm, resizepart and the rest change the partition table, and parted applies each command at once, without a final “write” step. mklabel makes every partition on the disk unreachable. On a disk you are recovering from, work on a copy instead.

gdisk and sgdisk: GPT partition tables

Package: gptfdisk · Writes to disks: yes, when told to

sudo gdisk -l /dev/sdX                 # list the partition table (read-only)
sudo sgdisk -p /dev/sdX                # the same, non-interactive
sudo sgdisk -i 1 /dev/sdX              # details of partition 1 (type GUID, unique GUID, name)
sudo sgdisk -b gpt-sdX.bin /dev/sdX    # save the GPT to a file (backup)

Keep a backup of the table (-b) before trying any repair. sgdisk -l <file> loads it back; that one writes.

gdisk without -l is interactive: nothing is written until you type w, and q quits without saving. Its recovery menu (r) can rebuild a damaged GPT from the backup copy at the end of the disk.

fdisk: list partitions

Package: util-linux · Writes to disks: only after w in interactive mode

sudo fdisk -l                # every disk with its partitions, sizes and types
sudo fdisk -l /dev/sdX       # one disk
sudo fdisk -x /dev/sdX       # more detail

fdisk /dev/sdX (without -l) opens the interactive editor. Changes stay in memory until w; q quits without writing.

gparted: partitions, graphically

Package: gparted · Writes to disks: only when you apply

Create, delete, move, resize and check partitions in a window.

sudo -E gparted            # in pwm or wasp
sudo -E gparted /dev/sdX   # open one disk

Operations queue up and nothing is written until you click Apply; until then, you can undo them.

Moving or resizing can lose data if interrupted. Never on a failing disk or on evidence: copy it first with ddrescue. Do not use it on a disk you are examining.

Opening it changes nothing: in a virtual machine, a disk holding ext4, swap, LUKS and LVM stayed identical, byte for byte, with nothing mounted or activated. In wasp, plain sudo gparted fails with cannot open display; -E fixes it.

f3: fake-capacity USB sticks and cards

Package: f3 · Writes to disks: yes

Checks whether a USB stick or memory card really has the capacity it claims.

sudo f3probe /dev/sdX          # quick probe of the whole device
f3write /mnt/stick && f3read /mnt/stick   # fill a mounted stick with test files, then check them

Writes: f3probe writes to the device during the test and puts the original blocks back afterwards (with --destructive it does not). f3write fills the free space with files. Use them only on a stick whose contents you do not need, never on evidence.

Recovery

Tools to copy data off failing disks, find lost partitions and files, and back up or restore file systems.

On a failing disk, copy first, repair later: every read of a dying disk may be one of the last. Image it with ddrescue onto a healthy disk, then run the other tools on the image (see losetup).

ToolFor
ddrescuecopying a failing disk, skipping and retrying bad areas
testdiskfinding lost partitions, repairing boot sectors, undeleting
photorecrecovering files by their content, whatever the file system
extundeleteundeleting files on ext3/ext4
partcloneimaging only the used blocks of a file system
fsarchiverbacking up and restoring file systems as archives
gpartguessing a lost MBR partition table
restic, borggetting files back from backups

ddrescue: copy a failing disk

Package: ddrescue (GNU ddrescue) · Writes to disks: only to the output you name

Copies a disk or partition to an image file (or another disk), reading the easy parts first and coming back to the bad areas later. The map file records what has been copied, so a copy can be stopped and resumed.

# 1. First pass: copy everything that reads easily, skip the bad areas
sudo ddrescue -n /dev/sdX /mnt/target/disk.img /mnt/target/disk.map

# 2. Second pass: go back to the bad areas, 3 retries, direct disk access
sudo ddrescue -d -r3 /dev/sdX /mnt/target/disk.img /mnt/target/disk.map

# Copy to another disk instead of a file (-f is needed to write to a device)
sudo ddrescue -f -n /dev/sdX /dev/sdY /mnt/target/disk.map
  • -n: no scraping; leaves the slowest, worst areas for later.
  • -d: reads the source directly, bypassing the kernel cache.
  • -r3: retries bad sectors three times.

The target must be at least as big as the source, on a different, healthy disk, mounted read-write on purpose. Keep the map file next to the image: rerunning the same command continues where it stopped.

Writes: to the output. Double-check the order: source first, then the image or target disk. Swapping them overwrites the disk you are rescuing.

testdisk: lost partitions and boot sectors

Package: testdisk · Writes to disks: only when you choose “Write”

Finds lost or deleted partitions, rebuilds partition tables and boot sectors, and can undelete files on FAT, NTFS and ext2 file systems (for ext3/ext4, see extundelete). It is interactive (menus).

sudo testdisk /list /dev/sdX      # just list the partitions it sees
sudo testdisk /log /dev/sdX       # interactive, keeping testdisk.log
sudo testdisk /log disk.img       # work on an image instead of the disk

Typical path for a lost partition: choose the disk → the partition table type → Analyse → Quick Search (then Deeper Search if needed). Check the partitions it found with P (list files) before going on.

Check the table type. On a GPT disk left with no partitions, TestDisk proposes Intel (MBR): choosing it would replace the GPT. Choose EFI GPT. See I deleted a partition.

Writes: only at the end, on Write. Until then, everything is read only. Prefer running it on an image of the disk.

For deleted files: Advanced → choose the partition → Undelete.

photorec: recover files by their content

Package: testdisk · Writes to disks: only to the folder where recovered files go

Recovers files (photos, documents, archives, …) by recognising their content, even when the file system is damaged or reformatted. File names and folders are not kept.

sudo photorec /log /d /mnt/target/recovered /dev/sdX   # recover into that folder
sudo photorec /log /d /mnt/target/recovered disk.img   # from an image

It is interactive: choose the partition (or the whole disk), the file system type and the file types to look for (File Opt), then Search.

Writes: recovered files go to the folder given with /d. It must be on another disk; recovering onto the disk you are scanning overwrites the files you are looking for.

extundelete: undelete on ext3/ext4

Package: extundelete · Writes to disks: no (to the scanned file system); recovered files go to the current folder

Recovers deleted files from an ext3 or ext4 file system using its journal. The file system must be unmounted.

cd /mnt/target                                         # somewhere on another disk
sudo extundelete /dev/sdX1 --restore-all               # everything it can find
sudo extundelete /dev/sdX1 --restore-file home/user/report.odt   # one file
sudo extundelete /dev/sdX1 --restore-directory home/user/Photos  # one folder
sudo extundelete /dev/sdX1 --restore-all -o /mnt/target/undeleted   # choose the output folder

Recovered files go to RECOVERED_FILES/ in the current folder, or to the folder given with -o. Paths are relative to the root of the file system, without a leading /.

The sooner it runs after the deletion, the better: anything written to that file system since may have reused the blocks.

partclone: image a file system

Package: partclone · Writes to disks: to the output; when restoring, to the target partition

Copies only the blocks a file system uses, so images are much smaller than with dd. There is one program per file system: partclone.ext4, partclone.ntfs, partclone.vfat, partclone.btrfs, partclone.exfat, partclone.f2fs, … (there is no partclone.xfs in Void; use xfsdump or fsarchiver for XFS)

sudo partclone.ext4 -c -s /dev/sdX1 -o /mnt/target/sdX1.img    # save (clone) to an image
sudo partclone.ext4 -r -s /mnt/target/sdX1.img -o /dev/sdY1    # restore the image to a partition
sudo partclone.ntfs -b -s /dev/sdX1 -o /dev/sdY1               # partition to partition
  • -c: clone to partclone’s image format; -r: restore from it; -b: device to device.
  • -s: source; -o: output.

partclone needs a readable file system. For a disk with bad sectors, use ddrescue instead.

Writes: restoring (-r, -b) overwrites the target partition.

fsarchiver: back up and restore file systems

Package: fsarchiver · Writes to disks: restfs overwrites the target

Saves file systems to a compressed archive and restores them to partitions of any size (as long as the data fits).

sudo fsarchiver probe                                       # file systems it can see
sudo fsarchiver savefs -j4 /mnt/target/backup.fsa /dev/sdX1 # save one file system (4 threads)
sudo fsarchiver savefs -Z3 /mnt/target/backup.fsa /dev/sdX1 /dev/sdX2   # two, zstd level 3
fsarchiver archinfo /mnt/target/backup.fsa                  # what is in an archive
sudo fsarchiver restfs /mnt/target/backup.fsa id=0,dest=/dev/sdY1   # restore the first one

In restfs, id= is the position of the file system in the archive (0 for the first), as shown by archinfo.

Writes: restfs formats and overwrites the destination partition.

gpart: guess a lost MBR partition table

Package: gpart · Writes to disks: only with -W

Scans a disk for the start of known file systems and proposes an MBR (msdos) partition table. For GPT disks, use testdisk or gdisk instead.

sudo gpart /dev/sdX         # scan and print the partitions it guesses
sudo gpart -f /dev/sdX      # full scan (slower, finds more)

Compare its guess with what you know about the disk before acting on it.

Writes: -W writes the guessed table to a device or file. Use testdisk for an interactive, safer repair.

restic: read and restore backups

Package: restic · Writes to disks: only to the folder you restore into

Opens restic repositories, local or remote, to recover files from them. It asks for the repository’s password.

restic -r /mnt/backup/repo snapshots                     # list the snapshots
restic -r /mnt/backup/repo ls latest                     # files in the newest one
restic -r /mnt/backup/repo find report.odt               # which snapshots have this file
restic -r /mnt/backup/repo restore latest --target /mnt/target/out
restic -r /mnt/backup/repo restore latest --target /mnt/target/out --include /home/user/Documents
restic -r /mnt/backup/repo check                         # is the repository healthy?
restic -r sftp:user@host:/backups/repo snapshots         # a repository over SSH

To browse a backup as a folder: mkdir -p ~/snap && restic -r /mnt/backup/repo mount ~/snap (Ctrl+C to stop).

To make a new backup: restic -r /mnt/target/repo init once, then restic -r /mnt/target/repo backup /mnt/source.

borg: read and restore backups

Package: borg · Writes to disks: only to the current folder when extracting

Opens BorgBackup repositories. It asks for the passphrase if there is one.

borg list /mnt/backup/repo                     # the archives
borg list /mnt/backup/repo::2026-11-01         # files in one archive
borg info /mnt/backup/repo::2026-11-01         # its size and date
cd /mnt/target/out && borg extract /mnt/backup/repo::2026-11-01             # everything
cd /mnt/target/out && borg extract /mnt/backup/repo::2026-11-01 home/user/Documents
borg extract --dry-run --list /mnt/backup/repo::2026-11-01     # show, write nothing
borg check /mnt/backup/repo                    # is the repository healthy?

borg extract writes into the current folder: change to a folder on another disk first. Repositories over SSH need Borg on the other machine too: borg list user@host:/backups/repo.

File systems and volumes

Mounting, checking and repairing file systems, and opening encrypted volumes, LVM and software RAID.

Everything here starts from Working safely with disks: nothing is mounted, assembled or unlocked automatically, and on a disk that matters you mark it read-only first.

Checking (-n, no changes) is safe. Repairing writes to the file system; on a disk with data you need, image it first (ddrescue) and repair the copy.

ToolFor
mountmounting read-only, without replaying journals
ext2/3/4e2fsck, tune2fs, debugfs
XFSxfs_repair, xfs_info
Btrfsbtrfs check, btrfs restore
NTFSntfs-3g, ntfsfix, ntfsinfo
FAT and exFATfsck.vfat, fsck.exfat
cryptsetupLUKS and BitLocker volumes
dislockerBitLocker volumes (alternative)
LVMlogical volumes
mdadmLinux software RAID, and Intel RST (IMSM) sets

mount: mount without changing the disk

Package: util-linux · Writes to disks: not with the options below

sudo blockdev --setro /dev/sdX /dev/sdX1        # first: make the devices read-only
sudo mount -o ro,noload /dev/sdX1 /mnt           # ext3/ext4: no journal replay
sudo mount -o ro,norecovery /dev/sdX1 /mnt       # XFS: no log recovery
sudo mount -o ro /dev/sdX1 /mnt                  # other file systems
findmnt /mnt                                     # check: options must include "ro"
sudo umount /mnt

Without noload (ext4) or norecovery (XFS), the kernel replays an unfinished journal even with -o ro, which writes to the disk.

For NTFS, see NTFS; for encrypted volumes, open them first with cryptsetup.

ext2, ext3 and ext4: e2fsck, tune2fs, debugfs

Package: e2fsprogs · Writes to disks: e2fsck without -n

sudo e2fsck -fn /dev/sdX1      # full check, change nothing (answers "no" to everything)
sudo e2fsck -fp /dev/sdX1      # repair what is safe to repair automatically
sudo e2fsck -fy /dev/sdX1      # repair everything, answering "yes" (last resort, on a copy)
sudo tune2fs -l /dev/sdX1      # superblock: state, last mount, mount count, features
sudo debugfs -R ls /dev/sdX1   # list the root folder without mounting (read-only by default)

The file system must not be mounted while e2fsck runs. -f checks even when the file system says it is clean.

Writes: -p and -y repair, and so change the file system. Run them on an image when the data matters.

XFS: xfs_repair, xfs_info

Package: xfsprogs · Writes to disks: xfs_repair without -n

sudo xfs_repair -n /dev/sdX1   # check only, no changes
sudo xfs_repair /dev/sdX1      # repair (the file system must be unmounted)
xfs_info /mnt                  # geometry of a mounted XFS

If xfs_repair refuses because the log is dirty, first mount and unmount the file system once so the log is replayed (this writes), or, as a last resort, xfs_repair -L, which throws the log away and can lose recent changes.

To read a damaged XFS without changing it, mount with -o ro,norecovery (see mount).

Btrfs: check and restore

Package: btrfs-progs · Writes to disks: btrfs restore only to the target folder

sudo btrfs filesystem show                         # Btrfs file systems and their devices
sudo btrfs check --readonly /dev/sdX1              # check without changing anything
sudo btrfs restore -v /dev/sdX1 /mnt/target/out    # copy files off a damaged, unmountable Btrfs
sudo mount -o ro,rescue=usebackuproot /dev/sdX1 /mnt   # try an older tree root, read-only

btrfs restore reads the file system directly and writes the files it can reach into a folder on another disk.

Writes: btrfs check --repair exists but can make things worse; the Btrfs developers advise it only as a last resort. Prefer restore.

NTFS: ntfs-3g, ntfsfix, ntfsinfo

Package: ntfs-3g · Writes to disks: ntfsfix without -n

sudo ntfs-3g -o ro /dev/sdX1 /mnt     # mount read-only
sudo ntfsinfo -m /dev/sdX1            # volume information (unmounted)
sudo ntfsfix -n /dev/sdX1             # what ntfsfix would do, without writing
sudo ntfsfix -d /dev/sdX1             # clear the "dirty" flag so Windows runs chkdsk

A Windows that was hibernated or shut down with Fast Startup leaves NTFS in a state that must not be written to; mount it read-only (-o ro), as above. The Windows partitions of a BitLocker-encrypted disk must be opened first with cryptsetup or dislocker.

ntfsfix is not a full repair tool (that is chkdsk on Windows); it fixes some common problems and schedules a check.

FAT and exFAT: fsck.vfat, fsck.exfat

Packages: dosfstools, exfatprogs · Writes to disks: without -n

sudo fsck.vfat -n /dev/sdX1    # check a FAT12/16/32 file system, change nothing
sudo fsck.vfat -a /dev/sdX1    # repair automatically
sudo fsck.exfat -n /dev/sdX1   # check exFAT, change nothing
sudo fsck.exfat -y /dev/sdX1   # repair exFAT

USB sticks and SD cards are usually FAT32 or exFAT. EFI system partitions are FAT32.

Writes: -a and -y repair, and so change the file system.

cryptsetup: LUKS and BitLocker volumes

Package: cryptsetup · Writes to disks: not with --readonly

Nothing is unlocked at boot. To open an encrypted volume without changing it:

sudo cryptsetup isLuks -v /dev/sdX2                   # is this a LUKS volume?
sudo cryptsetup luksDump /dev/sdX2                    # header: version, cipher, key slots
sudo cryptsetup open --readonly /dev/sdX2 evidence    # unlock read-only → /dev/mapper/evidence
sudo cryptsetup status evidence                       # check: "mode: readonly"
sudo mount -o ro,noload /dev/mapper/evidence /mnt     # if it holds ext4
sudo umount /mnt && sudo cryptsetup close evidence

sudo cryptsetup luksHeaderBackup /dev/sdX2 --header-backup-file /mnt/target/sdX2.luksheader

BitLocker (Windows): cryptsetup opens it too, with the user password or the 48-digit recovery key:

sudo cryptsetup bitlkDump /dev/sdX3
sudo cryptsetup open --type bitlk --readonly /dev/sdX3 windows
sudo ntfs-3g -o ro /dev/mapper/windows /mnt

Verified in a virtual machine for LUKS2: the mapping was read-only, writes failed and the container’s hash did not change. Keep a header backup before any repair: a damaged LUKS header makes the data unrecoverable.

dislocker: BitLocker volumes

Package: dislocker · Writes to disks: not with -r

An alternative to cryptsetup for BitLocker. It exposes the decrypted volume as a file, dislocker-file, which is then mounted.

sudo mkdir -p /mnt/bitlocker /mnt/windows
sudo dislocker -r -V /dev/sdX3 -u -- /mnt/bitlocker          # asks for the user password
sudo dislocker -r -V /dev/sdX3 -p -- /mnt/bitlocker          # asks for the recovery key
sudo dislocker -r -V /dev/sdX3 -f /path/key.BEK -- /mnt/bitlocker   # with a .BEK key file
sudo ntfs-3g -o ro /mnt/bitlocker/dislocker-file /mnt/windows
sudo umount /mnt/windows && sudo umount /mnt/bitlocker

-r keeps the BitLocker volume read-only.

LVM: logical volumes

Package: lvm2 · Writes to disks: not with the commands below

d77orphaned never activates LVM volumes on its own.

sudo pvs; sudo vgs; sudo lvs           # physical volumes, volume groups, logical volumes
sudo vgchange -ay --config 'activation { read_only_volume_list = [ "myvg" ] }' myvg
sudo lvs myvg                          # attributes "-Ri-a-": active (a) and read-only (R)
sudo mount -o ro,noload /dev/myvg/root /mnt
sudo umount /mnt && sudo vgchange -an myvg     # deactivate when done

Verified in a virtual machine: the logical volumes were active and read-only, writes failed and the disk’s hash did not change.

Avoid vgchange -ay --readonly (activates nothing) and lvchange -pr (writes the permission into the metadata on the disk).

mdadm: software RAID

Package: mdadm · Writes to disks: assembling read-write does

d77orphaned never assembles RAID arrays on its own. mdadm also reads the Intel Rapid Storage (IMSM) RAID sets that many desktops use.

cat /proc/mdstat                                # arrays the kernel knows about
sudo mdadm --examine /dev/sdX1                  # RAID metadata on one member
sudo mdadm --examine --scan                     # arrays found on all disks
sudo mdadm --assemble --readonly /dev/md0 /dev/sdX1 /dev/sdY1   # assemble read-only
sudo mdadm --detail /dev/md0                    # state of an assembled array
sudo mdadm --stop /dev/md0

Not verified yet in d77orphaned: read-only assembly. When the data matters, image each member disk first and assemble the images (through losetup).

Forensics

Tools to image disks with hashes, open forensic image formats and examine file systems without mounting them.

A careful workflow, in short:

  1. Make the source read-only (blockdev).
  2. Image it with hashes (dcfldd or ewfacquire) onto another disk.
  3. Verify the image (ewfverify, or compare the hashes).
  4. Work only on the image: list and extract files with the Sleuth Kit, carve deleted data with foremost, or mount it read-only (xmount, losetup).

d77orphaned gives you tools that do not write unless told to. Chain of custody, notes and procedure are yours.

ToolFor
sha256sum and friendshashing disks, images and files
dcflddraw images with hashes computed while copying
ewfacquire, ewfverify, ewfinfo, ewfmountEWF (E01) images
affinfoAFF images
xmountpresenting E01/AFF images as raw disks
Sleuth Kitpartitions, files and deleted files inside an image
foremostcarving files out of raw data
exiftoolfile metadata: dates, GPS, author
yarasearching with rules
binwalkfinding embedded files and firmware
xxd and hexeditlooking at raw bytes

sha256sum and friends: hashes

Package: coreutils · Writes to disks: no

sudo sha256sum /dev/sdX                      # hash a whole disk (reads all of it)
sha256sum disk.img > disk.img.sha256         # hash an image and keep the result
sha256sum -c disk.img.sha256                 # later: check the image has not changed

md5sum, sha1sum and sha512sum work the same way. Hash the source and the image: identical hashes mean an exact copy.

dcfldd: raw images with hashes

Package: dcfldd · Writes to disks: to the output

dd with hashing and progress built in.

sudo dcfldd if=/dev/sdX of=/mnt/target/disk.img hash=sha256 hashlog=/mnt/target/disk.sha256
sudo dcfldd if=/dev/sdX of=/mnt/target/disk.img hash=md5,sha256 hashwindow=1G hashlog=/mnt/target/disk.hashes
  • hash=: md5, sha1, sha256, sha384 or sha512 (several, separated by commas).
  • hashlog=: where the hashes go; hashwindow= also hashes each chunk of that size, to locate damage later.

dcfldd stops on read errors like dd. For a failing disk use ddrescue, then hash the image.

Writes: to of=. Check if= (source) and of= (target) twice.

ewfacquire, ewfverify, ewfinfo, ewfmount: EWF (E01) images

Package: libewf · Writes to disks: ewfacquire writes the image files

The Expert Witness Format (.E01, .E02, …) stores the disk compressed, in segments, with case notes and hashes inside.

sudo ewfacquire /dev/sdX                       # interactive: asks for target, case number, examiner, …
sudo ewfacquire -u -t /mnt/target/case1 -C 2026-001 -E disk1 -e "J. Doe" -d sha256 /dev/sdX
ewfverify /mnt/target/case1.E01                # recompute and check the stored hashes
ewfinfo /mnt/target/case1.E01                  # case data, acquisition date, hashes
sudo mkdir -p /mnt/ewf && sudo ewfmount /mnt/target/case1.E01 /mnt/ewf   # → /mnt/ewf/ewf1, a raw view
  • -u: unattended (no questions); -t: target name without extension; -C case number, -E evidence number, -e examiner, -d sha256 an extra hash besides MD5.

ewfmount exposes the image as one read-only raw file (ewf1), which the Sleuth Kit or losetup can then read.

affinfo: AFF images

Package: afflib · Writes to disks: no

affinfo image.aff          # metadata and segments of an AFF image
affinfo -a image.aff       # all segments, including data segments

To read the contents of an AFF image, present it as a raw disk with xmount.

xmount: E01 and AFF images as raw disks

Package: xmount · Writes to disks: no (writes go to a cache file, if you allow them)

sudo mkdir -p /mnt/raw
sudo xmount --in ewf /mnt/target/case1.E01 /mnt/raw     # E01 → a raw .dd file in /mnt/raw
ls /mnt/raw                                              # its name
sudo xmount --in aff image.aff /mnt/raw                  # AFF → raw
sudo losetup -r -P -f --show /mnt/raw/<name>.dd          # then its partitions as /dev/loopNpM
sudo umount /mnt/raw

Without --cache, the virtual disk is read-only. With --cache <file>, programs that insist on writing (some need it to mount) write into that file and the image itself stays untouched.

Sleuth Kit: mmls, fsstat, fls, icat, istat, tsk_recover

Package: sleuthkit · Writes to disks: no (tsk_recover writes to its output folder)

Reads partitions and file systems inside an image (or a device) without mounting it, including deleted entries. It works on raw images, and on E01 directly.

mmls disk.img                       # partitions, with their start sector
fsstat -o 2048 disk.img             # file system at sector 2048: type, size, dates
fls -o 2048 -r -p disk.img          # every file, with full paths (deleted ones marked *)
fls -o 2048 -r -d -p disk.img       # deleted entries only
istat -o 2048 disk.img 1234         # metadata of inode/MFT entry 1234
icat -o 2048 disk.img 1234 > out    # the contents of inode 1234
tsk_recover -o 2048 -e disk.img /mnt/target/recovered   # extract every file, deleted ones included

-o is the partition’s start sector, from mmls. fls -m / -r prints a “body file” for building a timeline with mactime.

foremost: carve files out of raw data

Package: foremost · Writes to disks: only to the output folder

Finds files by their headers and footers in an image or device, ignoring the file system. Like photorec, but configured by file type.

foremost -i disk.img -o /mnt/target/carved                  # all built-in types
foremost -t jpg,pdf,doc -i disk.img -o /mnt/target/carved   # only some types
foremost -T -i disk.img -o /mnt/target/carved               # time-stamped output folder

The output folder must not exist yet (or use -T); a report (audit.txt) is written there too.

exiftool: file metadata

Package: exiftool · Writes to disks: only with the options that change metadata

Reads metadata from photos, documents, videos and many more: dates, camera, GPS position, author, software used.

exiftool photo.jpg                         # everything it finds
exiftool -a -G1 document.pdf               # with duplicates, grouped by origin
exiftool -gps:all photo.jpg                # only the GPS position
exiftool -r -csv /mnt/evidence/Photos > photos.csv   # a whole folder, as a table

Writes: options that set a value (such as -all=) change the file, and keep a copy named file_original. Never on evidence: work on a copy.

yara: search with rules

Package: yara · Writes to disks: no

Looks for patterns (text, bytes, conditions) described in rule files, typically to recognise malware or known files. d77orphaned ships no rules: bring your own.

yara rules.yar suspicious.exe              # which rules match this file
yara -r rules.yar /mnt/evidence            # a whole folder, recursively
yara -s rules.yar suspicious.exe           # also show the matching strings

A minimal rule, in rules.yar:

rule contains_password {
    strings:
        $a = "password" nocase
    condition:
        $a
}

binwalk: embedded files and firmware

Package: binwalk · Writes to disks: only with -e, to a folder next to the file

binwalk firmware.bin        # list signatures found inside: archives, file systems, images
binwalk -e firmware.bin     # extract what it recognises
binwalk -E firmware.bin     # entropy: compressed or encrypted areas

Useful for router firmware, unknown blobs and files hidden inside other files.

xxd and hexedit: raw bytes

Packages: xxd, hexedit · Writes to disks: hexedit when saving

xxd -l 512 disk.img                 # first sector: hex and text side by side
sudo xxd -s 1024 -l 512 /dev/sdX1   # 512 bytes starting at offset 1024 (ext superblock)
hexedit disk.img                    # interactive viewer/editor

In hexedit, Ctrl-X saves and quits, Ctrl-C quits without saving. Open evidence only in images, or use xxd, which only reads.

Secure erasure and sanitization

Everything in this chapter destroys data, and it cannot be undone. Check each device by model and serial first (lsblk -d -o NAME,SIZE,MODEL,SERIAL,TRAN). Only erase disks you own or are authorized to erase. Nothing here runs by itself: d77orphaned erases only what you tell it to.

Which method for which disk

DiskUseWhy
Hard disk (HDD)nwipeoverwriting reaches every sector the disk shows
SATA SSDATA Secure Erasethe drive erases itself, including areas software cannot reach
NVMe SSDNVMe sanitize or formatsame, through the NVMe commands
SAS or SCSI disksg_sanitizethe SCSI equivalent
USB stick, SD cardnwipe, then treat as not guaranteedadapters usually block firmware commands
Any disk already encrypteddestroy the keys, then one of the abovefast, and the data is unreadable without keys

Why overwriting is not enough on SSDs

An SSD maps what you write to whichever flash cells it chooses, and keeps spare cells you cannot address. Overwriting the whole drive can leave old data in those cells. The drive’s own erase commands reach them, so use those on SSDs.

On a hard disk, one pass is enough: NIST SP 800-88 treats a single overwrite as sufficient for modern drives. Multi-pass methods such as Gutmann or DoD take far longer, and exist for older drives or for policies that require them.

Check it worked

  • After nwipe: its verification pass, and its log or PDF report.
  • After a firmware erase: the drive only reports what it did, and you are trusting its firmware. You can check that it reads as empty, for example sudo cmp /dev/sdX /dev/zero (zeros are common, but not every drive returns them).
  • For data that must never be recovered, physically destroy the drive as well.

Several disks at once

nwipe wipes several disks at the same time by itself. For the other tools, see parallel.

What has been tested: nwipe and parallel, in a virtual machine. The firmware commands (hdparm, nvme, sg_sanitize) have not been run on real drives by this project; their pages come from the tools’ own documentation. Try them on a drive you can lose first.

nwipe: overwrite whole disks

Package: nwipe · Writes to disks: yes, it erases them

The tool behind ShredOS. It overwrites whole disks, several at a time, verifies the result and writes a report.

sudo nwipe                                  # interactive: pick disks and method, keys are shown on screen
sudo nwipe --method=zero /dev/sdX           # interactive, offering only this disk, with one zero pass
sudo nwipe --method=dodshort --verify=all /dev/sdX /dev/sdY
sudo nwipe --method=verify_zero /dev/sdX    # write nothing: check the disk is all zeros

In the interactive screen, nothing is erased until you start it: Space marks or unmarks a disk, and S (capital, Shift+S) starts the wipe. The keys are listed at the bottom of the screen.

Where to run it: nwipe’s screen is unreadable in pwm’s terminal (st, with its Dracula colours and transparency). Run it in the wasp session, where it was tested and is readable. The text console (Ctrl+Alt+F2, not available with the graphics disabled entry) should work too, but has not been tested.

Methods

--method=What it does
zero (or quick)one pass of zeros; enough for a hard disk
oneone pass of 0xFF
random (or prng, stream)random data; the default
dodshort (or dod3pass)3 passes (DoD)
dod522022m (or dod)7 passes (DoD 5220.22-M)
gutmann35 passes; very slow, for old drives
ops2, is5enh, bruce7, bmbother standards
verify_zero, verify_oneonly check the disk’s content

Useful options

  • --verify=off|last|all: verify nothing, the last pass (default) or every pass.
  • --rounds=N: repeat the method N times.
  • --logfile=FILE: keep the log in a file.
  • -P PATH: where the PDF report goes (-P noPDF for none). Save it somewhere that survives a reboot, such as /mnt/d77-data.
  • --exclude=/dev/sdA,/dev/sdB: never touch these devices.
  • --nousb: ignore USB devices.

What protects you, and what does not

nwipe refuses devices that are in use. Verified in a virtual machine: the d77orphaned boot stick (also with the RAM boot entry) and a mounted disk were left untouched, and a disk given to --exclude too. --force removes this protection; do not use it.

Danger: --autonuke without a device starts at once and erases every disk not in use, with no questions. --nogui needs it. Always name the devices: sudo nwipe --autonuke --nogui --method=zero /dev/sdX.

Verified in a virtual machine: a disk wiped with --method=zero --verify=last read back as all zeros.

ATA Secure Erase with hdparm: SATA drives

Package: hdparm · Writes to disks: yes, the drive erases itself

For SATA SSDs and hard disks. The drive does the work, and it usually covers areas software cannot reach. It does not normally work through USB adapters.

sudo hdparm -I /dev/sdX | grep -A8 Security   # supported? "not frozen"? how long will it take?
sudo hdparm --user-master u --security-set-pass erase /dev/sdX   # set a temporary password
sudo hdparm --user-master u --security-erase erase /dev/sdX      # erase (the password is removed)
sudo hdparm -I /dev/sdX | grep -A8 Security   # "not enabled" again

--security-erase-enhanced instead of --security-erase also covers reallocated areas, if hdparm -I lists it as supported.

  • “frozen”: the BIOS froze the security commands at boot. Suspending and resuming the machine often clears it, as does plugging the drive in after boot; not all machines allow either.
  • Do not interrupt it, or power off: a drive left locked needs the password (--security-unlock erase, then --security-disable erase) to be usable.

Not verified on real drives by this project. On laptops, some firmwares have been reported to brick drives on these commands: try on a drive you can lose.

NVMe sanitize and format

Package: nvme-cli · Writes to disks: yes, the drive erases itself

Note the two device names: /dev/nvme0 is the controller, /dev/nvme0n1 the namespace.

sudo nvme id-ctrl /dev/nvme0 -H | grep -iE 'format|crypto|sanitize'   # what it supports

# Sanitize: the strongest; covers the whole drive, and survives a power loss
sudo nvme sanitize /dev/nvme0 --sanact=2      # block erase
sudo nvme sanitize /dev/nvme0 --sanact=4      # crypto erase
sudo nvme sanitize-log /dev/nvme0             # progress and result

# Format: where sanitize is not supported
sudo nvme format /dev/nvme0n1 --ses=1         # erase user data
sudo nvme format /dev/nvme0n1 --ses=2         # crypto erase

Use the value the drive reports as supported. Sanitize keeps running in the background after the command returns: check it with sanitize-log.

Not verified on real drives by this project.

sg_sanitize: SAS and SCSI disks

Package: sg3_utils · Writes to disks: yes, the drive erases itself

sudo sg_sanitize --dry-run --block /dev/sdX   # check the command, send nothing
sudo sg_sanitize --block --wait /dev/sdX      # block erase, and wait
sudo sg_sanitize --crypto --wait /dev/sdX     # cryptographic erase
sudo sg_sanitize --overwrite --wait /dev/sdX  # overwrite

It works only if the drive supports the SCSI SANITIZE command, and it can take hours. It usually does not work through USB adapters.

Not verified on real drives by this project.

Destroying encryption keys

Package: cryptsetup · Writes to disks: yes, the key material

A LUKS volume is unreadable without its keys, so destroying them makes the data unrecoverable in seconds, whatever the size of the disk.

sudo cryptsetup isLuks -v /dev/sdX2     # is it LUKS?
sudo cryptsetup erase /dev/sdX2         # destroy all key slots
sudo cryptsetup luksDump /dev/sdX2      # the slots are now empty

This is only as good as the encryption was: copies of the LUKS header, kept elsewhere, could still open the volume with an old passphrase. If the disk was ever used unencrypted, old data may remain outside the volume, so follow with a method from the chapter’s table when that matters.

The persistence partition of a d77orphaned stick can be destroyed this way too.

blkdiscard: quick discard on SSDs

Package: util-linux · Writes to disks: yes

Tells an SSD that all its blocks are free, which is very fast, but it is not a guaranteed erasure: use it to prepare a drive for reuse, not for sensitive data.

sudo blkdiscard /dev/sdX            # discard everything
sudo blkdiscard --secure /dev/sdX   # secure discard, if the drive supports it
sudo blkdiscard --zeroout /dev/sdX  # write zeros instead of discarding

parallel: run on several disks at once

Package: parallel

Runs a command once per item, several at a time, keeping each one’s output separate. Useful for tools that handle a single disk.

parallel --tag sudo smartctl -H {} ::: /dev/sda /dev/sdb /dev/sdc      # a safe first try
parallel --tag --dry-run sudo blkdiscard {} ::: /dev/sdb /dev/sdc      # show the commands, run nothing
parallel --tag sudo nvme sanitize {} --sanact=2 ::: /dev/nvme0 /dev/nvme1
  • {} is replaced by each item after :::.
  • --tag starts each line of output with the item it belongs to.
  • --dry-run only prints what would run: use it first on anything destructive.
  • --jobs N limits how many run at a time.

It works with anything, not only disks. For overwriting, nwipe already handles several disks at a time.

Network

Tools to connect, diagnose a network, transfer data and look at traffic. For getting online in the first place, see Network.

The scanning and capture tools (nmap, tcpdump, arp-scan) are for networks you are authorized to test.

ToolFor
nmcli and nmtuiconnecting to wired and Wi-Fi networks
ipaddresses, routes, interfaces
ping, traceroute, mtrreachability and the path to a host
dig, host, whoisDNS and domain ownership
iw and ethtoolWi-Fi and Ethernet link details
curl, wget, lftpdownloading and uploading
ssh, scp, rsync, sshfsremote shells, copying, mounting over SSH
NFS and SMB sharesmounting network shares
tcpdumpcapturing traffic
nmapfinding hosts and open ports
testssl.sh, ssh-auditauditing TLS and SSH servers
arp-scanlisting devices on the local network
nc and socatraw connections, quick file transfer
iperf3measuring bandwidth
iftop and nethogswho is using the network
WireGuard and OpenVPNVPN connections
linksweb browsing in a text console
ipcalcsubnet calculations

nmcli and nmtui: connecting

Package: NetworkManager

NetworkManager starts at boot and connects wired networks by itself (DHCP). For Wi-Fi:

nmtui                                         # menus: "Activate a connection" lists Wi-Fi networks
nmcli device wifi list                        # visible Wi-Fi networks
nmcli device wifi connect "NetworkName" password 'the passphrase'
nmcli device status                           # each interface and its state
nmcli connection show                         # saved connections
nmcli connection down "NetworkName"           # disconnect
nmcli radio wifi off                          # turn Wi-Fi off

The live user can run these without sudo. Saved connections are lost at reboot, like everything else.

To stay offline (e.g. when examining a machine that must not touch a network): nmcli networking off, and nmcli networking on to come back.

ip: addresses, routes, interfaces

Package: iproute2

ip -br addr             # each interface with its addresses, one line each
ip -br link             # interfaces and whether the link is up
ip route                # routing table (the "default via" line is the gateway)
ip neigh                # neighbours (ARP/NDP cache)
sudo ip link set eth0 down       # take an interface down (and "up" again)
sudo ip addr add 192.168.1.50/24 dev eth0   # add a static address by hand

Interfaces managed by NetworkManager are better changed with nmcli; manual changes may be overwritten.

ping, traceroute, mtr: reachability and path

Packages: iputils, traceroute, mtr

ping -c 4 1.1.1.1              # is the internet reachable? (no DNS involved)
ping -c 4 voidlinux.org        # … and does DNS work?
traceroute voidlinux.org       # the routers on the way
mtr voidlinux.org              # live traceroute with loss per hop (q quits)
mtr -r -c 20 -n voidlinux.org  # report after 20 probes, numeric addresses

If ping 1.1.1.1 works but ping voidlinux.org does not, the problem is DNS; see dig.

dig, host, whois: DNS and domains

Packages: bind-utils, whois

dig voidlinux.org              # full answer, with the server that replied
dig +short voidlinux.org       # just the addresses
dig voidlinux.org MX           # mail servers (also NS, TXT, AAAA, …)
dig @9.9.9.9 voidlinux.org     # ask a specific DNS server
dig -x 1.1.1.1                 # reverse lookup
host voidlinux.org             # short form
whois voidlinux.org            # who registered the domain
cat /etc/resolv.conf           # DNS servers in use

iw and ethtool: link details

Packages: iw, ethtool

iw dev                          # Wi-Fi interfaces
iw dev wlan0 link               # the access point, signal and bitrate
sudo iw dev wlan0 scan | grep -E 'SSID|signal'   # nearby networks
ethtool eth0                    # Ethernet speed, duplex, "Link detected"
sudo ethtool -i eth0            # driver and firmware

rfkill list (from util-linux) shows whether Wi-Fi is blocked by a switch or key; rfkill unblock wifi lifts a software block.

curl, wget, lftp: downloading and uploading

Packages: curl, wget, lftp

curl -LO https://example.org/file.iso         # download, keep the name, follow redirects
curl -I https://example.org                   # headers only
wget -c https://example.org/file.iso          # download, resuming if interrupted
wget -r -np https://example.org/dir/          # a folder, recursively
lftp sftp://user@host                         # interactive FTP/SFTP client (mirror, get, put)
lftp -e 'mirror /remote/dir /local/dir; quit' ftp://user@host

ssh, scp, rsync, sshfs: working over SSH

Packages: openssh, rsync, fuse-sshfs

ssh user@host                                  # remote shell
scp file.img user@host:/backup/                # copy a file to another machine
rsync -aP /mnt/source/ user@host:/backup/      # copy a folder, with progress, resumable
rsync -aP --dry-run /mnt/source/ /mnt/target/  # show what would be copied, copy nothing
mkdir -p ~/remote && sshfs user@host:/data ~/remote   # mount a remote folder
fusermount3 -u ~/remote                        # unmount it

Copying a recovered disk image to another machine is often easier than finding a local disk big enough.

The SSH server is off. To let others in, see Network.

NFS and SMB shares

Packages: nfs-utils, cifs-utils

sudo mount -t nfs server:/export /mnt/share              # NFS
sudo mount -t nfs -o ro server:/export /mnt/share        # read-only
sudo mount -t cifs //server/share /mnt/share -o username=user          # Windows/Samba (asks for the password)
sudo mount -t cifs //server/share /mnt/share -o username=user,vers=3.0 # force SMB 3
sudo umount /mnt/share

Useful to save images and recovered files directly to a NAS or a Windows share.

tcpdump: capture traffic

Package: tcpdump · For networks you are authorized to monitor

sudo tcpdump -D                                  # interfaces you can capture on
sudo tcpdump -i eth0 -n                          # live, numeric addresses
sudo tcpdump -i eth0 -n port 53                  # only DNS
sudo tcpdump -i eth0 -n host 192.168.1.10        # only one host
sudo tcpdump -i eth0 -c 1000 -w capture.pcap     # save 1000 packets to a file
tcpdump -n -r capture.pcap                       # read a capture back

.pcap files open in Wireshark on another machine.

nmap: hosts and open ports

Package: nmap (Void’s “nonfree” repository) · For networks you are authorized to test

sudo nmap -sn 192.168.1.0/24                 # which hosts are up (no port scan)
nmap 192.168.1.10                            # the 1000 most common TCP ports
nmap -p 22,80,443 192.168.1.10               # only these ports
nmap -p- 192.168.1.10                        # all 65535 TCP ports (slow)
sudo nmap -sV 192.168.1.10                   # versions of the services found
sudo nmap -O 192.168.1.10                    # guess the operating system
nmap -Pn 192.168.1.10                        # scan even if it does not answer ping
nmap -oN scan.txt 192.168.1.0/24             # save the results

testssl.sh: audit a server’s TLS

Package: testssl.sh · For servers you are authorized to test

Checks a server’s TLS versions, ciphers, certificate and known weaknesses.

testssl.sh https://example.org          # the full check (takes minutes)
testssl.sh --quiet --vulnerable example.org:443   # only known vulnerabilities
testssl.sh --protocols example.org      # only which TLS versions it offers

ssh-audit: audit an SSH server

Package: ssh-audit · For servers you are authorized to test

Reports an SSH server’s version and algorithms, marking the weak ones.

ssh-audit example.org              # port 22
ssh-audit -p 2222 example.org      # another port

arp-scan: devices on the local network

Package: arp-scan · For networks you are authorized to test

sudo arp-scan -l                 # every device on the local subnet: IP, MAC, vendor
sudo arp-scan -I wlan0 -l        # on a specific interface

Finds devices that ignore ping, since every device must answer ARP.

nc and socat: raw connections

Packages: nmap (provides nc, which is ncat), socat

nc -zv 192.168.1.10 22                       # is the port open?
nc -l 9000 > received.img                    # receiver: listen on port 9000
nc 192.168.1.20 9000 < disk.img              # sender: send a file to it
socat - TCP:192.168.1.10:80                  # talk to a TCP port by hand
socat TCP-LISTEN:8080,fork TCP:10.0.0.5:80   # forward a local port to another host

nc here is Ncat (from the nmap package), not the OpenBSD netcat; the basic options above work in both. Data sent with nc is not encrypted; use ssh/rsync over untrusted networks.

iperf3: bandwidth

Package: iperf3

iperf3 -s                          # on one machine: server
iperf3 -c 192.168.1.10             # on the other: test upload to it (10 s)
iperf3 -c 192.168.1.10 -R          # test download (reverse)
iperf3 -c 192.168.1.10 -P 4 -t 30  # 4 parallel streams, 30 seconds

Tells a slow cable, switch port or Wi-Fi link apart from a slow server.

iftop and nethogs: who uses the network

Packages: iftop, nethogs

sudo iftop -i eth0 -n -P     # bandwidth per connection, numeric, with ports (q quits)
sudo nethogs eth0            # bandwidth per process

WireGuard and OpenVPN

Packages: wireguard-tools, openvpn

sudo wg-quick up ./wg0.conf        # bring up a WireGuard tunnel from a config file
sudo wg show                       # its state, peers and traffic
sudo wg-quick down ./wg0.conf
sudo openvpn --config client.ovpn  # an OpenVPN connection (Ctrl+C to stop)

NetworkManager can also import these: nmcli connection import type wireguard file wg0.conf (and type openvpn needs a plugin that is not installed).

links: web in a text console

Package: links

links https://voidlinux.org      # browse in the terminal (arrows, Enter; q quits)
links /usr/share/doc/d77orphaned/html/index.html   # this documentation, offline

Works without a graphical session. d77-docs opens this documentation in links on a console, or in Mullvad Browser in a graphical session.

ipcalc: subnets

Package: ipcalc

ipcalc 192.168.1.10/24         # network, broadcast, host range, mask
ipcalc 10.0.0.0/20             # how many hosts fit

Hardware and boot

Identify a machine’s hardware, check it under load, and look at (or fix) how it boots. For disk health, see smartctl.

ToolFor
inxia one-screen summary of the whole machine
lshw, hwinfo, dmidecodedetailed hardware inventory, serial numbers
lspci and lsusbPCI and USB devices, and their drivers
sensors and acpitemperatures, fans, battery
memtester and Memtest86+testing RAM
stress and fioload tests: CPU, memory, disk
cpuid and cpupowerCPU details and frequency
efibootmgr, efivar, os-proberUEFI boot entries, finding installed systems
chntpwWindows local accounts (reset a password)
lynissecurity audit of a Linux system
flashromreading and writing firmware chips
i2c-toolsthe internal I2C/SMBus buses

inxi: machine summary

Package: inxi · Writes to disks: no

inxi -b          # basic: system, CPU, machine, battery, graphics, network, drives
inxi -e          # expanded: adds audio, partitions, sensors, repositories, …
inxi -v 7        # the most detailed report
inxi -e -z       # hide serial numbers, IP and MAC addresses (for sharing the output)

lshw, hwinfo, dmidecode: hardware inventory

Packages: lshw, hwinfo, dmidecode · Writes to disks: no

sudo lshw -short                  # every device in a compact table
sudo lshw -class disk -class storage   # only disks and controllers
sudo lshw -html > hardware.html   # full report as a web page
sudo lshw -sanitize -short        # without serial numbers
hwinfo --short                    # another summary, grouped by type
sudo dmidecode -t system          # manufacturer, model, serial number, UUID
sudo dmidecode -t memory          # RAM slots, sizes, speeds
sudo dmidecode -s bios-version    # one value

dmidecode reads the firmware’s tables (SMBIOS): useful to identify a machine for an inventory or a warranty claim.

lspci and lsusb: PCI and USB devices

Packages: pciutils, usbutils · Writes to disks: no

lspci                 # PCI devices: graphics, network, storage, …
lspci -k              # with the kernel driver in use
lspci -nn             # with vendor:device IDs (to search for driver support)
lsusb                 # USB devices
lsusb -t              # USB tree, with drivers and speeds

A device with no “Kernel driver in use” line in lspci -k has no working driver, a common cause of missing Wi-Fi or graphics.

sensors and acpi: temperatures and battery

Packages: lm_sensors, acpi · Writes to disks: no

sensors              # CPU, chipset and drive temperatures, fan speeds
acpi -b              # battery level and state
acpi -V              # battery, AC adapter, thermal zones, cooling
upower -d            # battery details as the desktop sees them

sudo sensors-detect probes for more sensor chips; answer the questions with the defaults (Enter). The modules it finds are lost at reboot.

memtester and Memtest86+: testing RAM

Packages: memtester; Memtest86+ is in the boot menu

sudo memtester 1G 2      # test 1 GiB of free RAM, 2 passes

memtester tests only memory that Linux is not using. For a full test, reboot and choose Memtest86+ in the boot menu, and let it run at least one complete pass. Any error there means faulty RAM.

stress and fio: load tests

Packages: stress, fio · Writes to disks: fio only with write tests

stress -c 4 -t 300                  # 4 CPU workers for 5 minutes (watch "sensors" meanwhile)
stress -m 2 --vm-bytes 1G -t 120    # 2 memory workers of 1 GiB each
sudo fio --name=read --filename=/dev/sdX --rw=read --bs=1M --size=2G --direct=1 --readonly

The fio line measures sequential reads from a disk without writing to it (--readonly). A machine that shuts down or freezes under stress usually has a cooling or power problem.

Writes: fio with --rw=write or randwrite on a device overwrites it. Write tests only on a disk you can wipe.

cpuid and cpupower: CPU details

Packages: cpuid, cpupower · Writes to disks: no

lscpu                         # model, cores, threads, caches, flags (util-linux)
cpuid -1                      # everything the CPU reports, for one core
cpupower frequency-info       # frequency limits and the current governor
sudo cpupower frequency-set -g performance   # run at full speed (until reboot)

efibootmgr, efivar, os-prober: boot

Packages: efibootmgr, efivar, os-prober, and grub, grub-x86_64-efi for reinstalling a boot loader · Writes: efibootmgr changes firmware settings when told to

efibootmgr                 # UEFI boot entries and boot order
efibootmgr -v              # with the file each entry starts
efivar -l                  # all UEFI variables
sudo os-prober             # other operating systems installed on the disks

Missing or wrong boot entries are a common reason for “no bootable device” after a disk swap or a Windows update. efibootmgr can create, reorder and delete entries (-c, -o, -B).

Writes: efibootmgr options that change entries write to the firmware’s memory, not to disks; a wrong boot order can still make the machine boot into the wrong system. os-prober mounts partitions to look inside them; on disks under examination, mark them read-only first (blockdev).

chntpw: Windows local accounts

Package: chntpw · Writes to disks: yes, when you save a change

Lists the local accounts of a Windows installation and can clear a password or unlock an account. It works on the SAM file of the Windows partition, mounted read-write. Only on machines you are authorized to administer.

sudo ntfs-3g /dev/sdX3 /mnt                           # the Windows partition, read-write
cd /mnt/Windows/System32/config
sudo chntpw -l SAM                                    # list the accounts
sudo chntpw -u Administrator SAM                      # interactive menu for one account
sudo umount /mnt

In the menu, “Clear (blank) user password” and “Unlock and enable user account” are the usual choices; then q and y to save.

Windows must have been shut down fully (not hibernated or Fast Startup), or NTFS will not mount read-write safely. Accounts linked to a Microsoft account and BitLocker-encrypted drives are not handled this way.

lynis: security audit

Package: lynis · Writes to disks: only its log in /var/log

sudo lynis audit system          # audit the running system (the live system itself)

Lynis checks the system it runs on. To audit an installed Linux from d77orphaned, it has to run inside it (for example in a chroot); results from the live system describe d77orphaned, not the installed machine.

flashrom: read and write firmware chips

Package: flashrom · Writes: only with -w, to the firmware chip

A wrong write can leave the computer unable to start. Then it only recovers with an external programmer (a clip and a CH341A or similar). Have one at hand, and know the chip’s location, before writing. Never run a write on a laptop on battery alone, or on a machine you cannot afford to lose.

The internal programmer needs the (firmware tools) entry in the boot menu, which adds iomem=relaxed. The other entries keep the kernel’s protection of system memory.

Always read first

sudo flashrom -p internal                        # find the chip; writes nothing
sudo flashrom -p internal -r backup1.rom         # read it to a file
sudo flashrom -p internal -r backup2.rom         # read it again
sha256sum backup1.rom backup2.rom                # must be identical

If the two hashes differ, stop: the read is not reliable. Copy the backup off the stick: anything outside persistence is gone at the next boot.

Writing

sudo flashrom -p internal --wp-status            # is it write-protected?
sudo flashrom -p internal -w new.rom             # write, and verify automatically
sudo flashrom -p internal -v new.rom             # compare the chip with a file

On many machines the firmware blocks internal writes, or only some regions can be written: flashrom says so. Do not force it. Use an external programmer instead.

External programmers use the same commands with another -p, for example -p ch341a_spi.

Not verified yet on real hardware by this project, including whether a Libreboot or coreboot machine allows internal access.

i2c-tools: the I2C/SMBus buses

Package: i2c-tools · Writes: i2cset, and i2cdetect can disturb some devices

Lists the small chips on a computer’s internal bus: RAM SPD, sensors, and so on.

sudo modprobe i2c-dev        # the devices appear in /dev
sudo i2cdetect -l            # the buses
sudo i2cdetect 0             # which addresses answer on bus 0 (it asks to confirm)
sudo i2cdump 0 0x50          # read a chip's registers

Probing some chips can upset them, and writing to the wrong one (with i2cset) has been known to damage hardware, such as RAM SPD. Read only, unless you know exactly what the chip is.

Console

Everyday tools for working in a terminal, also on the text console and in the console-only boot.

ToolFor
mc and rangerfile managers in the terminal
tmux and screenseveral shells in one terminal; keeping jobs alive
htop, iotop, iostatprocesses, disk activity
ncdu and treewhat takes up space
lsof, strace, ltraceopen files, what a program is doing
pv and mbufferprogress and buffering in pipes
Archivestar, zip, 7z, zstd, cabextract, unp
gpgchecking signatures, encrypting files
minicom and tioserial consoles (routers, switches, boards)

mc and ranger: file managers

Packages: mc, ranger

mc           # Midnight Commander: two panels; F5 copy, F6 move, F3 view, F4 edit, F10 quit
ranger       # three columns with previews; arrows or h/j/k/l, q quits

In mc, copying a large folder (F5) shows progress and can be put in the background. Its viewer (F3) has a hex mode (F4 inside the viewer), and it can browse inside archives and over SFTP (Left/Right menu → “SFTP link”). mcedit file is its editor.

tmux and screen: terminals inside a terminal

Packages: tmux, screen

tmux                 # start a session
tmux new -s rescue   # … with a name
tmux ls              # sessions
tmux attach -t rescue

Inside tmux: Ctrl+b then c new window, n/p next/previous, % and " split, d detach (the session keeps running).

Run long jobs (a ddrescue copy, an image hash) inside tmux: they survive a closed terminal or an SSH connection that drops.

screen does the same with Ctrl+a instead of Ctrl+b (screen -S name, screen -ls, screen -r name).

htop, iotop, iostat: processes and disk activity

Packages: htop, iotop, sysstat

htop                   # processes, CPU and memory (F6 sort, F9 kill, q quit)
sudo iotop -o -P       # only processes doing disk I/O right now
iostat -dx 2           # per-disk utilisation every 2 seconds (%util near 100 = disk saturated)

ncdu and tree: disk space

Packages: ncdu, tree

sudo ncdu -x /mnt      # what takes space under /mnt, without crossing into other file systems
tree -L 2 /mnt         # folder structure, two levels deep
tree -h --du /mnt      # with sizes

lsof, strace, ltrace: what programs are doing

Packages: lsof, strace, ltrace

lsof /mnt                   # which processes keep files open there ("target is busy")
lsof -i                     # network connections and listening ports
strace -f -e trace=file program   # files a program tries to open
sudo strace -p 1234         # attach to a running process
ltrace program              # library calls

umount: target is busy → lsof /mnt shows what to close.

pv and mbuffer: progress in pipes

Packages: pv, mbuffer

pv disk.img | zstd -T0 > disk.img.zst          # compress with a progress bar
sudo pv /dev/sdX > /mnt/target/disk.img        # copy a (healthy) disk with progress
pv -p disk.img | ssh user@host 'cat > disk.img'   # send over SSH with progress

For failing disks, use ddrescue instead. mbuffer smooths transfers between slow and fast ends (tape, network).

Archives: tar, zip, 7z, zstd, cabextract, unp

Packages: tar, zip, unzip, p7zip, zstd, lz4, lzop, cabextract, unp

tar -cf - folder | zstd -T0 > folder.tar.zst   # pack and compress with all cores
tar -xf folder.tar.zst                          # unpack (tar detects the compression)
zip -r folder.zip folder                        # zip, readable everywhere
unzip -l file.zip                               # list without extracting
7z x file.7z -o/mnt/target/out                  # extract 7z (also rar, iso, …)
7z t file.7z                                    # test an archive
zstd -d file.zst                                # decompress zstd
cabextract file.cab                             # Windows .cab files
unp file.anything                               # unpack whatever format it is

gpg: signatures and encryption

Package: gnupg

gpg --verify file.sig file          # check a detached signature (needs the signer's key)
gpg --import key.asc                # import a public key
gpg -c file                         # encrypt with a passphrase → file.gpg
gpg -d file.gpg > file              # decrypt

Encrypt recovered data with gpg -c before carrying it on a USB stick.

minicom and tio: serial consoles

Packages: minicom, tio

For the console port of routers, switches, servers and development boards, usually through a USB serial adapter (/dev/ttyUSB0).

tio -l                          # serial devices found
sudo tio /dev/ttyUSB0           # connect at 115200 baud (Ctrl+t q quits)
sudo tio -b 9600 /dev/ttyUSB0   # at 9600 baud
sudo minicom -D /dev/ttyUSB0 -b 9600   # the same with minicom (Ctrl+a x quits)

Install when you need them

These tools are large, and most people never need them, so they are not in the image. They install in a few minutes on the running system, with a network.

ToolForMemory it takes
rclonecloud storage: copying files to and from itabout 140 MB
tshark and termsharkanalysing network capturesabout 220 MB
johntesting and recovering passwordsabout 80 MB
clamavscanning for malwareabout 220 MB, plus its signatures
sudo xbps-install -S rclone

What you should know

  • They live in memory, and vanish at reboot. The running system is held in RAM, and persistence keeps files and settings, not packages. So you reinstall each time.
  • Make sure you have the memory. The numbers above were measured in a virtual machine, and include the downloaded package. All of them, with ClamAV’s signatures, took about 770 MB. On a machine with little RAM, install only what you need, and sudo xbps-remove -O afterwards frees the downloaded packages.
  • They need the network (see Network), unless you built your own image containing them (see Building).

All installed and run in a virtual machine from this image, except as each page notes.

rclone: cloud storage

Install: sudo xbps-install -S rclone (about installing) · Writes: to the destination you name

Copies files to and from cloud storage (Google Drive, S3, OneDrive and many others), often the quickest way to get rescued files off a machine.

rclone config                              # set up a remote, interactively; here called "drive"
rclone lsd drive:                          # its folders
rclone ls drive:Rescue                     # its files
rclone copy -P /mnt/rescue drive:Rescue    # copy, with progress
rclone copy --dry-run /mnt/rescue drive:Rescue    # show what it would do
rclone check /mnt/rescue drive:Rescue      # do both sides match?

sync deletes. It makes the destination identical to the source, removing what is not in the source. Use copy unless you mean that.

The configuration holds your access to the account. Without persistence it vanishes at reboot. Set it up again each time.

Installed, and its options checked against its help. Not tested with a real cloud account.

tshark and termshark: analysing captures

Install: sudo xbps-install -S wireshark termshark (about installing) · For networks you are authorized to test

tshark is Wireshark for the console, and comes in the wireshark package. termshark is a full-screen interface over it. To only capture, you do not need either: tcpdump is in the image, and you can analyse the file later on another computer.

sudo tshark -D                                  # the interfaces
sudo tshark -i eth0 -c 100                      # capture 100 packets
sudo tshark -i eth0 -f "port 53" -w dns.pcapng  # a capture filter, to a file
tshark -r dns.pcapng                            # read a file
tshark -r dns.pcapng -Y "dns.qry.name contains example"     # a display filter
tshark -r dns.pcapng -T fields -e ip.src -e dns.qry.name    # only some fields
termshark -r dns.pcapng                         # explore a file, full screen
sudo termshark -i eth0                          # capture live

The graphical program is a separate package, wireshark-qt. It was not tested here.

Installed. Tested: tshark -r on a tcpdump capture. Other options checked against the help. termshark was not run with a capture.

john: testing and recovering passwords

Install: sudo xbps-install -S john (about installing) · Only for your own systems and files, or with authorization

John the Ripper tries many passwords against a password hash until one matches. It is for recovering a forgotten password, or checking whether a system’s passwords are weak.

sudo john --wordlist=/usr/share/john/password.lst --format=crypt hashes.txt
sudo john --show hashes.txt                 # what it found so far
john --list=formats                         # the hash types it knows

hashes.txt holds lines like those in /etc/shadow: user:$6$.... Linux hashes ($6$) need --format=crypt.

Using a password you did not know, on an account or file that is not yours, is a crime in most places.

Installed and tested: it found a test password in a SHA-512 hash, with that command. For files such as ZIPs, john’s converters were not tested.

clamav: scanning for malware

Install: sudo xbps-install -S clamav (about installing) · Writes to disks: not unless you ask it to move or remove files

Scans files for known malware, such as a Windows disk you are recovering files from.

sudo freshclam                                   # download the signatures, first
sudo mkdir -p /mnt/win
sudo mount -o ro,noload /dev/sdXn /mnt/win       # ext4; NTFS: see below
sudo clamscan -r -i /mnt/win                     # the whole tree; only list what it finds

On NTFS: sudo ntfs-3g -o ro /dev/sdXn /mnt/win (NTFS).

Exit code 0 means nothing found, and 1 means it found something. A clean result does not prove a disk is clean: it knows only what is in its signatures. On evidence, avoid --move and --remove.

The signatures are large, and vanish at reboot along with the program. To avoid downloading them each time, keep them in persistence:

sudo mkdir -p /mnt/d77-data/clamav
sudo freshclam --datadir=/mnt/d77-data/clamav
sudo clamscan -d /mnt/d77-data/clamav -r -i /mnt/win

Installed and tested: freshclam downloaded the signatures, and clamscan detected the EICAR test file. Scanning takes 10 seconds or more just to load them. Keeping signatures in persistence was not tested.

Network

Wired

NetworkManager starts at boot and connects a wired network by itself (DHCP). Check with:

ip -br addr
ping -c 3 voidlinux.org

Verified in a virtual machine: address, route and DNS were set automatically.

The clock is set over the network by chronyd, which also runs at boot.

Wi-Fi

Use nmtui (menus) or nmcli:

nmcli device wifi list
nmcli device wifi connect "NetworkName" password 'the passphrase'

In the wasp session, Utumno’s network indicator shows the connection. More in nmcli and nmtui.

Some Wi-Fi cards need firmware that is not free software; the image has the firmware from Void’s linux-firmware package only.

Tested on real hardware by the user (Wi-Fi works with the right NetworkManager commands); not verified on other machines.

dhcpcd and wpa_supplicant are still installed for manual use, but not started at boot, so they do not compete with NetworkManager.

Staying offline

To examine a machine without touching any network, turn networking off before connecting a cable: nmcli networking off (and on to come back).

Nothing listens

No network service is running: the system listens on no TCP port. Check with ss -tlnp.

SSH server

sshd is installed but not enabled. The passwords are the same on every copy of the ISO, so change them first:

sudo passwd anon
sudo passwd root
sudo ln -s /etc/sv/sshd /var/service/

sudo sv up sshd does not work on its own: the service has to be linked into /var/service first, as above. To stop it again, remove the link: sudo rm /var/service/sshd.

Privacy

Utumno’s bar normally fetches the weather from wttr.in when the wasp session starts. That would tell an outside service your public IP address, so d77orphaned blocks it (/etc/hosts). The bar shows “weather unavailable”; this is expected.

Emergency procedures

For when something has gone wrong, and you need the steps rather than the tools.

What happenedGo toWrites to the disk?
The computer no longer startsThe computer does not bootyes, the boot loader
Strange noises, read errors, files vanishingThe disk is dyingno, only to the copy
A partition disappearedI deleted a partitionyes, the partition table
A locked Windows diskI need the files from a BitLocker diskno
Bigger disk, or a new computerI want to move to another diskyes, the new disk
The computer changes handsI am giving this computer awayyes, everything

Before anything else

  1. Stop using the disk. Every write can destroy what you hope to recover. Do not run fsck, and do not reinstall, before you have read the procedure.

  2. Do you have a copy of what matters? If not, and the data is worth more than the machine, copy the disk first.

  3. Identify the disk by model and serial, not by letter: sdX can change between boots.

    lsblk -d -o NAME,SIZE,MODEL,SERIAL,TRAN
    
  4. Save your work outside the live system. Files in the running system, such as images, are in memory and vanish at reboot.

d77orphaned does not touch a disk until you tell it to. These procedures do tell it to, and each one says where.

When to stop

Stop and get professional help if the data is irreplaceable and the disk clicks, grinds, or is not detected. Each attempt can make a physical failure worse, and a data recovery lab has better chances with a disk nobody has kept running.

How far these were tested

Each page says what was tested. “In a virtual machine” means on disposable disks, with simulated faults: real failures are messier.

The computer does not boot

Writes to the disk: yes, the boot loader and its configuration. Your files are not touched, but copy them first if the disk is at all suspect.

This page is for a Linux system whose boot loader is gone or broken, after a disk swap, a Windows reinstall, or a failed update. It reinstalls GRUB from inside the installed system.

1. Find out what you have

Boot d77orphaned and look:

lsblk -o NAME,SIZE,FSTYPE,LABEL,PARTLABEL,MOUNTPOINT
sudo os-prober
[ -d /sys/firmware/efi ] && echo UEFI || echo BIOS

The last line says how d77orphaned started, which is how you should start it for the repair: the computer should boot the stick in the same mode as the installed system.

You are looking for the system’s root partition, its /boot if separate, and on UEFI the EFI System Partition (vfat, usually 100 MB to 1 GB).

2. Mount the system

Plain partition, replacing sdXn with what you found:

sudo mount /dev/sdXn /mnt

Encrypted, with LVM, which d77orphaned never opens by itself:

sudo cryptsetup open /dev/sdXn cr
sudo vgchange -ay vg0              # your volume group: see `sudo vgs`
sudo mount /dev/vg0/root /mnt

Then whichever exist, in this order:

sudo mount /dev/sdXb /mnt/boot             # a separate /boot
sudo mount /dev/sdXe /mnt/boot/efi         # the EFI partition (or /mnt/efi: see the system's /etc/fstab)

Check with cat /mnt/etc/fstab that this matches what the system expects.

3. Enter the system

sudo xchroot /mnt /bin/bash

xchroot sets up /dev, /proc, /sys and DNS, and undoes them when you leave. From here on, commands run with the installed system’s own programs, so its grub is the one used.

4. Reinstall the boot loader

BIOS, on the whole disk (sdX, not sdX1):

grub-install --target=i386-pc /dev/sdX

UEFI:

grub-install --target=x86_64-efi --efi-directory=/boot/efi --removable --no-nvram

--removable puts GRUB in the fallback location that firmware looks in by itself, so this works even if the firmware’s boot entries were lost, and it needs no changes to them. Some firmware prefers a named entry, which is what happens without those two options, with --bootloader-id=Void. That form was not tested.

Then rebuild the menu, by distribution (only Void was tested):

SystemCommand
Voidgrub-mkconfig -o /boot/grub/grub.cfg
Archgrub-mkconfig -o /boot/grub/grub.cfg
Debian, Ubuntuupdate-grub
Fedoragrub2-mkconfig -o /boot/grub2/grub.cfg, and grub2-install above

If the initramfs is also suspect, rebuild it. On Void: xbps-reconfigure -f linux6.18 (your version: see ls /usr/lib/modules).

5. Leave and restart

exit
sudo umount -R /mnt
sudo vgchange -an vg0 && sudo cryptsetup close cr     # only if you opened them
sudo reboot

If it still does not boot

  • Check the firmware’s boot order, and on UEFI, efibootmgr -v (more).
  • Windows is on another disk or in the same firmware? Its loader can be the one starting first.
  • GRUB’s own prompt (grub>) usually means the configuration, not the loader: repeat the grub-mkconfig step, and check /boot was mounted.
  • If the system was installed in the other mode, BIOS or UEFI, change the firmware back rather than converting the system.

Tested in a virtual machine, with Void Linux installed on a test disk, on both a plain ext4 root and LUKS2 + LVM with a separate /boot. The boot loader and EFI directory were destroyed so the disk no longer started; after this procedure it booted with both BIOS and UEFI. Not tested: real firmware, an encrypted /boot, a named UEFI entry, other distributions, or dual-boot with Windows.

The disk is dying

Writes to the disk: none to the failing disk. All writes go to the healthy disk you choose.

Signs: read errors, a system suddenly slow or freezing, files that vanish, SMART warnings, clicks. Copy first, diagnose later. Every hour running can be one of the last, so do not run long tests, fsck, or defragmentation.

1. You need another disk

At least as big as the failing disk, and healthy. Mount it, read-write on purpose:

lsblk -d -o NAME,SIZE,MODEL,SERIAL,TRAN      # identify both disks
sudo mount /dev/sdYn /mnt/target

2. A quick look, without stressing it

sudo smartctl -H -A /dev/sdX                 # verdict and attributes
sudo smartctl -l error /dev/sdX              # the errors it remembers

A failed verdict confirms it. A passed verdict does not clear it: drives often fail without warning. Do not start a long self-test on a disk you suspect. See smartctl, or nvme.

3. Copy it

# First pass: what reads easily, leaving the bad areas for later
sudo ddrescue -n /dev/sdX /mnt/target/disk.img /mnt/target/disk.map

# Second pass: back to the bad areas, 3 retries
sudo ddrescue -d -r3 /dev/sdX /mnt/target/disk.img /mnt/target/disk.map

Source first, then the image. Swapping them overwrites the disk you are saving. Keep the map file: if the disk disappears or the power goes, the same command carries on from where it stopped. If the disk drops off, power it off for a while, then resume. See ddrescue.

To see how much was lost:

ddrescuelog -t /mnt/target/disk.map

4. Get the files from the image

From here on, work only on the image, and leave the failing disk alone.

sudo losetup -rPf --show /mnt/target/disk.img     # prints /dev/loopN; -r: read only
sudo mount -o ro,noload /dev/loopNp1 /mnt/rescue  # ext4; for XFS: ro,norecovery

If a file system does not mount, work on a second copy of the image with fsck or TestDisk; photorec recovers files by their contents when nothing else does.

Encrypted disks

Copy the whole disk the same way. Then open the image: the same cryptsetup open /dev/loopNpM cr. Bad sectors in a LUKS header can make the whole volume unreadable, which is why a header backup is worth having beforehand.

Tested in a virtual machine: a disk with 64 unreadable sectors simulated with device-mapper. Both passes completed, the map recorded the bad area, and the image mounted read-only with the files identical. Not tested on a disk really failing, where reads can hang and the disk can disappear.

I deleted a partition

Writes to the disk: yes, the partition table, at the very end and only when you say so. Your files are usually still there: deleting a partition removes its entry in the table, not the data.

Do not create new partitions, format, or install anything on that disk. That is what really destroys the data.

1. Work on a copy, if you can

sudo ddrescue /dev/sdX /mnt/target/disk.img /mnt/target/disk.map

Repair the copy, confirm your files are there, and only then repeat on the real disk. If you have nowhere to copy it, you can run TestDisk on the disk directly, as it writes only at the end.

2. Find it with TestDisk

cd /mnt/target                     # it leaves testdisk.log here
sudo testdisk /log disk.img        # or /dev/sdX
  1. Choose the disk, and Proceed.

  2. Choose the partition table type yourself.

    On a GPT disk left with no partitions, TestDisk proposes Intel. Choosing that would replace your GPT with an MBR. Choose EFI GPT. If you are not sure which the disk had, sudo gdisk -l /dev/sdX says whether a GPT is present.

  3. Analyse, then Quick Search.

  4. Your partition appears in the list. Press P to list its files. If you see them, you have the right one. Press q to go back.

  5. With the arrows ← →, change its status: on GPT, from D (deleted) to P (primary); on MBR, * (bootable) or P. Then Enter.

  6. Write, then Y to confirm. Nothing has been written before this.

  7. Leave with Quit, and reboot if you repaired the real disk.

If Quick Search does not find it, try Deeper Search.

3. Check it

On an image:

sudo losetup -Pf --show disk.img       # prints /dev/loopN
sudo mount -o ro,noload /dev/loopNp1 /mnt/check

On the real disk, after rebooting:

sudo mount -o ro,noload /dev/sdXn /mnt/check

noload is for ext4; for XFS use norecovery, and for others simply ro.

If it was formatted, or TestDisk finds nothing

The partition’s file system is gone or overwritten. photorec recovers files by their contents, without their names or folders, to another disk.

Tested in a virtual machine, through TestDisk’s menus, on copies of a GPT disk and an MBR disk, each with an ext4 partition deleted: the partition came back with its files identical. Not tested: NTFS, or partitions overlapping others.

I need the files from a BitLocker disk

Writes to the disk: no, with the commands below.

Not tested. This project has no BitLocker disk to test with. This page comes from the documentation of cryptsetup and dislocker. Try it with a copy of the disk first, if you can.

You need the key

Without the password or the 48-digit recovery key, there is no way in. Windows users often have the recovery key in their Microsoft account (account.microsoft.com/devices/recoverykey), in their company’s directory, or on a printout or USB stick from when BitLocker was turned on.

A Windows computer that “is not encrypted” may be: many turn on device encryption by themselves. See if the partition is BitLocker:

lsblk -o NAME,SIZE,FSTYPE          # shows BitLocker

Option 1: cryptsetup

sudo blockdev --setro /dev/sdXn
sudo mkdir -p /mnt/windows
sudo cryptsetup open --type bitlk --readonly /dev/sdXn windows      # asks for the password or recovery key
sudo ntfs-3g -o ro /dev/mapper/windows /mnt/windows

Cleaning up:

sudo umount /mnt/windows
sudo cryptsetup close windows

Option 2: dislocker

When cryptsetup does not recognise the volume. See dislocker.

sudo mkdir -p /mnt/bitlocker /mnt/windows
sudo dislocker -r -V /dev/sdXn -p -- /mnt/bitlocker      # asks for the recovery key
sudo ntfs-3g -o ro /mnt/bitlocker/dislocker-file /mnt/windows

If Windows was only hibernated or “fast started”

NTFS is left marked as in use, and read-only mounting is the right thing to do anyway. Do not force a read-write mount: it can lose data still waiting to be written.

See NTFS.

I want to move to another disk

Writes to the disk: yes, everything on the new disk is replaced. The old disk is only read.

The simple way: copy the whole disk to a new one at least as big, then use the extra space. This keeps the partitions, the boot loader and the encryption.

1. Identify both disks

lsblk -d -o NAME,SIZE,MODEL,SERIAL,TRAN

Check the new one twice. Below, sdX is the old disk and sdY the new one.

2. Copy

sudo ddrescue -f /dev/sdX /dev/sdY /tmp/move.map

Source first. -f lets it write to a device, so swapping them destroys the old disk. Nothing on either disk may be mounted.

3. Use the extra space (GPT)

sudo sgdisk -e /dev/sdY                    # move the GPT's backup to the new end
sudo parted /dev/sdY resizepart N 100%     # grow the last partition: number N
sudo partprobe /dev/sdY
sudo e2fsck -f /dev/sdYN                   # check first
sudo resize2fs /dev/sdYN                   # grow ext4 to fill the partition

Only the last partition can grow this way. Others need moving first, with gparted. For other file systems: XFS uses xfs_growfs once mounted, Btrfs uses btrfs filesystem resize max once mounted. On LUKS or LVM there are more layers to grow, inside to out: cryptsetup resize, then pvresize, then lvextend, then the file system. That was not tested.

4. Do not keep both disks connected

The copy has the same IDs as the original, and systems can pick the wrong one or get confused. Remove the old disk, and keep it, untouched, until the new one has proven itself.

If you have to keep both, give the new one its own IDs (ext4):

sudo sgdisk -G /dev/sdY              # new GUIDs for the disk and partitions
sudo tune2fs -U random /dev/sdYN     # new file system UUID

But then the system’s /etc/fstab and boot configuration may point to the old IDs. Fix them through The computer does not boot.

Moving to a smaller disk

A whole copy will not fit. Copy the file systems instead, with fsarchiver or rsync -aHAX, then create the partitions and reinstall the boot loader.

A new computer

The copy usually boots, but check whether it uses BIOS or UEFI: the new computer has to support the same one. A system with its disk encrypted by a TPM will not unlock on another machine without the recovery key.

Tested in a virtual machine: an ext4 disk moved to a bigger one, with its files identical, its file system grown, and new IDs; and an installed Void system moved the same way, which then booted with both BIOS and UEFI. e2fsck can exit with code 1 here: that means it corrected something, which is fine. Not tested: XFS, Btrfs, LUKS or LVM growth, smaller disks, a different computer.

I am giving this computer away

Writes to the disk: yes, everything, permanently.

1. Before erasing

  • Copy what you want to keep, and check that the copy opens on another computer.

  • Sign out of what is tied to the machine: licences, cloud accounts, password managers. On Windows, save the BitLocker recovery key if you might need the old data.

  • Note down the disk’s model and serial for your records, if it matters.

  • Are you sure this is the disk? Check by model and serial, and disconnect any disk or USB stick you do not mean to erase.

    lsblk -d -o NAME,SIZE,MODEL,SERIAL,TRAN
    

2. Pick the method by disk type

The TRAN column above says how it is connected; sudo smartctl -i /dev/sdX says if it is solid state.

DiskDo this
Hard disknwipe: one pass is enough
SATA SSDATA Secure Erase
NVMe SSDNVMe sanitize or format
Encrypteddestroy the keys, then one of the above
USB-connectednwipe, and treat it as not guaranteed

Why not just nwipe on an SSD? An SSD keeps spare cells that overwriting cannot reach. Its own erase command can. The details are in Secure erasure and sanitization.

A laptop’s firmware often blocks the SATA command (“frozen”): the page tells you what to do.

3. Check it

  • After nwipe: its verification pass, and its log.
  • After a firmware erase: sudo cmp /dev/sdX /dev/zero usually reports it reads as zeros. Not every drive returns zeros. You are trusting the drive’s firmware.

4. If the disk leaves your hands and the data was sensitive

If a drive fails to erase, or the stakes are high, take it out and destroy it. A new disk costs less than the consequences.

5. What remains in the computer

Firmware may hold the owner’s name, passwords or boot entries: clear them in its setup. On a TPM machine, clear the TPM there too. Remove any stick you left in.

Tested: nwipe in a virtual machine and on real hardware. The firmware commands have not been run on real drives by this project.

Building the ISO

The ISO is built from the d77void/d77orphaned repository with mkorphaned.sh, a wrapper around mklive.sh from void-mklive.

Requirements

  • A Void Linux x86_64 (glibc) computer, and root.
  • A few GB free in the repository directory.
  • mtools, if the computer’s kernel cannot mount vfat images.

Build

From the repository root:

sudo ./mkorphaned.sh

The result is d77orphaned-live-x86_64-<date>.iso in the same directory, as with void-mklive. Options after -- go to mklive.sh, for example a different keyboard layout and language:

sudo ./mkorphaned.sh -- -k pt-latin1 -l pt_PT.UTF-8

Repositories

Besides the official Void repositories, the build uses:

  • the d77void repository on SourceForge, for pwm, wasp, Utumno, the greeter and Kantele;
  • Void’s nonfree repository, for nmap.

-n leaves both out, and -r <repository> adds one. Repositories given first take precedence. For example, to use packages you built yourself with xbps-src:

sudo ./mkorphaned.sh -n \
  -r /path/to/void-packages/hostdir/binpkgs/d77 \
  -r https://repo-default.voidlinux.org/current/nonfree

Packages already downloaded are cached in xbps-cachedir-x86_64/.

Documentation inside the image

When a checkout of d77void/orphaned-docs sits next to the d77orphaned repository (or D77_DOCS_DIR points to one) and mdbook is installed on the build computer, the build puts this documentation into the image: the website in /usr/share/doc/d77orphaned/html and the Markdown pages in /usr/share/doc/d77orphaned/md. Without them, the build warns and goes on.

The SOURCES file

Each build also writes d77orphaned-live-x86_64-<date>.SOURCES.txt next to the ISO, and puts the same file in the image at /usr/share/doc/d77orphaned/SOURCES.txt (mksources.sh, called from postsetup.sh). It is generated from the packages actually installed, so it always matches the ISO it comes with. Publish it together with the ISO.

The build does not touch your /boot

mklive.sh installs Memtest86+ into a helper directory that has no shell. When that happens, XBPS runs the package’s post-install script on the computer doing the build, and that script regenerates the computer’s own /boot/grub/grub.cfg (running os-prober on its disks as well). This comes from void-mklive.

The regenerated file is normally the same as an update-grub would make, but a build should not change the computer that runs it. mkorphaned.sh therefore runs the whole build in a private mount namespace, with an empty /boot. The script then has nothing to regenerate, and the build fails if the computer’s grub.cfg changes anyway.

Testing

tests/qemu-harness.py boots the ISO in QEMU (with KVM when available) and runs the test scenarios: boot menus, sessions, tools and disk integrity. See the repository’s README.md and docs/TEST_REPORT.md.

Common problems

Problems seen while testing, with their cause and what to do.

Black or garbled screen after booting

The graphics driver does not work with this display. Reboot and choose (graphics disabled) in the boot menu. If that fails too, choose (console only), which always gives a text console.

The session ended and a login screen appeared

That is the greeter: the automatic login happens only once per boot. Log in as anon with the password voidlinux, and pick pwm or wasp.

In versions before pwm 0.6.8, pwm sometimes quit right after starting (about one start in twenty), which dropped you to the greeter. pwm 0.6.8 fixes it.

With “graphics disabled”, logging out restarts pwm, and Ctrl+Alt+F2 does nothing

That is expected: on some computers, leaving X in this mode leaves a black screen for good. Use shutdown or reboot in pwm’s menu (super+x). See Sessions and logging in.

Utumno says “weather unavailable”

Expected: d77orphaned blocks the weather request on purpose. See Network.

No network

Wired networks connect by themselves. For Wi-Fi, use nmtui or nmcli device wifi connect …; see Network.

Programs crash at random, or SQUASHFS error / Input/output error

The system cannot read the USB stick reliably. Programs then fail in strange ways, such as a segmentation fault in su. Seen on an old laptop with a stick that works elsewhere. Try another USB port (no hubs), then the (RAM) boot entry, which copies the system to memory at boot. If it persists, run Memtest86+ from the boot menu. See also Download to check the stick.

nwipe’s screen is unreadable

In pwm’s terminal it is. See nwipe.

A disk does not show up as mounted

Nothing is mounted automatically, on purpose. See Working safely with disks.

sv up sshd fails

The service has to be linked into /var/service first. See Network.