Jump to content
Sign in to follow this  
golli53

Quick command to back up all LUKS headers

3 posts in this topic Last Reply

Recommended Posts

Wrote this after a potential nightmare when mounting a cache drive with an extra empty slot erased my LUKS header

 

Run in ssh from whichever directory you want to store the headers. Will be automatically named with model and serial numbers. Finishes in a few seconds

for i in {/dev/sd*,/dev/nvme*}; do if cryptsetup luksDump $i &>/dev/null; then dd if=$i of=`udevadm info --query=all --name=$i | sed -n 's/.*ID_SERIAL=//p'`.img bs=512 count=4096; fi; done

 

Share this post


Link to post

Excellent idea;
I may make a script to back up superblock information as well; as that could be used to recover a lot of data in the event of multiple disk failures.
Should be fine without though.

Share this post


Link to post

What would we add to have it also grab LUKS headers from unassigned disks mounted?

 

Correction, it seems to already do unassigned disks.  Awesome...

Edited by tr0910

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this