ExternalUSB+LUKS+LVM: Difference between revisions
Jump to navigation
Jump to search
(New page: cryptsetup luksFormat /dev/sdb cryptsetup luksOpen /dev/sdb external pvcreate /dev/mapper/external vgcreate vg-backup /dev/mapper/external lvcreate -l 17884 vg-backup mkfs.ext4 -m 0 /dev/v...) |
m (Drew moved page ExternalUSBEncryptedLVM to ExternalUSB+LUKS+LVM) |
||
(5 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
cryptsetup luksFormat /dev/sdb | Format the drive for encryption, supply pass or key.. | ||
<syntaxhighlight lang=bash> | |||
# cryptsetup luksFormat /dev/sdb | |||
</syntaxhighlight> | |||
mount /dev/ | Open and mount the drive, it will be available at /dev/mapper/external | ||
<syntaxhighlight lang=bash> | |||
# cryptsetup luksOpen /dev/sdb external | |||
</syntaxhighlight> | |||
Create LVM (PV, VG, LV), format as ext4 reserving 0% for root, and mount the drive. | |||
<syntaxhighlight lang=bash> | |||
# pvcreate /dev/mapper/external | |||
# vgcreate vg-backup /dev/mapper/external | |||
# lvcreate -l 17884 vg-backup | |||
# mkfs.ext4 -m 0 /dev/vg-backup/lvol0 | |||
# mount /dev/vg-backup/lvol0 /mnt/backup | |||
</syntaxhighlight> | |||
cryptsetup luksClose /dev/ | To unmount; | ||
<syntaxhighlight lang=bash> | |||
# umount /mnt/backup | |||
# lvchange -a n /dev/vg-backup/lvol0 | |||
# vgchange -a n vg-backup | |||
# cryptsetup luksClose /dev/mapper/external | |||
</syntaxhighlight> | |||
To mount; | |||
<syntaxhighlight lang=bash> | |||
# cryptsetup luksOpen /dev/sdb | |||
# mount /dev/vg-backup/lvol0 /mnt/backup | |||
</syntaxhighlight> | |||
Research: What is the best way to remove LVM's left over device files. | |||
rsync -avn --delete --log-file=/root/raid5_backup.log --exclude drew/video /mnt/raid5/ /mnt/backup | |||
Rsync backup; | |||
This is a '''dry run''' which will delete files not on the source, log everything to ~/backup.log, exclude a video directory from all files named /mnt/raid5 to /mnt/backup. | |||
<syntaxhighlight lang=bash> | |||
# rsync -avn --delete --log-file=/root/raid5_backup.log --exclude drew/video /mnt/raid5/ /mnt/backup | |||
</syntaxhighlight> | |||
The real deal. | |||
<syntaxhighlight lang=bash> | |||
# rsync -av --delete --log-file=/root/raid5_backup.log --exclude drew/video /mnt/raid5/ /mnt/backup | |||
</syntaxhighlight> |
Latest revision as of 08:42, 10 May 2020
Format the drive for encryption, supply pass or key..
# cryptsetup luksFormat /dev/sdb
Open and mount the drive, it will be available at /dev/mapper/external
# cryptsetup luksOpen /dev/sdb external
Create LVM (PV, VG, LV), format as ext4 reserving 0% for root, and mount the drive.
# pvcreate /dev/mapper/external
# vgcreate vg-backup /dev/mapper/external
# lvcreate -l 17884 vg-backup
# mkfs.ext4 -m 0 /dev/vg-backup/lvol0
# mount /dev/vg-backup/lvol0 /mnt/backup
To unmount;
# umount /mnt/backup
# lvchange -a n /dev/vg-backup/lvol0
# vgchange -a n vg-backup
# cryptsetup luksClose /dev/mapper/external
To mount;
# cryptsetup luksOpen /dev/sdb
# mount /dev/vg-backup/lvol0 /mnt/backup
Research: What is the best way to remove LVM's left over device files.
Rsync backup; This is a dry run which will delete files not on the source, log everything to ~/backup.log, exclude a video directory from all files named /mnt/raid5 to /mnt/backup.
# rsync -avn --delete --log-file=/root/raid5_backup.log --exclude drew/video /mnt/raid5/ /mnt/backup
The real deal.
# rsync -av --delete --log-file=/root/raid5_backup.log --exclude drew/video /mnt/raid5/ /mnt/backup