Table of Contents

Files management

Partitioning

Cheatsheet for preparing and a new disk and using it with:

Creation

This section presents how to use each tool, in a given order, but depending on the use case you may want to skip some layers, or apply them in a different order. In particular:

Partitions

LVM

LUKS

Filesystem

Sub-volumes

Some filesystems such as BTRFS and ZFS allow to create subvolumes.

Usage

Open

Close

Backup

Maintenance

Renaming / Updating

Checks

Backup

Disk usage

Defragmentation

Compression

SSD TRIM

Source : https://wiki.archlinux.org/title/Solid_state_drive

Resizing

TODO

Backup

Everyone has personal data that nothing could recreate (pictures, emails, creations, …), or global data and configuration that it would take a lot of time to recreate. However you can lose some of them or all of them in several situations: hard drive crash, hard drive corruption, computer theft, computer destruction (fire…).

My advice:

Tools

rsync

Borg Backup

Restic

BTRFS snapshots

The BTRFS filesystem allows to perform some sorts of backups:

Container files

Sources:

Digital Will

The goal is threefold:

Different approaches:

  1. A service that gives your data to designated persons when they provide a death certificate for you (Wishbook, …)
    • Cons: sending a fake document, does not work for coma, service needs to remain available, price, incomplete control.
    • Variants: store it directly in a vault at the bank, or at the notary.
  2. A service that regularly checks that you are alive by requesting a connection with your private credentials (period can be adapted to the situations), and gives your data when you fail to do it, after warning emails (can be self-hosted).
    • Cons: there will be some delay between when you stop pinging and when your data becomes available, service needs to remain available, and if you host it yourself there is still a risk that your server crashes at the wrong time.
  3. A service that waits for a request to reveal your data with a personal password, sends you one or several emails to warn you that this request has been made, and in the absence of opposition from you in some delay (that can be adapted to the situation) sends your data (can be self-hosted).
    • Cons: there will be some delay between when you stop pinging and when your data becomes available, service needs to remain available, or if you host it yourself there is still a risk that your server crashes at the wrong time (but if the service is associated to your password manager for instance, then the availability is not a problem anymore…)
  4. Split the secret between several people (cf Shamir's secret, implemented for instance in ssss or libgfshare), so that X out of Y need to agree to obtain your data.
    • Cons: people need to remain accessible (and not loose the information), compromise between robustness and risk of conspiracy, what data can each person access
  5. Store your key on a piece of opaque paper (eg visit card), with you (eg in your smartphone), wrapped in a unique piece of paper (eg journal paper) that is glued. The goal is that it is impossible to read the key (eg through light) without removing the wrapping paper, impossible to remove it without tearing it apart, impossible to replace it without you noticing quickly. This base key then has to be derived a large number of times, so that it takes several days with a classical computer to derive the final key, which the designated persons then can use to decrypt their personal message. In case of unauthorized attempt, you can change the password. A better solution could be to use a proper TLP (Time Lock Problem) / TLE (Time Lock Encryption) / VDF (Verifiable Delay Function) / Delayed encryption, which would have the big advantage of fast generation, but it doesn't seem to exist standard implementations, even of seminal Rivest & Shamir proposal.
    • Cons: need to actively monitor the integrity of your artifact, doesn't work if you have an accident that destroys the artifact, need to revoke the information in case of unauthorized attempt (thus only revokable information is protected, such as passwords protecting data for which it is impossible to make an unauthorized copy beforehand), need to revoke the information in case of upgrade of the derivation scheme in order to follow hardware improvements.
    • Variant: it seems that it is possible to make “paint to scratch” with dishwashing soap and gouache, thus it can be an alternate way to hide while allowing to detect unauthorized access. Even if there is a tentative of reconstructing the paint layer, if a complex color mix was chosen, with approximate random borders, and even random color gradients, it would be very difficult to replicate accurately enough so that it goes unnoticed (especially if the color changes while drying).

Different methods could be combined, for instance 2 or 3 plus 4. But 3 managed by the password manager is probably unbeatable.

Ideally, for increased safety, the data to be obtained is always encrypted with a key that the designated persons possess.

What to transmit?

Notes:

File Systems

ext3, ext4

Reserved blocks

By default ext3 reserves 5% of disk space to super-user. The intent is to let to critical applications the ability to write to the disk when it is full, but it has no use for a data partition, you just waste 5% of your partition.

You can check and remove these reserved blocks with the following commands:

tune2fs -l /dev/sda1 | grep Reserved
tune2fs -r 0 /dev/sda1

Duplicates

Secure delete

Data recovery

First unmount your partition and remount it read-only.

Disk Recovery

In case the MBR/partition table of you disk is damaged.

Make a backup before

You should always keep a backup of your partition table !

The first way is to store the output of p command of fdisk.

You can also do a dump of the MBR and EBR:

dd if=/dev/sda of=sda.dd bs=512 count=1 # full MBR dump
sfdisk -d /dev/sda > sda.sfdisk         # MBR and EBR partition tables

Out of curiosity, the file command is able to interpret the content of your MBR dump:

file sda.dd

Restore with a backup

If you have the output of the p command of fdisk, then you can manually recreate the partition table with fdisk with the same information. As long as you don't mount or format, modifying the partition table with fdisk doesn't modify the partitions data.

If you have a full dump of MBR and EBR, you can automatically restore it:

dd if=sda.dd of=/dev/sda
sfdisk /dev/sda < sda.sfdisk

To restore the MBR without the partition table:

dd if=sda.dd of=/dev/sda bs=446 count=1

To restore only the partition table:

dd if=sda.dd of=/dev/sda bs=1 skip=446 count=66

Restore without a backup

If you don't have a copy of your partition info, don't panic, some software can recover them by searching for the partitions in the disk content (but it has to be formatted as a standard filesystem, ie not encrypted):

Performance optimization