LUKS
Jump to navigation
Jump to search
https://opensource.com/article/21/4/linux-encryption
Ubuntu
dd if=/dev/urandom of=vaultfile.img bs=1M count=512 sudo apt install -y cryptsetup-initramfs cryptsetup --verify-passphrase luksFormat vaultfile.img
mounting in wsl2
cd /tmp mkdir mnt dd if=/dev/urandom of=foo2.img bs=1M count=512 mkfs ext2 -F foo2.img mount -o loop foo2.img /tmp/mnt umount mnt
More
#!/bin/bash FILENAME="private.img"; FILESIZE="100M"; # Create encrypted volume if it doesn't exist if [ ! -f $FILENAME ]; then echo "Creating image file..."; dd if=/dev/zero of=$FILENAME bs=$FILESIZE count=0 seek=1 echo "Setting permissions..."; chmod 600 $FILENAME; echo "Mounting image file..."; sudo losetup -D; sudo losetup /dev/loop0 $FILENAME; echo "Encrypting image file..."; sudo cryptsetup -q -y luksFormat /dev/loop0; echo "Opening encrypted volume..."; sudo cryptsetup luksOpen /dev/loop0 encrypted; echo "Zeroing encrypted volume..."; sudo dd if=/dev/zero of=/dev/mapper/encrypted; echo "Formatting encrypted volume..."; sudo mkfs.ext4 -L "encrypted" /dev/mapper/encrypted; echo "Closing encrypted volume..."; sudo cryptsetup luksClose /dev/mapper/encrypted; sudo losetup -D; fi echo "Mounting image file..."; sudo losetup -D; sudo losetup /dev/loop0 $FILENAME; echo "Decrypting image file..."; sudo cryptsetup luksOpen /dev/loop0 encrypted; echo "Mounting encrypted volume..."; sudo mount /dev/mapper/encrypted /mnt/encrypted; vim -i NONE -c 'set noswapfile' -c 'set nobackup' -c 'set noundofile' --cmd 'set undodir=/dev/null' /mnt/encrypted/; echo "Unmounting encrypted volume..."; sudo umount /mnt/encrypted; echo "Closing encrypted volume..."; sudo cryptsetup luksClose /dev/mapper/encrypted; echo "Unmounting image file..."; sudo losetup -D;