You are not logged in.

#1 2014-11-12 04:58:35

cyberpsych0sis
Member
Registered: 2014-11-02
Posts: 47

Mounting an encrypted system (LUKS)

Background

My system is currently setup with two independent hard drives, each has it's own copy of arch. One is my main system and the other is an encrypted backup system. I find myself occasionally opening the backup system to do updates to certain files. To fascilitate this I've created the following entries to my .bashrc file

#encrypt/decrypt mount/umount
alias opened='cryptsetup luksOpen /dev/sdb2 vol'                                                                                                                     #unlocks encrypted volume on sdb2
alias closed='vgchange -a n ; cryptsetup luksClose vol'                                                                                                              #locks encrypted volume
alias mounted='mount /dev/mapper/vol-lvroot /mnt ; mount /dev/mapper/vol-lvvar /mnt/var ; mount /dev/mapper/vol-lvhome /mnt/home ; mount /dev/sdb1 /mnt/boot'        #mounts encrypted volumes
alias umounted='umount /mnt/var ; umount /mnt/home ; umount /mnt/boot ; umount /mnt/'                                                                                #umounts encrypted volumes

#rapid encryption/decryption and mount/umount
alias cry='opened && sleep 1 && mounted && sleep 1 && lsblk'                                                                                             #opens volume, waits, mounts volume, waits, and then prints lsblk to verify mounting
alias ucry='umounted && sleep 1 && closed && sleep 1 && lsblk'                                                                                           #umounts volume, waits, closes volume, waits, and then prints lsblk to verify unmounting
Questions

How would you stream line this process yourself?
What solutions to this problem would you implement?
Is there a way to do this more "elegantly"?
I'm relatively new to the process of writing bash scripts and would greatly appreciate any suggested reading or other information you could recommend.

And lastly, what risks would be involved in running these scripts as the root user as apposed to using sudo?

Last edited by cyberpsych0sis (2014-11-12 05:04:40)

Offline

#2 2014-11-12 05:02:05

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: Mounting an encrypted system (LUKS)

Move it out of your .bashrc and make it a script, rather than a series of aliases (alii?).

Read everything on the Wooledge Wiki: it is the best bash resource on the web...


Not a Sysadmin issue, moving to NC.


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

Board footer

Powered by FluxBB