1

Consider the following scenario for a laptop: Most of the time the laptop sits in its docking station on the desk but is occasionally taken out. Docking and undocking can happen while running or while the laptop is powered off.

Now laptops are prone to data loss in several ways: Spinning disks are sensitive to shocks (to which laptops are especially prone) whereas SSDs may fail spontaneously with no prior warning. And eventually, laptops can get lost or stolen while on the road.

To counter these risks, I have been thinking about an external drive hooked up to the docking station, and using LVM to configure a mirror set across both disks.

If the internal disk fails, I would simply get a new disk and restore the mirror set. As Linux is quite tolerant to the disk being “transplanted” into a different computer, this would work even if the laptop gets stolen and I have to get a new one, with only minor limitations. Restoring the system would be much easier than with a conventional external backup.

Obvious drawbacks: for one, this setup will not help if the laptop is stolen from your desk together with the external HD. Also, USB may be a bottleneck for disk performance. And finally, this setup offers no protection against logical data corruption for whatever reason. Let us leave those aside for now.

A particular characteristic of this setup is that failover and restore scenarios now become everyday occurrences, requiring them to be fully automated:

  • Operation continues as usual if the external disk becomes unavailable. In a hot-undock scenario, the system should continue running with no limitations. In a cold-undock scenario, the absence of one of the two disks should not prevent the system from booting normally (i.e. without intervention).

  • If the external disk becomes available again (both in a hot and cold dock scenario), the system should recognize that and immediately start re-syncing and restoring the mirror set, without any human intervention.

  • During re-sync, the system should be prepared to deal with being shut down (and resume on restart) or undocked (and start over when docked again).

Is such a setup feasible? Is LVM in Linux capable of automating these steps, or can they be scripted?

1
  • You could script it with mdadm & udev, the big question is whether it will re-sync everything or just the changed parts. The md raid bitmap feature can be picky as to when it trusts the drive to have good data or not. It's more common to do this with tar, rsync, borg, btrfs/zfs send, and other file(system) based utilities. And this would also allow you to use drives of different size, keep incremental backups / snapshots, checksumming etc. (logical errors as you say). Commented May 12, 2020 at 19:54

0

You must log in to answer this question.

Browse other questions tagged .