date int64 1,220B 1,719B | question_description stringlengths 28 29.9k | accepted_answer stringlengths 12 26.4k | question_title stringlengths 14 159 |
|---|---|---|---|
1,651,838,414,000 |
My Laptop froze and after a hard shutdown the boot process won’t accept my disk encryption password anymore.
I have a ‘standard’ luks-inside-lvm setup, generated while installing fedora, split in a /root, /home and /swap partition, which worked for several years.
Using a live USB system I can access the encrypted volumes and the data seems fine. I haven't had problems using it via chroot.
I ran fsck on the partition for good measure, fstab and crypttab seem fine and haven't changed compared to my backups.
cryptsetup --debug isLuks seems fine(Luks headers etc.).
As far as I can tell the boot messages don’t report anything, except for the errors related to the ‘wrong’ password.
I tried to look into journalctl, but the entries stop hours before the system freeze occured (using journalctl -D mounted-root/var/log/journalctl) but maybe I’m doing it wrong.
While trying to use a keyfile to unlock (which, again, works manually but not on boot, although the keyfile and the luks volume are found), I regenerated the initramfs, so that shouldn't be the problem aswell.
I honestly don’t know what else to look for, any help would be appreciated.
|
I just took out one of my RAMs and it magically works fine again. This seemed to be the cause for the freeze and for cryptsetup 'silently' failing.
| Encrypted LUKS volume does not accept password on boot after system freeze |
1,651,838,414,000 |
As the title says, I've made a backup of my system before sending my laptop for tech repairs, my system was encrypted and I used CloneZilla's beginner mode so as to not mess anything up. I received my computer today and I tried to restore the image made by CloneZilla on the machine. Everything looked like it worked, but when I try to boot the machine by selecting the main drive on the boot menu, nothing happens. It juste brings me back to the BIOS boot menu. I am not greeted with any Grub or LUKS decrypt screen. I'm at a loss of ideas for what to try next, any help is greatly appreciated.
I've also tried this: FreeBSD Clonezilla Not Restoring
and
Rescatux, but for reasons which i attribute to my drive being encrypted, it cannot fix any problem and only asks to install GRUB on external drives.
Edit to answer questions:
I am using EndeavourOS, an Arch Linux fork,
I cloned the entire disk and verified it. Also, I restored it on the exact same drive, therefore image vs drive sizes isn't an issue. Also, after unencrypting the partitions once in a live USB, I do seem to have access to the partitions themselves.
Perhaps it is an issue with GRUB not having been reinstalled when cloning?
Thanks.
|
It turns out that somehow my Secure Boot was enabled in my BIOS. Turning it off solved my entire problem. Turns out the repair shop reset some settings in the BIOS...
In brief, to solve the problem, go into BIOS and disable Secure Boot.
| Restored encrypted LUKS drive with CloneZilla makes system non-bootable |
1,651,838,414,000 |
Are there any backup/cloning/recovery tools that can pull files from LUKS-encrypted disks while dropping free blocks?
Something that runs from within the unlocked system and hot-transfers the files, or maybe runs from a bootable USB flash drive, prompts the encryption key, and unlocks the disk?
|
The fact that your disk is encrypted is largely irrelevant. Whatever you use will need the encrypted disk to be opened (cryptsetup luksOpen ...) before operation.
I'll also draw your attention to e2image which may copy more filesystem meta data. It only works with ext2,3,4 file systems.
Besides e2image, your only real option is to look at tools which copy file trees rather than blocks. For backups, I use rsync copy files.
Besides files, what else does your system need?
Partition definitions will not be backed up with rsync. Partitions sizes can be listed with with fdisk -l <disk> eg: fdisk -l /dev/sda and stored this in a file somewhere for safe keeping.
To boot up, you system will probably use UUIDs to know what file system mount's where. These can be listed with blkid (sudo blkid).
If your system is using EFI (rather than legacy boot) then you need to also copy the contents of your EFI partition.
| Backup tool for pulling files out of encrypted disks? |
1,651,838,414,000 |
I am attempting to add a new LUKS encrypted hard drive to my 18.04 setup.
I already have 3 drives (2 of which are RAID) that have LUKS and they work fine - when my computer boots, I get prompted to enter password, LUKS gets mounted and detected by LVM.
The problem I am encountering with this new drive is that I am able to mount LUKS manually when I have already booted (sudo cryptdisks_start sdd1_crypt), but it just won't mount at boot time - I don't get prompted for the password, and after boot the volume is not mounted.
My setup:
md0_crypt UUID=82f31819-4f0e-4745-adb2-002ea8264bdb none luks,discard
sda5_crypt UUID=95ba237d-ec61-455f-b4ca-5d258b1e1798 none luks,discard
sda5_crypt UUID=02a997cf-e33a-4990-b369-fb0f5843987f none luks,discard
sdd1_crypt UUID=cfd31853-d04b-4b6a-a697-4ac15d5eb9a7 none luks,discard
Where sdd1_crypt is the drive I am trying to mount on boot. The result of running blkid:
/dev/mapper/md0_crypt: UUID="Int6VP-Le2Z-YhAt-FgXD-M0sA-qf9i-bkH3dz" TYPE="LVM2_member"
/dev/mapper/sda5_crypt: UUID="1NNYpg-bSOL-qqXq-5e0H-RPCC-z53a-K2wmt4" TYPE="LVM2_member"
/dev/mapper/vg--primary-root: UUID="31bb6097-9b15-44a0-80bd-8069b0fa38f1" TYPE="ext4"
/dev/sda1: UUID="66254139-68eb-4ff1-907f-2ab59e2f44f1" TYPE="ext4" PARTUUID="224d3265-01"
/dev/sda5: UUID="95ba237d-ec61-455f-b4ca-5d258b1e1798" TYPE="crypto_LUKS" PARTUUID="224d3265-05"
/dev/sdb1: UUID="30d02b9a-91d7-f714-3215-ea30a9dd68dc" UUID_SUB="07cc112e-275e-be6b-0aea-3b32ce6fe77e" LABEL="sunblaze:0" TYPE="linux_raid_member" PARTUUID="eafaf0f2-01"
/dev/sdc1: UUID="30d02b9a-91d7-f714-3215-ea30a9dd68dc" UUID_SUB="41b67e4b-0238-5a92-24ff-2c3f5e517f73" LABEL="sunblaze:0" TYPE="linux_raid_member" PARTUUID="eafaf0f2-01"
/dev/sdd1: UUID="cfd31853-d04b-4b6a-a697-4ac15d5eb9a7" TYPE="crypto_LUKS" PARTUUID="558ca513-01"
/dev/md0: UUID="82f31819-4f0e-4745-adb2-002ea8264bdb" TYPE="crypto_LUKS"
/dev/mapper/vg--primary-swap: UUID="ef2a221c-aa2a-4d22-9b54-575369d1b30a" TYPE="swap"
/dev/mapper/vg--primary-var: UUID="d09b7b0e-d9b5-4542-b41c-e23c8a6e6a2d" TYPE="ext4"
/dev/mapper/vg--primary-home: UUID="f1663dec-808f-4dbe-a7ac-a57da086db0d" TYPE="ext4"
/dev/mapper/vg--primary-tmp: UUID="d8a314e4-29b0-4f04-b0be-249da807f78f" TYPE="ext4"
I have also run update-initramfs -u -k all after updating my crypttab.
It seems that I need to do something to trigger password prompt for sdd1_crypt at start time, similar to me getting prompted for md0_crypt and sda5_crypt, but I don't know what.
Content of `/etc/fstab"
# <file system> <mount point> <type> <options> <dump> <pass>
/dev/mapper/vg--primary-root / ext4 errors=remount-ro 0 1
# /boot was on /dev/sda1 during installation
UUID=66254139-68eb-4ff1-907f-2ab59e2f44f1 /boot ext4 defaults 0 2
/dev/mapper/vg--primary-home /home ext4 defaults 0 2
/dev/mapper/vg--primary-tmp /tmp ext4 defaults 0 2
/dev/mapper/vg--primary-var /var ext4 defaults 0 2
/dev/mapper/vg--primary-swap none swap sw 0 0
#/dev/mapper/vg--secondary-backups /backups ext4 defaults 0 2
When I load with the last line commented out (the volume that resides on the new disk I am trying to encrypt and load at boot), I see this in journalctl -b (it looks happy, but has no mention of sdd1_crypt:
Dec 11 18:08:30 server systemd[1]: Starting Cryptography Setup for sda5_crypt...
Dec 11 18:08:30 server systemd-cryptsetup[945]: Volume sda5_crypt already active.
Dec 11 18:08:30 server systemd-fsck[933]: /dev/mapper/vg--primary-home: clean, 707048/39321600 files, 146443846/157286400 blocks
Dec 11 18:08:30 server systemd[1]: Reached target Sound Card.
Dec 11 18:08:30 server systemd[1]: Activating swap /dev/mapper/vg--primary-swap...
Dec 11 18:08:30 server systemd[1]: Created slice system-lvm2\x2dpvscan.slice.
Dec 11 18:08:30 server kernel: Adding 19529724k swap on /dev/mapper/vg--primary-swap. Priority:-2 extents:1 across:19529724k FS
Dec 11 18:08:30 server systemd[1]: Starting LVM2 PV scan on device 253:5...
Dec 11 18:08:30 server lvm[947]: 5 logical volume(s) in volume group "vg-primary" now active
Dec 11 18:08:30 server systemd[1]: Starting LVM2 PV scan on device 253:0...
Dec 11 18:08:30 server systemd[1]: Starting Cryptography Setup for md0_crypt...
Dec 11 18:08:30 server systemd-cryptsetup[952]: Volume md0_crypt already active.
Dec 11 18:08:30 server systemd[1]: Activated swap /dev/mapper/vg--primary-swap.
Dec 11 18:08:30 server systemd[1]: Started File System Check on /dev/mapper/vg--primary-tmp.
Dec 11 18:08:30 server lvm[950]: 5 logical volume(s) in volume group "vg-primary" now active
Dec 11 18:08:31 server systemd[1]: Started File System Check on /dev/mapper/vg--primary-home.
Dec 11 18:08:31 server systemd[1]: Started File System Check on /dev/disk/by-uuid/66254139-68eb-4ff1-907f-2ab59e2f44f1.
Dec 11 18:08:31 server systemd[1]: Started File System Check on /dev/mapper/vg--primary-var.
Dec 11 18:08:31 server systemd[1]: Started Cryptography Setup for sda5_crypt.
Dec 11 18:08:31 server systemd[1]: Started LVM2 PV scan on device 253:5.
Dec 11 18:08:31 server systemd[1]: Started LVM2 PV scan on device 253:0.
Dec 11 18:08:31 server systemd[1]: Started Cryptography Setup for md0_crypt.
Dec 11 18:08:31 server systemd[1]: Started File System Check Daemon to report status.
Dec 11 18:08:31 server systemd[1]: Reached target Local Encrypted Volumes.
Dec 11 18:08:31 server systemd[1]: Mounting /var...
Dec 11 18:08:31 server systemd[1]: Mounting /boot...
Dec 11 18:08:31 server kernel: EXT4-fs (sda1): mounted filesystem with ordered data mode. Opts: (null)
Dec 11 18:08:31 server systemd[1]: Mounting /home...
Dec 11 18:08:31 server systemd[1]: Mounting /tmp...
Dec 11 18:08:31 server systemd[1]: Reached target Swap.
Dec 11 18:08:31 server systemd[1]: Mounted /boot.
Dec 11 18:08:31 server systemd[1]: Mounted /var.
Dec 11 18:08:31 server kernel: EXT4-fs (dm-2): mounted filesystem with ordered data mode. Opts: (null)
Dec 11 18:08:31 server kernel: EXT4-fs (dm-3): mounted filesystem with ordered data mode. Opts: (null)
Dec 11 18:08:31 server systemd[1]: Mounted /home.
Dec 11 18:08:31 server systemd[1]: Mounted /tmp.
When I uncomment the last line in fstab, I get (no mention of sdd1_crypt, but lvm mount fails, as expected):
Dec 11 20:13:02 server systemd[1]: Starting Cryptography Setup for md0_crypt...
Dec 11 20:13:02 server systemd-cryptsetup[934]: Volume md0_crypt already active.
Dec 11 20:13:02 server systemd[1]: Started Cryptography Setup for md0_crypt.
Dec 11 20:13:02 server systemd[1]: Reached target Local Encrypted Volumes.
Dec 11 20:13:02 server systemd-fsck[883]: /dev/sda1: clean, 321/61056 files, 51240/243968 blocks
Dec 11 20:13:02 server systemd[1]: Started File System Check on /dev/disk/by-uuid/66254139-68eb-4ff1-907f-2ab59e2f44f1.
Dec 11 20:13:02 server systemd[1]: Mounting /boot...
Dec 11 20:13:02 server systemd-fsck[896]: /dev/mapper/vg--primary-var: clean, 14762/6111232 files, 2194249/24413184 blocks
Dec 11 20:13:02 server systemd-fsck[931]: /dev/mapper/vg--primary-tmp: clean, 15/6111232 files, 530078/24413184 blocks
Dec 11 20:13:02 server systemd-fsck[930]: /dev/mapper/vg--primary-home: clean, 707046/39321600 files, 146447102/157286400 blocks
Dec 11 20:13:03 server systemd[1]: Mounted /boot.
Dec 11 20:13:03 server kernel: EXT4-fs (sda1): mounted filesystem with ordered data mode. Opts: (null)
Dec 11 20:13:03 server systemd-udevd[579]: Process '/usr/sbin/alsactl -E HOME=/run/alsa restore 1' failed with exit code 99.
Dec 11 20:13:03 server systemd[1]: Started File System Check on /dev/mapper/vg--primary-var.
Dec 11 20:13:03 server systemd[1]: Mounting /var...
Dec 11 20:13:03 server systemd[1]: Started File System Check on /dev/mapper/vg--primary-tmp.
Dec 11 20:13:03 server systemd[1]: Mounting /tmp...
Dec 11 20:13:03 server systemd[1]: Started File System Check on /dev/mapper/vg--primary-home.
Dec 11 20:13:03 server systemd[1]: Mounting /home...
Dec 11 20:13:03 server systemd[1]: Mounted /tmp.
Dec 11 20:13:03 server kernel: EXT4-fs (dm-4): mounted filesystem with ordered data mode. Opts: (null)
Dec 11 20:13:03 server kernel: input: HDA NVidia HDMI/DP,pcm=3 as /devices/pci0000:00/0000:00:03.0/0000:01:00.1/sound/card2/input5
Dec 11 20:13:03 server kernel: input: HDA NVidia HDMI/DP,pcm=7 as /devices/pci0000:00/0000:00:03.0/0000:01:00.1/sound/card2/input6
Dec 11 20:13:03 server kernel: input: HDA NVidia HDMI/DP,pcm=8 as /devices/pci0000:00/0000:00:03.0/0000:01:00.1/sound/card2/input7
Dec 11 20:13:03 server kernel: input: HDA NVidia HDMI/DP,pcm=9 as /devices/pci0000:00/0000:00:03.0/0000:01:00.1/sound/card2/input8
Dec 11 20:13:03 server systemd-udevd[569]: Process '/usr/sbin/alsactl -E HOME=/run/alsa restore 2' failed with exit code 99.
Dec 11 20:13:03 server systemd[1]: Mounted /var.
Dec 11 20:13:03 server systemd[1]: Starting Load/Save Random Seed...
Dec 11 20:13:03 server kernel: EXT4-fs (dm-2): mounted filesystem with ordered data mode. Opts: (null)
Dec 11 20:13:03 server systemd[1]: Mounting Mount unit for core, revision 5742...
Dec 11 20:13:03 server systemd[1]: Starting Flush Journal to Persistent Storage...
Dec 11 20:13:03 server systemd[1]: Mounting Mount unit for skype, revision 70...
Dec 11 20:13:03 server systemd[1]: Started Read required files in advance.
Dec 11 20:13:03 server systemd[1]: Starting Load/Save RF Kill Switch Status...
Dec 11 20:13:03 server kernel: EXT4-fs (dm-3): mounted filesystem with ordered data mode. Opts: (null)
Dec 11 20:13:03 server systemd[1]: Mounting Mount unit for skype, revision 68...
Dec 11 20:13:03 server systemd[1]: Mounting Mount unit for skype, revision 69...
Dec 11 20:13:03 server systemd[1]: Mounting Mount unit for core, revision 6034...
Dec 11 20:13:03 server systemd[1]: Mounting Mount unit for anbox-installer, revision 24...
Dec 11 20:13:03 server systemd[1]: Mounting Mount unit for core, revision 5897...
Dec 11 20:13:03 server systemd[1]: Mounted /home.
Dec 11 20:13:03 server systemd-journald[538]: Time spent on flushing to /var is 537.656ms for 1026 entries.
Dec 11 20:13:03 server systemd-journald[538]: System journal (/var/log/journal/3c456b619f154ed49e48efc89fa0e55e) is 3.9G, max 4.0G, 15.8M free.
Dec 11 20:13:07 server kernel: snd_hda_intel 0000:00:1b.0: azx_get_response timeout, switching to polling mode: last cmd=0x300f0000
Dec 11 20:13:07 server kernel: snd_hda_intel 0000:00:1b.0: No response from codec, disabling MSI: last cmd=0x300f0000
Dec 11 20:13:03 server systemd[1]: Mounted Mount unit for anbox-installer, revision 24.
Dec 11 20:13:03 server systemd[1]: Mounted Mount unit for skype, revision 68.
Dec 11 20:13:03 server systemd[1]: Mounted Mount unit for core, revision 5742.
Dec 11 20:13:03 server systemd[1]: Mounted Mount unit for core, revision 6034.
Dec 11 20:13:03 server systemd[1]: Mounted Mount unit for skype, revision 69.
Dec 11 20:13:03 server systemd[1]: Mounted Mount unit for skype, revision 70.
Dec 11 20:13:03 server systemd[1]: Started Load/Save Random Seed.
Dec 11 20:13:03 server systemd[1]: Mounted Mount unit for core, revision 5897.
Dec 11 20:13:03 server systemd[1]: Started Load/Save RF Kill Switch Status.
Dec 11 20:13:06 server systemd[1]: Started Flush Journal to Persistent Storage.
Dec 11 20:13:07 server kernel: snd_hda_intel 0000:00:1b.0: Codec #3 probe error; disabling it...
Dec 11 20:13:07 server kernel: snd_hda_codec_realtek hdaudioC0D2: autoconfig for ALC888: line_outs=4 (0x14/0x15/0x16/0x17/0x0) type:line
Dec 11 20:13:07 server kernel: snd_hda_codec_realtek hdaudioC0D2: speaker_outs=0 (0x0/0x0/0x0/0x0/0x0)
Dec 11 20:13:07 server kernel: snd_hda_codec_realtek hdaudioC0D2: hp_outs=1 (0x1b/0x0/0x0/0x0/0x0)
Dec 11 20:13:07 server kernel: snd_hda_codec_realtek hdaudioC0D2: mono: mono_out=0x0
Dec 11 20:13:07 server kernel: snd_hda_codec_realtek hdaudioC0D2: dig-out=0x1e/0x0
Dec 11 20:13:07 server kernel: snd_hda_codec_realtek hdaudioC0D2: inputs:
Dec 11 20:13:07 server kernel: snd_hda_codec_realtek hdaudioC0D2: Rear Mic=0x18
Dec 11 20:13:07 server kernel: snd_hda_codec_realtek hdaudioC0D2: Front Mic=0x19
Dec 11 20:13:07 server kernel: snd_hda_codec_realtek hdaudioC0D2: Line=0x1a
Dec 11 20:13:07 server kernel: snd_hda_codec_realtek hdaudioC0D2: CD=0x1c
Dec 11 20:13:07 server kernel: snd_hda_codec_realtek hdaudioC0D2: dig-in=0x1f
Dec 11 20:13:07 server kernel: input: HDA Intel MID Rear Mic as /devices/pci0000:00/0000:00:1b.0/sound/card0/input9
Dec 11 20:13:07 server kernel: input: HDA Intel MID Front Mic as /devices/pci0000:00/0000:00:1b.0/sound/card0/input10
Dec 11 20:13:07 server kernel: input: HDA Intel MID Line as /devices/pci0000:00/0000:00:1b.0/sound/card0/input11
Dec 11 20:13:07 server kernel: input: HDA Intel MID Line Out Front as /devices/pci0000:00/0000:00:1b.0/sound/card0/input12
Dec 11 20:13:07 server kernel: input: HDA Intel MID Line Out Surround as /devices/pci0000:00/0000:00:1b.0/sound/card0/input13
Dec 11 20:13:07 server kernel: input: HDA Intel MID Line Out CLFE as /devices/pci0000:00/0000:00:1b.0/sound/card0/input14
Dec 11 20:13:07 server kernel: input: HDA Intel MID Line Out Side as /devices/pci0000:00/0000:00:1b.0/sound/card0/input15
Dec 11 20:14:31 server systemd[1]: dev-mapper-vg\x2d\x2dsecondary\x2dbackups.device: Job dev-mapper-vg\x2d\x2dsecondary\x2dbackups.device/start timed out.
Dec 11 20:14:31 server systemd[1]: Timed out waiting for device dev-mapper-vg\x2d\x2dsecondary\x2dbackups.device.
Dec 11 20:14:31 server systemd[1]: Dependency failed for /backups.
Dec 11 20:14:31 server systemd[1]: Dependency failed for Local File Systems.
Dec 11 20:14:31 server systemd[1]: Dependency failed for Clean up any mess left by 0dns-up.
Dec 11 20:14:31 server systemd[1]: dns-clean.service: Job dns-clean.service/start failed with result 'dependency'.
Dec 11 20:14:31 server systemd[1]: local-fs.target: Job local-fs.target/start failed with result 'dependency'.
Dec 11 20:14:31 server systemd[1]: local-fs.target: Triggering OnFailure= dependencies.
Dec 11 20:14:31 server systemd[1]: backups.mount: Job backups.mount/start failed with result 'dependency'.
Dec 11 20:14:31 server systemd[1]: Dependency failed for File System Check on /dev/mapper/vg--secondary-backups.
Dec 11 20:14:31 server systemd[1]: systemd-fsck@dev-mapper-vg\x2d\x2dsecondary\x2dbackups.service: Job systemd-fsck@dev-mapper-vg\x2d\x2dsecondary\x2dbackups.service/start failed with result 'dependency'.
Dec 11 20:14:31 server systemd[1]: dev-mapper-vg\x2d\x2dsecondary\x2dbackups.device: Job dev-mapper-vg\x2d\x2dsecondary\x2dbackups.device/start failed with result 'timeout'.
Dec 11 20:14:31 server systemd[1]: Starting ebtables ruleset management...
Dec 11 20:14:31 server systemd[1]: Starting Set console font and keymap...
Dec 11 20:14:31 server systemd[1]: Starting Enable support for additional executable binary formats...
Dec 11 20:14:31 server systemd[1]: Closed Syslog Socket.
Dec 11 20:14:31 server systemd[1]: Reached target Printer.
Dec 11 20:14:31 server systemd[1]: Started Stop ureadahead data collection 45s after completed startup.
Dec 11 20:14:31 server systemd[1]: Reached target Login Prompts.
Dec 11 20:14:31 server systemd[1]: Starting Set console scheme...
Dec 11 20:14:31 server systemd[1]: Reached target Timers.
Dec 11 20:14:31 server systemd[1]: Reached target Paths.
Dec 11 20:14:31 server systemd[1]: Starting AppArmor initialization...
|
Your crypttab has two devices with sda5_crypt name. Looks like processing stops at the second sda5_crypt entry, therefore sdd1_crypt is not unlocked.
| additional LUKS partition does not mount on boot |
1,651,838,414,000 |
I have a hard drive which is encrypted using LUKS. It was originally an external hard drive. Recently I removed the casing and connected it directly (via SATA). However, when I connect it directly, I'm unable to view the partition, and it doesn't prompt for the password. Out of 4 TB, it shows an unknown partition of 500GB and free space of 3.5TB.
I removed it from the system and connected it as an external hard drive again, and ubuntu detects the partitions, and prompts for the password.
Also, the partitioning is shown as MBR, when in reality it is GPT
|
It's probably a problem with the sector size. Some USB enclosures claim their drives have 4KiB sectors, when the drive represents itself as 512 byte sectors or vice versa. Partition tables (both msdos and gpt) unfortunately depend on the sector size. If the sector size changes, the partition table becomes invalid.
Now, this is a problem that could be solved in software - Linux could be made smart enough to interpret a GPT partition table correctly, regardless of the physical sector size the drive claims to have. But it doesn't do that, and it's probably not part of the standard, so ...
What you need to do is get the exact byte offsets of your partitions while in the USB closure
parted /dev/usbdrive unit b print free
and then see if those partition offsets work for the internal drive
losetup --find --show --read-only --offset 1048576 /dev/internaldrive
file -s /dev/loopX
and if that works out okay, re-create the partition table with the same (byte) offsets for the internal disk (make a backup of the first/last few megabytes of the disk first)
parted /dev/internaldisk unit b mklabel gpt mkpart 1048576 42424242 ...
I don't know if there is a partitioner that is smart enough to 'repair' such wrong-sector-size partition tables automagically. It would beat the manual approach but ...
| LUKS on an internal hard drive |
1,651,838,414,000 |
Anyone have any ideas for how I can automatically do a luksSuspend on a luks volume after it's been unused for a certain amount of time. I was thinking of just scheduling a command with crontab or something, but I don't want it to suspend if I'm actually using the volume.
|
The intent of luksSetup is to be used when the device is still in use, but you want to temporarily lock all accesses to it until the passphrase is entered from an external source. Thus it doesn't make much sense to only call luksSetup when the device is unused: if it's unused, close it with luksClose.
There's no way to atomically enforce that the device is not in use and call luksSuspend. What you can do if you really want to suspend the device but only if it isn't in use is call luksSuspend, then check with fuser or lsof for any mounted file on the filesystem that's on the encrypted device; if the filesystem is in use, call luksResume immediately. That does have a small chance of requiring you to enter the passphrase.
To detect whether a filesystem is idle, I recommend to piggyback on an existing automounter such as autofs.
| Automatically suspend luks volume after delay |
1,651,838,414,000 |
this is my disk configure:
# hlsblk -F
NAME FSTYPE FSVER LABEL UUID FSAVAIL FSUSE% MOUNTPOINTS
loop0 squashfs 4.0 0 100% /run/archiso/airootfs
sda
├─sda1 btrfs 0bd3ff02-b7a9-4421-877c-c16d1fdf6a6e
└─sda2 crypto_LUKS 2 f030bc5b-773e-4fea-88d4-36b3e95f7c26
└─x200 LVM2_member LVM2 001 20xRtS-jPGK-kTIC-YKfA-XDNr-RSPr-CxNcRU
├─x200-swap swap 1 f6c9ca7d-41a5-4f6b-acc8-fd53e1f4a36e
└─x200-root btrfs f174b77a-c75c-4897-ac31-80aa728004c8
sdb iso9660 Joliet Extension ARCH_202206 2022-06-01-15-35-22-00
├─sdb1 iso9660 Joliet Extension ARCH_202206 2022-06-01-15-35-22-00 0 100% /run/archiso/bootmnt
└─sdb2 vfat
So I've mounted all needed partitions and chroot into it as follows:
# swapon /dev/mapper/x200-swap
# mount /dev/mapper/x200-root /mnt
# mount /dev/sda1 /mnt/boot
# arch-chroot /mnt
When I try to install GRUB with grub-install I get: /usr/bin/grub-probe: error: cannot find a GRUB drive for /dev/sda1. Check your device.map.
This full command output will be pasted at the end of this post.
Got same above error when grub-mkconfig.
This is the head of my grub config.
# head /etc/default/grub
GRUB_DEFAULT=0
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="Arch"
# GRUB_CMDLINE_LINUX_DEFAULT="loglevel=3 quiet cryptdevice=UUID=/dev/sda2:cryptlvm root=/dev/disk/by-uuid/f174b77a-c75c-4897-ac31-80aa728004c8"
# GRUB_CMDLINE_LINUX_DEFAULT="loglevel=3 quiet cryptdevice=UUID=/dev/sda2:cryptlvm root=/dev/x200/root"
GRUB_CMDLINE_LINUX_DEFAULT="loglevel=3 quiet cryptdevice=UUID=/dev/sda2:cryptlvm root=/dev/mapper/x200-root"
GRUB_CMDLINE_LINUX=""
Here is also my fstab
# /dev/mapper/x200-root
UUID=f174b77a-c75c-4897-ac31-80aa728004c8 / btrfs rw,relatime,ssd,space_cache=v2,subvolid=5,subvol=/ 0 0
# /dev/sda1
UUID=0bd3ff02-b7a9-4421-877c-c16d1fdf6a6e /boot btrfs rw,relatime,ssd,space_cache=v2,subvolid=5,subvol=/ 0 0
# /dev/mapper/x200-swap
UUID=f6c9ca7d-41a5-4f6b-acc8-fd53e1f4a36e none swap defaults 0 0
Full GRUB commands output at BBS.
Update
Formated sda1 as ext4, updated fstab uuids, still getting error.
Oh. Also installed os-prober. Still same.
|
TLDR: sda1 partition type was not set by fdisk.
This is what was going on.
After some discussion around it, been MBR boot section one of those, I got curious if fdisk was actually reserving disk initial bytes. So I've typed an fdisk -l /dev/sda. Than I've noticed /dev/sda1 had the type undefined or unknown, so I've pressed t, changed the sda1 to Linux, remount everything and grub-install just worked.
| cannot find a GRUB drive for /dev/sda1. Check your device.map |
1,651,838,414,000 |
I apparently messed up today.
I have to resize an encrypted root partition to make room for a windows dual boot.
I followed instructions from the arch wiki since it seemed to match my needs even though I am using debian. At some point I had to use pvmove because after shrinking the root partition, the free space was between my root and swap partition. I thought it all went well, but I apparently messed up my sector/bytes/stuff calculations at some point.
Right now the machine is booted from a live debian usb key and this is the output of what I think are the relevant shell commands.
user@debian:~$ sudo lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop0 7:0 0 2.3G 1 loop /usr/lib/live/mount/rootfs/filesystem.s
sda 8:0 0 3.6T 0 disk
sdb 8:16 1 114.6G 0 disk
sdc 8:32 1 28.9G 0 disk
├─sdc1 8:33 1 2.5G 0 part /usr/lib/live/mount/medium
└─sdc2 8:34 1 2.6M 0 part
nvme0n1 259:0 0 3.6T 0 disk
├─nvme0n1p1 259:1 0 512M 0 part
├─nvme0n1p2 259:2 0 488M 0 part
└─nvme0n1p3 259:3 0 3.5T 0 part
└─cryptdisk 253:0 0 3.5T 0 crypt # this is where the "fun" happens
So, I managed to free 100G for windows, looks good so far. But...
user@debian:~$ sudo cryptsetup luksOpen /dev/nvme0n1p3 cryptdisk
Enter passphrase for /dev/nvme0n1p3:
user@debian:~$ sudo vgchange -a y licorne-vg
WARNING: Device /dev/mapper/cryptdisk has size of 7602233344 sectors which is smaller than corresponding PV size of 7602235392 sectors. Was device resized?
WARNING: One or more devices used as PVs in VG licorne-vg have changed sizes.
device-mapper: reload ioctl on (253:2) failed: Invalid argument
1 logical volume(s) in volume group "licorne-vg" now active
user@debian:~$ sudo lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop0 7:0 0 2.3G 1 loop /usr/lib/live/mount/rootfs/filesystem.squashfs
sda 8:0 0 3.6T 0 disk
sdb 8:16 1 114.6G 0 disk
sdc 8:32 1 28.9G 0 disk
├─sdc1 8:33 1 2.5G 0 part /usr/lib/live/mount/medium
└─sdc2 8:34 1 2.6M 0 part
nvme0n1 259:0 0 3.6T 0 disk
├─nvme0n1p1 259:1 0 512M 0 part
├─nvme0n1p2 259:2 0 488M 0 part
└─nvme0n1p3 259:3 0 3.5T 0 part
└─cryptdisk 253:0 0 3.5T 0 crypt
└─licorne--vg-root 253:1 0 3.5T 0 lvm
Panic intensifies... 253:2 was my encrypted swap partition which was part of this cryptdisk.
user@debian:~$ sudo pvdisplay /dev/mapper/cryptdisk
WARNING: Device /dev/mapper/cryptdisk has size of 7602233344 sectors which is smaller than corresponding PV size of 7602235392 sectors. Was device resized?
WARNING: One or more devices used as PVs in VG licorne-vg have changed sizes.
--- Physical volume ---
PV Name /dev/mapper/cryptdisk
VG Name licorne-vg
PV Size 3.54 TiB / not usable 0
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 928007
Free PE 0
Allocated PE 928007
PV UUID x5fLwB-qnhM-qc4x-y28f-FdDM-pFGI-9I6SYh
user@debian:~$ sudo lvs
WARNING: Device /dev/mapper/cryptdisk has size of 7602233344 sectors which is smaller than corresponding PV size of 7602235392 sectors. Was device resized?
WARNING: One or more devices used as PVs in VG licorne-vg have changed sizes.
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root licorne-vg -wi-a----- <3.54t
swap_1 licorne-vg -wi------- 976.00m
user@debian:~$ sudo dmesg | grep device-mapper
[ 99.652244] device-mapper: uevent: version 1.0.3
[ 99.652317] device-mapper: ioctl: 4.43.0-ioctl (2020-10-01) initialised: [email protected]
[ 100.537014] device-mapper: table: 253:2: dm-0 too small for target: start=7600236544, len=1998848, dev_size=7602233344
[ 100.537016] device-mapper: core: Cannot calculate initial queue limits
[ 100.537027] device-mapper: ioctl: unable to set up device queue for new table.
[ 1451.395603] device-mapper: table: 253:2: dm-0 too small for target: start=7600236544, len=1998848, dev_size=7602233344
[ 1451.395605] device-mapper: core: Cannot calculate initial queue limits
[ 1451.395956] device-mapper: ioctl: unable to set up device queue for new table.
Is this LVM/LUKS setup in a recoverable state? I think that licorne--vg-root and only the swap partition suffered, which is OK, right? What steps should I follow here to fix things? Thanks for your help.
|
Thanks to @frostchutz I got this fixed by using parted to extend /dev/nvme0n1p3 by 2048 sectors.
| How can I fix LVM PV size after a botched encrypted partition shrinking |
1,651,838,414,000 |
So I've read the wiki and this answer, and I'm still a bit overwhelmed. In the wiki it feels like a lot of these are optional.
Here's what I did. I used Manjaro to install into a single partition, which I may be regretting, and I enabled full disk encryption. What I observe when booting, to either windows or Linux, is I'm prompted for a password, and then I see the actual grub menu.
I'm not then certain which options will work. I think that LVM is enabled, but not 100% and I'm sure I selected ext4. I looked at modifying the grub.conf generation scripts, but I'm not sure where, nor am I sure if that's the right place.
What's the right answer for adding discard, no_read_workqueue, and no_write_workqueue on Manjaro?
UPDATE:
here's what my most current configuration is, but I keep getting dropped into a rescue shell. I'm trying to used the systemd cryptsetup to do all the things, which seems to suggest that I use luks.* parameters.
note: the name root is coming from my manual mounting in the rescue shell.
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS MOUNTPOINT UUID
loop0 7:0 0 450.2M 1 loop /var/lib/snapd/snap/wickrme/543 /var/lib/snapd/snap/wickrme/543
loop1 7:1 0 55.4M 1 loop /var/lib/snapd/snap/core18/2074 /var/lib/snapd/snap/core18/2074
loop2 7:2 0 65.1M 1 loop /var/lib/snapd/snap/gtk-common-themes/1515 /var/lib/snapd/snap/gtk-common-themes/1515
loop3 7:3 0 32.3M 1 loop /var/lib/snapd/snap/snapd/12398 /var/lib/snapd/snap/snapd/12398
zram0 253:0 0 1.5G 0 disk [SWAP] [SWAP]
nvme0n1 259:0 0 953.9G 0 disk
├─nvme0n1p1 259:1 0 100M 0 part /boot/efi /boot/efi 6CEB-F417
├─nvme0n1p2 259:2 0 16M 0 part
├─nvme0n1p3 259:3 0 780.6G 0 part
├─nvme0n1p4 259:4 0 508M 0 part CA343C30343C223D
├─nvme0n1p5 259:5 0 146.5G 0 part 74c51543-eb14-4f61-afeb-b5de6c10a32a
│ └─root 254:0 0 146.5G 0 crypt / / e0a93c98-88a8-4fc9-9948-acdb423d05fd
└─nvme0n1p6 259:6 0 18.6G 0 part [SWAP] [SWAP] 72db96da-87e4-4b17-a622-6a4d56b314c6
4 ❯ cryptsetup luksDump /dev/nvme0n1p5 # ~
LUKS header information for /dev/nvme0n1p5
Version: 1
Cipher name: aes
Cipher mode: xts-plain64
Hash spec: sha256
Payload offset: 4096
MK bits: 512
UUID: 74c51543-eb14-4f61-afeb-b5de6c10a32a
❯ cat /etc/default/grub | grep -v -e '^[[:space:]]*$' -e '^#' # ~
GRUB_DEFAULT=saved
GRUB_TIMEOUT=5
GRUB_TIMEOUT_STYLE=hidden
GRUB_DISTRIBUTOR="Manjaro"
GRUB_CMDLINE_LINUX_DEFAULT="quiet luks.uuid=74c51543-eb14-4f61-afeb-b5de6c10a32a luks.options=discard,no_read_workqueue,no_write_workqueue root=/dev/mapper/luks-e0a93c98-88a8-4fc9-9948-acdb423d05fd splash apparmor=1 security=apparmor udev.log_priority=3"
GRUB_CMDLINE_LINUX=""
GRUB_SAVEDEFAULT=true
GRUB_PRELOAD_MODULES="part_gpt part_msdos"
GRUB_TERMINAL_INPUT=console
GRUB_GFXMODE=1280x768x32,auto
GRUB_DISABLE_RECOVERY=false
GRUB_DISABLE_OS_PROBER=false
GRUB_COLOR_NORMAL="light-gray/black"
GRUB_COLOR_HIGHLIGHT="green/black"
GRUB_THEME="/usr/share/grub/themes/manjaro/theme.txt"
GRUB_ROOT_FS_RO=true
GRUB_ENABLE_CRYPTODISK=y
from what I understand systemd-cryptsetup-generator shouldn't need more options, I do have an /etc/crypttab but everything is commented out.
I'm fairly confident that GRUB_CMDLINE_LINUX_DEFAULT is my only problem, I'm not certain what it should be though. google isn't finding me a lot of (read no) examples of how to do this with the output of blkid or lsblk.
|
I finally figured it out, order to fix my boot, and get the features I want I had to do this.
GRUB_CMDLINE_LINUX_DEFAULT="cryptdevice=UUID=74c51543-eb14-4f61-afeb-b5de6c10a32a:root:allow-discards,no-read-workqueue,no-write-workqueue quiet udev.log_priority=3"
| How should I enable discard and no workqueue for LUKS in Arch/Manjaro |
1,651,838,414,000 |
I have encrypted my home partition via cryptsetup. Inside the mapper /dev/mapper, i have created a ext4 fs via
mkfs.ext4 /dev/mapper/home
Now, my home partiotion only has 91 GB. My luks partition has ~ 270 GB. Is this normal? How can i resize my ext4 home partition?
Some fdisc -l data:
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 195314547 195312500 93,1G 83 Linux
/dev/sda2 781252606 928055295 146802690 70G 5 Extended
/dev/sda3 195315712 781250559 585934848 279,4G 83 Linux
/dev/sda5 781252608 894498815 113246208 54G 83 Linux
/dev/sda6 894500864 928055295 33554432 16G 82 Linux swap / Solaris
/dev/sda3 is the luks encrypted partition.
Disk /dev/mapper/home: 279,4 GiB, 299981864960 bytes, 585902080 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
So in fdisk /dev/mapper/home and /dev/sda3 have the same size.
Some df -h /home data:
Filesystem Size Used Free Used % mounted
/dev/sda1 92G 47G 41G 54% /
So here we only have 92 GB.
Some parted /dev/mapper/home data:
GNU Parted 3.2
Using /dev/mapper/home
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print
Model: Linux device-mapper (crypt) (dm)
Disk /dev/mapper/home: 300GB
Sector size (logical/physical): 512B/512B
Partition Table: loop
Disk Flags:
Number Start End Size File system Flags
1 0,00B 300GB 300GB ext4
Here its seems to have the 300 GB size?
|
To make an encrypted partition mount automatically, you'll first need /etc/crypttab set up properly. In your case, that means a line like this:
home /dev/sda3 none luks
(Here I'm assuming you used LUKS; if you used some other mode of cryptsetup, the two last parameters on the line may need to be different.)
This should cause the system to prompt for encryption passphrase at boot time to unlock the encrypted volume and create the /dev/mapper/home device to access it through the encryption layer. Before proceeding further, boot once to verify that this actually works.
Then you'll need a line in /etc/fstab to mount it:
/dev/mapper/home /home ext4 defaults 0 2
Both in /etc/crypttab and in /etc/fstab you'll have the option of using the UUID= syntax instead of the corresponding device name. Please note that the UUID of the /home filesystem (as viewed through /dev/mapper/home for mounting) is extremely unlikely to be the same as the UUID of the encrypted container /dev/sda3.
| Wrong EXT4 Partition size in luks encrypted partition |
1,651,838,414,000 |
I've just finished a Debian install and I'm trying to boot. I've encrypted my hard drive (LUKS) without partitioning and set up LVM on it. I don't have a separate boot volume, so the system will boot from the logical volume root. I've replaced my BIOS with GRUB but I don't have a GRUB config generated for the system, so I need to boot manually from GRUB.
The GRUB shell code I've guessed to be correct is this:
cryptomount ahci0
set root=lvm/vg-root
linux /vmlinuz root=/dev/mapper/vg-root cryptdevice=/dev/sda
initrd /initrd.img
This is a modification of the configuration given here for a different encrypted LVM setup.
GRUB decrypts the drive fine, but when I try to boot like this I get the following several dozen times:
Begin: Running /scripts/local-block ... WARNING: Failed to connect to lvmetad. Falling back to device scanning.
Volume group "vg" not found
Cannot process volume group vg
done.
Then I get an initramfs shell. I suspect the kernel is looking for the root logical volume before decrypting the disk, since the same thing happens if I use for example root=/dev/mapper/bogus-root. Are there kernel parameters that will allow me to boot this system, or do I have to change the initrd?
|
This can be resolved by adding /etc/crypttab to the initramfs (see manual page for crypttab for the file format) using update-initramfs from the Debian package initramfs-tools.
First, mount the encrypted disk. Then bind-mount /dev, /proc, /sys, and /run on the host into the root filesystem with e.g. mount --bind /dev /mnt/dev. Then chroot into the root filesystem. The crypttab file may now be created (in any location), or copied in before chrooting.
In order to include the crypttab in the initramfs, create a hook script in /usr/share/initramfs-tools/hooks that copies the file into the initramfs. Note that initramfs-tools uses two types of scripts: boot scripts are run by the initramfs init when the system boots, whereas hook scripts are run during the creation of the initramfs image.
The hook script should look something like this (source):
#!/bin/sh
. /usr/share/initramfs-tools/hook-functions
cp -pnL /path/to/crypttab ${DESTDIR}/etc/crypttab
chmod 644 ${DESTDIR}/etc/crypttab
${DESTDIR} expands to the root of the initramfs being created when the hook is run.
Then run update-initramfs with appropriate options. I used -k $(uname -r) since the host and the target used the same kernel version. I also used -c, and -b to specify where the image is written to.
After installing the new image or passing its path to GRUB, early userspace should decrypt the disk and map the contained logical volumes before trying to mount the root volume. The only kernel parameter needed is the root volume path, e.g. root=/dev/mapper/vg-root.
| Booting from LVM on encrypted device |
1,651,838,414,000 |
We have installed Debian 8 on a new Dell PowerEdge T330, there are two partitions, / and /var, in a RAID1 array using mdadm. During testing the primary applications: mysql and tomcat were stopped. We are getting abysmal write performance from both partitions although the read performance is adequate. This is the observations from one of two identical servers setup the same way. Any help would be appreciated.
Performance
root@bcmdit-519:/home/bcmdit# FILE=/tmp/test_data && dd bs=16k \
count=102400 oflag=direct if=/dev/zero of=$FILE && \
rm $FILE && FILE=/var/tmp/test_data && dd bs=16k \
count=102400 oflag=direct if=/dev/zero of=$FILE && rm $FILE
102400+0 records in
102400+0 records out
1677721600 bytes (1.7 GB) copied, 886.418 s, 1.9 MB/s
102400+0 records in
102400+0 records out
1677721600 bytes (1.7 GB) copied, 894.832 s, 1.9 MB/s
root@bcmdit-519:/home/bcmdit# hdparm -t /dev/sda ; hdparm -t /dev/sdb ; hdparm -t /dev/md0 ; hdparm -t /dev/md1
/dev/sda:
Timing buffered disk reads: 394 MB in 3.00 seconds = 131.15 MB/sec
/dev/sdb:
Timing buffered disk reads: 394 MB in 3.01 seconds = 131.05 MB/sec
/dev/md0:
Timing buffered disk reads: 398 MB in 3.00 seconds = 132.45 MB/sec
/dev/md1:
Timing buffered disk reads: 318 MB in 3.00 seconds = 106.00 MB/sec
References
https://severfault.com/questions/832117/how-increase-write-speed-of-raid1-mdadm
https://wiki.mikejung.biz/Software_RAID
Write access time slow on RAID1
https://bbs.archlinux.org/viewtopic.php?id=173791
et al...
Configuration
Encryption was setup using:
root@bcmdit-519:/home/bcmdit# cryptsetup luksDump UUID=1e7b64ac-f187-4fac-9712-8e0dacadfca7|grep -E 'Cipher|Hash'
Cipher name: aes
Cipher mode: xts-plain64
Hash spec: sha1
Config snippets
root@bcmdit-519:/home/bcmdit# facter virtual productname lsbdistid \
lsbdistrelease processor0 blockdevice_sda_model \
blockdevice_sdb_model bios_version && uname -a && uptime
----------
bios_version => 2.4.3
blockdevice_sda_model => ST1000NX0423
blockdevice_sdb_model => ST1000NX0423
lsbdistid => Debian
lsbdistrelease => 8.10
processor0 => Intel(R) Xeon(R) CPU E3-1230 v6 @ 3.50GHz
productname => PowerEdge T330
virtual => physical
Linux bcmdit-519 3.16.0-4-amd64 #1 SMP Debian 3.16.51-3 (2017-12-13) x86_64 GNU/Linux
14:45:58 up 2:49, 2 users, load average: 0.06, 0.17, 0.44
root@bcmdit-519:/home/bcmdit# grep GRUB_CMDLINE_LINUX_DEFAULT /etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT="quiet erst_disable elevator=deadline"
root@bcmdit-519:/home/bcmdit# free -m
total used free shared buffers cached
Mem: 32202 1532 30670 9 17 369
-/+ buffers/cache: 1145 31056
Swap: 0 0 0
root@bcmdit-519:/home/bcmdit# parted /dev/sda print
Model: ATA ST1000NX0423 (scsi)
Disk /dev/sda: 1000GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 500GB 500GB primary boot, raid
2 500GB 1000GB 500GB extended
5 500GB 1000GB 500GB logical raid
root@bcmdit-519:/home/bcmdit# parted /dev/sdb print
Model: ATA ST1000NX0423 (scsi)
Disk /dev/sdb: 1000GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 500GB 500GB primary raid
2 500GB 1000GB 500GB extended
5 500GB 1000GB 500GB logical raid
----------
root@bcmdit-519:/home/bcmdit# cat /proc/mdstat
Personalities : [raid1]
md1 : active raid1 sda5[0] sdb5[1]
488249344 blocks super 1.2 [2/2] [UU]
bitmap: 3/4 pages [12KB], 65536KB chunk
md0 : active raid1 sda1[0] sdb1[1]
488248320 blocks super 1.2 [2/2] [UU]
bitmap: 2/4 pages [8KB], 65536KB chunk
unused devices: <none>
root@bcmdit-519:/home/bcmdit# mdadm --query --detail /dev/md0
/dev/md0:
Version : 1.2
Creation Time : Mon Apr 16 13:46:51 2018
Raid Level : raid1
Array Size : 488248320 (465.63 GiB 499.97 GB)
Used Dev Size : 488248320 (465.63 GiB 499.97 GB)
Raid Devices : 2
Total Devices : 2
Persistence : Superblock is persistent
Intent Bitmap : Internal
Update Time : Tue May 15 14:26:47 2018
State : clean
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0
Name : bcmdit-519:0 (local to host bcmdit-519)
UUID : afd3968c:2e8b191d:4504f21e:255b6470
Events : 1703
Number Major Minor RaidDevice State
0 8 1 0 active sync /dev/sda1
1 8 17 1 active sync /dev/sdb1
root@bcmdit-519:/home/bcmdit# mdadm --query --detail /dev/md1
/dev/md1:
Version : 1.2
Creation Time : Mon Apr 16 13:47:06 2018
Raid Level : raid1
Array Size : 488249344 (465.63 GiB 499.97 GB)
Used Dev Size : 488249344 (465.63 GiB 499.97 GB)
Raid Devices : 2
Total Devices : 2
Persistence : Superblock is persistent
Intent Bitmap : Internal
Update Time : Tue May 15 14:15:11 2018
State : active
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0
Name : bcmdit-519:1 (local to host bcmdit-519)
UUID : e46f968a:e8fff775:ecee9cfb:4ad88574
Events : 2659
Number Major Minor RaidDevice State
0 8 5 0 active sync /dev/sda5
1 8 21 1 active sync /dev/sdb5
root@bcmdit-519:/home/bcmdit# cat /etc/crypttab
crypt1 UUID=1e7b64ac-f187-4fac-9712-8e0dacadfca7 /root/.crypt1 luks
root@bcmdit-519:/home/bcmdit# grep -v '^#' /etc/fstab
UUID=c6baa173-8ea6-4598-a965-eee728a93d69 / ext4 defaults,errors=remount-ro 0 1
/dev/sr0 /media/cdrom0 udf,iso9660 user,noauto 0 0
/dev/mapper/crypt1 /var ext4 defaults,errors=remount-ro 0 2
/var/swapfile1 none swap sw,nofail 0 0
root@bcmdit-519:/home/bcmdit# smartctl -a /dev/sda|head -n 20
smartctl 6.4 2014-10-07 r4002 [x86_64-linux-3.16.0-4-amd64] (local build)
Copyright (C) 2002-14, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF INFORMATION SECTION ===
Device Model: ST1000NX0423
Serial Number: W4713QXE
LU WWN Device Id: 5 000c50 0abb06247
Add. Product Id: DELL(tm)
Firmware Version: NA07
User Capacity: 1,000,204,886,016 bytes [1.00 TB]
Sector Size: 512 bytes logical/physical
Rotation Rate: 7200 rpm
Form Factor: 2.5 inches
Device is: Not in smartctl database [for details use: -P showall]
ATA Version is: ACS-3 (minor revision not indicated)
SATA Version is: SATA 3.1, 6.0 Gb/s (current: 6.0 Gb/s)
Local Time is: Tue May 15 14:29:03 2018 PDT
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
root@bcmdit-519:/home/bcmdit# smartctl -a /dev/sdb|head -n 20
smartctl 6.4 2014-10-07 r4002 [x86_64-linux-3.16.0-4-amd64] (local build)
Copyright (C) 2002-14, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF INFORMATION SECTION ===
Device Model: ST1000NX0423
Serial Number: W4714VDQ
LU WWN Device Id: 5 000c50 0abf99927
Add. Product Id: DELL(tm)
Firmware Version: NA07
User Capacity: 1,000,204,886,016 bytes [1.00 TB]
Sector Size: 512 bytes logical/physical
Rotation Rate: 7200 rpm
Form Factor: 2.5 inches
Device is: Not in smartctl database [for details use: -P showall]
ATA Version is: ACS-3 (minor revision not indicated)
SATA Version is: SATA 3.1, 6.0 Gb/s (current: 6.0 Gb/s)
Local Time is: Tue May 15 14:29:11 2018 PDT
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
Update 1
With 16M
root@bcmdit-519:/tmp# FILE=/tmp/test_data \
&& dd bs=16M count=102 oflag=direct if=/dev/zero of=$FILE \
&& rm $FILE \
&& FILE=/var/tmp/test_data \
&& dd bs=16M count=102 oflag=direct if=/dev/zero of=$FILE \
&& rm $FILE
102+0 records in
102+0 records out
1711276032 bytes (1.7 GB) copied, 16.6394 s, 103 MB/s
102+0 records in
102+0 records out
1711276032 bytes (1.7 GB) copied, 17.8649 s, 95.8 MB/s
Update 2
Seagate drive serial number found SMART indicates an Enterprise grade drive:
https://www.cnet.com/products/seagate-enterprise-capacity-2-5-hdd-v-3-1tb-sata-512n/specs/
Update 3
I found that drive write cacheing was off, but by setting it to on:
hdparm -W1 /dev/sd*
I get much better results with bs=16k now
root@bcmdit-519:/home/bcmdit# FILE=/tmp/test_data && dd bs=16k count=102400 oflag=direct if=/dev/zero of=$FILE && rm $FILE
102400+0 records in
102400+0 records out
1677721600 bytes (1.7 GB) copied, 14.0708 s, 119 MB/s
Update 4
root@ecm-oscar-519:/home/bcmdit# cryptsetup benchmark
# Tests are approximate using memory only (no storage IO).
PBKDF2-sha1 1394382 iterations per second
PBKDF2-sha256 923042 iterations per second
PBKDF2-sha512 728177 iterations per second
PBKDF2-ripemd160 804122 iterations per second
PBKDF2-whirlpool 313569 iterations per second
# Algorithm | Key | Encryption | Decryption
aes-cbc 128b 1149.9 MiB/s 3655.8 MiB/s
serpent-cbc 128b 99.6 MiB/s 743.4 MiB/s
twofish-cbc 128b 219.0 MiB/s 400.0 MiB/s
aes-cbc 256b 867.5 MiB/s 2904.5 MiB/s
serpent-cbc 256b 99.6 MiB/s 742.6 MiB/s
twofish-cbc 256b 218.9 MiB/s 399.8 MiB/s
aes-xts 256b 3615.1 MiB/s 3617.3 MiB/s
serpent-xts 256b 710.8 MiB/s 705.0 MiB/s
twofish-xts 256b 388.1 MiB/s 394.5 MiB/s
aes-xts 512b 2884.9 MiB/s 2888.1 MiB/s
serpent-xts 512b 710.7 MiB/s 704.7 MiB/s
twofish-xts 512b 388.0 MiB/s 394.3 MiB/s
|
When you ask dd for bs=16K and oflag=direct you are asking for many small writes, this is what HDDs are bad at and what SSDs are good at.
You can use LVMCache to get the benefit of both (up to the SSD size)
If you use bs=16M or no oflag then the writes are split/combined/cached in RAM and written at an optimal size.
Why is dd using direct slower writing to disk than to a file
for example;
> dd if=/dev/zero of=test.bin bs=16k count=1000 oflag=direct
1000+0 records in
1000+0 records out
16384000 bytes (16 MB, 16 MiB) copied, 3.19453 s, 5.1 MB/s
> dd if=/dev/zero of=test.bin bs=16M count=1 oflag=direct
1+0 records in
1+0 records out
16777216 bytes (17 MB, 16 MiB) copied, 0.291366 s, 57.6 MB/s
> dd if=/dev/zero of=test.bin bs=16k count=1000
1000+0 records in
1000+0 records out
16384000 bytes (16 MB, 16 MiB) copied, 0.0815558 s, 201 MB/s
> uname -r
4.14.41-130
| Slow Write Speed(<2 MB/s) on Unencrypted and LUKS Encrypted ext4 filesystems using mdadm Software RAID1 Debian 8 Dell PowerEdge T330 Server |
1,651,838,414,000 |
I upgraded my server from Debian Jessie to Debian Stretch without any issue before the reboot. After rebooting, the server now hangs with the message "Please unlock disk xxx".
The disk in question is encrypted using LUKS, and there also are other encrypted disks in the system. However, these are NOT necessary to boot the system. In the past, I just SSHed into the system after a reboot, unlocked the disks manually (and then started the virtual machines which are stored on the encrypted disks).
I don't understand why unlocking now is attempted (mandatory?) during boot.
Is there a way to boot my system (so that I have SSH access) without entering LUKS credentials? I'd love to see an approach that I can tell to my "remote hands", possibly by fiddling with the kernel arguments in GRUB.
After getting into a (repair) SSH mode, how can I fix the issue for the next reboot?
|
Actually, this was my fault. PEBCAK. The system was configured with SWAP on a LVM LV on some LVM VG which is part of the encrypted disk. In other words, Debian correctly prompted me to decrypt the disk after the reboot.
| Debian Stretch hangs at boot with "Please unlock disk xxx" error after upgrade from Debian Jessie |
1,484,357,934,000 |
I have an SSD I removed from a system. It had full disk encryption via LUKS (without using LVM).
I want to reuse this drive for a different purpose (in a different system). I cloned (using dd) a non-encrypted Arch Linux system (which is known to be good and does boot) to this previously encrypted drive. However, the cloned drive will not boot.
The dd command I used was:
dd if=/dev/sda of=/dev/sdb bs=1M status=progress
(I got the input and output devices correct too.) The disk I cloned from is back in its original hardware and it booted and runs fine. The new (cloned) disk is in identical hardware.
The newly cloned disk has the same partition structure and the UUID's are the same (as expected). Furthermore, when I mount the new disk and browse through the directories, all files appear to be as expected. The newly cloned disk appears identical upon inspection and it is not obviously corrupted. For example, I can open and read the UEFI loader config files to inspect the UUID numbers. I can also run blkid to verify that the UUID's are correct (they are).
Both systems use UEFI boot. The vfat EFI partition is on the newly cloned drive and it appears to be normal. As stated, the default loader config has the appropriate UUID (because nothing has changed from the drive that was cloned).
The error upon trying to boot from the cloned disk is:
:: running early hook udev
starting version 231
:: running hook [udev]
Waiting 10 seconds for device /dev.. (it lists the partition ID)
ERROR: device [partition UUID] not found. Skipping fsck.
ERROR: unable to find root device [partition UUID]
You are being dropped into a rescue shell
Then Arch drops into a rescue shell.
EDIT:
The cloned drive was connected to the system via USB. When I changed the connection to SATA, the problem went away. The drive works and the system boots as expected.
I expected the cloned drive to work when mounted via USB because this system has already been tested to boot from a btrfs snapshot residing on a USB drive and that works without any issues.
|
Your system boots up to the point where it tries to find the root filesystem, and fails at that point. This is often a sign that the kernel is missing a necessary driver. As your system, like most non-embedded systems, uses an initramfs, “kernel” here means the set of drivers compiled in the kernel image (/boot/bzImage or wherever it's located) plus the set of drivers that are present on the initramfs. The necessary drivers include everything that's needed to access the filesystem: bus controller, disk controller, disk type, partition, software RAID layer, encryption layer, LVM, filesystem… In your case, evidently the higher layers are present, but if you connected the disk to a different interface (say USB instead of SATA, or a different SATA port on a different controller, etc.) then maybe the driver for that interface is missing. You probably need to regenerate the initramfs.
As it says on the Arch wiki:
Boot succeeds on one machine and fails on another
(…) If you transfer your /boot directory to another machine and the boot sequence fails during early userspace, it may be because the new hardware is not detected due to missing kernel modules. (…) try manually adding modules to the initramfs.
| cloned drive won't boot. (It was a LUKS encrypted drive) |
1,484,357,934,000 |
I'm trying to install Gentoo on LVM logical volume inside LUKS container encrypted with key file encrypted by GPG with passphrase. Everything was going smoothly until I tried to boot. I'm building the kernel and initramfs with genkernel:
genkernel --lvm --luks --install --menuconfig --busybox all
and booting it with GRUB2. So after I start the kernel I get the information that my key file gets found, but in the next line I get “Failed to open LUKS device...” and than comes a kernel panic. Any idea what to do?
Kernel config - http://pastebin.com/YR7TfaVm
GRUB2 menuentry:
menuentry 'Gentoo'{
root='hd1,gpt1'
linux /kernel-genkernel-x86_64-3.17.7-gentoo initrd=/dev/ram0 crypt_root=/dev/disk/by-partuuid/PARTUUID_OF_LUKS_CONTAINTER_PARTION dolvm real_root=/dev/mapper/vg1-root rootfstype=ext4 real_init=/usr/lib/systemd/systemd root_keydev=/dev/disk/by-partuuid/PARTUUID_OF_MY_PENDRIVE_WITH_KEY root_key=luks-key.gpg
initrd /initramfs-genkernel-x86_64-3.17.7-gentoo
echo "initing..."
}
|
My problem got solved after changing kernel version to 3.10 and changing gpg version to an old one, that wasn't requiring pinentry to work and that i compiled statically. Although with new version i checked everything twice there always seemed to be an problem with pinentry. Also I think that genkernel wasn't including pinentry automatically. I had to include it myself.
So to summarize:
check if your gpg version requires pinentry (I my case I reverted to an older version to make the initrd)
consider more stable kernel version
consider compiling gpg statically
check all library dependents after generating initrd even if you used something like genkernel
| Booting Gentoo on LVM inside LUKS with gpg encrypted keyfile |
1,484,357,934,000 |
I'm going to create encrypted lvm on my disk. As a encryption mechanism I choose dmcrypt with LUKS.
Here's my question - should I overwrite (for security reasons) whole disk before creating encrypted container, or overwrite already encrypted container (there is some information at cryptsetup FAQ - step 6) or both? Does it matter?
|
If you do not overwrite the previous contents of the disk, any old information will remain in a trivially (software-only) readable form until it happens to be overwritten, which may be a very long time (bordering on forever).
If you do overwrite the previous contents of the disk with zeroes before creating the LUKS data structures on-disk, you have largely removed the possibility of reading old data off the disk (it will be a decidedly non-trivial task using software, but might be possible with specialized hardware, a lot of time and a lot of money) but since the odds of any length of data encrypting to all zeroes is negligible, it is trivially easy to determine which parts of the disk hold actual encrypted data. Hence, a determined adversary can focus on the parts of the disk that actually hold data.
If you do overwrite the previous contents of the disk with random data before creating the LUKS data structures on-disk, it will be very difficult to determine which areas of the disk holds actual data and which are simply noise, because they will look largely the same. (Without the key, properly encrypted data is indistinguishable from noise.) An attacker may be able to tell that there is a LUKS data container there because of its inherent data structures, but won't be able to tell which parts of the disk are worth attacking cryptographically.
If you do fill the encrypted container with zeroes or random data, anything outside that container will still hold the previous data and be susceptible to the same risks as if you didn't do any overwriting of the disk content. With an encrypted container covering the whole disk, this will be a trivial but still nonzero amount of data.
Which one of these is appropriate for you is a matter of risk analysis. Any overwrite takes a good while, but the difference in time between overwriting with zeroes and with pseudo-random data is rather small in comparison.
Overwriting the disk has an additional benefit: it exercises the entire physical area of the disk, allowing the drive to identify and relocate damaged areas before anything important gets written to it. Since with encrypted (like compressed) data any single bit errors are going to multiply rapidly, the potential benefit from this is non-trivial and comes at a relatively modest cost.
I overwrite the entire disk with random data as a matter of course before initializing it as a LUKS device, because I feel the benefits of such an approach outweigh the cost (with the cost being primarily time to first use of the new drive).
If you overwrite the entire disk (using something like dd if=/dev/urandom of=/dev/sdb bs=1M -- warning, do not run that command unless you know exactly why you are doing so!), then you don't need to do a separate overwrite of the encrypted LUKS partition, because it's already random-looking enough.
And of course, the obligatory XKCD reference: drug him and hit him with this $5 wrench until he tells us the password. But I'm sure you are aware that even full disk encryption is no panacea.
| Overwriting disk before encryption |
1,484,357,934,000 |
Is there a way to recover an overwritten LUKS partition? Consider the following case:
I had a (external) hard drive (not SSD) which is completely LUKS encrypted containing an ext4 file system with some (important) data (in my case images and videos). The passphrase is known. I don't have a LUKS header backup.
Now I accidentally created a new LUKS partition on that drive (which overwrote the old one) and a new ext4 file system inside. Then I copied some new data (in my case the some backup data from my laptop; 160 GB (the external drive has a size of 1TB) to it.
Is there any way to recover the old LUKS partition with all the data or at least the images and videos (maybe without filenames).
Edit: Additional questions
Is there any way to revert bitwise the last operations (i.e. data transfer to the new partition, creation of the ext4 file-system, and creation of the LUKS volume)?
Maybe this reversion is possible on a physical level if one analyzes the magnetic structure of the disk surface? Can a forensic professional do this?
Are there any other promising approaches a forensic professional would try in this case?
As already said I didn't backup the LUKS header of the old volume. However as indicated by frostschutz, if I had opened the old volume before the accident and didn't reboot, the header might be found in the memory (but I did reboot in my case). Are there other places where I can search for the header? I usually mounted the old volume using the pmount tool.
|
I'm afraid there's no chance without a header backup.
The passphrase is only useful when a LUKS header is available that has that passphrase in a keyslot. Without that, there's pretty much no way to recover the volume key.
Part of the LUKS design is that if the LUKS header is erased (and any backups) then it's forensically infeasible to access the container.
| Recover overwritten LUKS partition |
1,484,357,934,000 |
The Luks volume works fine regarding mounting it, reading from and writing to it. But when It try to create a backup for its header, with cryptsetup luksDump or cryptsetup luksHeaderBackup I get nothing, not even an error message.
I tried under sudo cryptsetup luksDump /dev/mapper/<device> and cryptsetup luksDump /media/user/partition. Tried the unmounted volume too.
sudo cryptsetup -v luksDump /media/<user>/LUKS
Command failed with code -4 (wrong device or file specified).
sudo cryptsetup -v luksDump /media/<user>/LUKS/
Command failed with code -4 (wrong device or file specified).
sudo cryptsetup -v luksDump /dev/mapper/LUKS
Command failed with code -1 (wrong or missing parameters).
sudo cryptsetup -v luksDump /dev/mapper/LUKS/
Device /dev/mapper/LUKS/ doesn't exist or access denied.
Command failed with code -4 (wrong device or file specified).
and
cryptsetup -v isLuks /dev/mapper/LUKS
Command failed with code -1 (wrong or missing parameters).
|
The errors you are showing seem to indicate you are running your commands against the mapping names (search man 8 cryptsetup for "mapping" to see what it refers to), i.e. the decrypted devices created by the device mapper, and not against the actual encrypted ones.
For instance, if you open a LUKS device using the command
cryptsetup luksOpen /dev/sda2 sda2_crypt
you will find the device sda2_crypt (the mapping name) in /dev/mapper, but you will have to run
cryptsetup luksDump /dev/sda2
to dump the header located on the encrypted device.
| `cryptsetup luksDump` or `cryptsetup luksHeaderBackup` generate no output |
1,484,357,934,000 |
I have a USB flash drive with Full Disk Encryption using LUKS.
I plugged in the drive and mounted it as such using the following:
cryptsetup luksOpen /dev/sdb flash
mount /dev/mapper/flash /mnt/flash
If I physically remove my flash drive I can still access it's contents at /mnt/flash. Why is this? I see it as a security risk as I want my flash drive contents to become inaccessible as soon as the drive is physically removed.
What can I do to make this happen? It needs to be something I can do to the drive as I use this on other computers and I don't want to have to change them all to make the drive secure.
|
If you ran a program / script from the USB itself, you should be able to figure out what LUKS map/name and device it's on (or just tell the script the device or mapped name if you know it) and watch for when the device "disappears" when it's removed. Then unmount it.
I'm pretty sure that unplugging a USB will cause the device (/dev/sdXn) to disappear, but in case it doesn't you'd have to watch dmesg or look in the syslog, or find it somewhere in /sys perhaps.
Here's a proof-of-concept bash script that looks like it should work, but I don't have any LUKS partitions on usb's to test with, so I'm not sure if umount might need options like --lazy or --force.
map=$( df --output=source $PWD |tail -n1 )
device=$( sudo cryptsetup status "$map" | grep -o "device:.*"|cut -d' ' -f 3 )
while [ -b "$device" ]
do
sleep 30
done
echo "Device $device is missing, unmounting"
sudo umount -v "$map"
If it's run from inside the mounted LUKS container, $PWD should find the LUKS name it's mapped on, and then the device, and if the device stops being a block special file then unmount the mapped device.
PS If the device was mounted rw (writeable) the filesystem can be corrupted by suddenly unplugging it. FAT seems especially vulnerable, while a journaling filesystem should be more robust. If it's mounted ro (read-only) at least you could avoid that problem, mount accepts -o ro and cryptsetup accepts --readonly (both probably aren't necessary)
| LUKS partition still accessible after removing drive physically |
1,484,357,934,000 |
I was given a HDD that was encrypted using dm-crypt and I'd like to mount it as /disk2 preferably having the decryption password stored in a file, so I won't have to enter the passphrase when booting, but it's not that important.
When I try to open the disk in the file manager providing the encryption passsword, I get this error
Failed to mount "500 GB LVM2 Physical Volume".
Not a mountable file system.
lvdisplay gives
LV Path /dev/disk2/disk2
LV Name disk2
VG Name disk2
LV Status NOT available
ls /dev/mapper gives the following, while the desired result should be disk2-disk2 I guess
udisks-luks-uuid-.....-uid1000
dmsetup ls --tree returns
udisks-luks-uuid-.....-uid1000 (253:7)
└─ (8:17)
lvs returns
disk2 disk2 -wi----- 465,75g
lsblk (before decryption) returns
sdb 8:16 0 465,8G 0 disk
└─sdb1 8:17 0 465,8G 0 part
lsblk returns
sdb 8:16 0 465,8G 0 disk
└─sdb1 8:17 0 465,8G 0 part
└─udisks-luks-uuid-.....-uid1000 (dm-7) 253:7 0 465,8G 0 crypt
mount /dev/mapper/disk2 /mnt returns
mount: unknown filesystem type 'LVM2_member'
fdisk -l /dev/sdb returns
WARNING: GPT (GUID Partition Table) detected on '/dev/sdb'! The util fdisk doesn't support GPT. Use GNU Parted.
Disk /dev/sdb: 500.1 GB, 500107862016 bytes 255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000
Device Boot Start End Blocks Id System /dev/sdb1 1 976773167 488386583+ ee GPT
Partition 1 does not start on physical sector boundary.
|
This sequence allowed me to access the data
cryptsetup luksOpen /dev/sdb1 disk2
modprobe dm-mod
vgchange -ay
mount /dev/disk2/disk2 /disk2
So I offer the reward to the one who'll tell me how to make this change permanent.
| Mount encrypted volume in Debian |
1,484,357,934,000 |
In LUKS, only files get encrypted, not the entire drive.
So my question is, what is accessible if just files are encrypted. For example:
Are file paths or file names visible? (Eg: For Enrypted ZIP Files using ZipCrypto i can see full paths, filenames which makes it possible to attack)??
Is there no encryption mechanism for a linux disk that for example encrypts page-by-page or any other mechanism so that you cannot read anything?
|
In LUKS, only files get encrypted, not the entire drive.
This is wrong. LUKS encrypts the whole volume. LUKS operates at a lower level than the filesystem. It doesn't know anything about files, directories, free space, etc. LUKS encrypts and decrypts blocks. What the filesystem (if any) does with those blocks is its own business.
In a LUKS-encrypted volume (drive or partition), the only thing that is visible in plaintext is a header containing some metadata (choice of encryption algorithm, list of passphrase hashes, volume UUID, …).
Either you read some incorrect information about LUKS or you're confusing it with some other storage encryption mechanism.
Is there no encryption mechanism for a linux disk that for example encrypts page-by-page or any other mechanism so that you cannot read anything?
Yes, there is. It's LUKS.
| LUKS Encryption - Readable content |
1,484,357,934,000 |
I'm having issues unlocking an encrypted disk over ssh using dropbear.
I've followed this guide to set it up, but I just end up getting Permission denied (publickey) error
I copied the public key from my machine ~/.ssh/id_rsa.pub to the server /etc/dropbear-initramfs/authorized_keys and updated with update-initramfs -u -k all
The config of /etc/dropbear-initramfs/config currently have this content:
DROPBEAR_OPTIONS="-I 120 -c /bin/cryptroot-unlock"
I also tested with the config from the article
DROPBEAR_OPTIONS="-RFEsjk -c /bin/cryptroot-unlock"
Using SSH, I've tried specifying the identity key (-i), tried with no username, server machine username, my machine username etc... I simply cannot get past the Permission denied error.
|
During writing the question, I figured it out, and might as well tell anyone else wondering.
When using ssh, you need to specify root as the user: ssh [email protected]
| dropbear-initramfs Permission denied (publickey) |
1,484,357,934,000 |
I try to prepare an nvme for encryption, so i first follow this post on SO.
But the speed of dd is really really slow (less than 100 mb/s). I see there is new option to speed up dm-crypt on kernel 5.9 (see this post), but before updating my kernel, i want to know if using nvme-cli format zero tools is equivalent to /dev/zero to prepare a disk : https://manpages.debian.org/testing/nvme-cli/nvme-write-zeroes.1.en.html
The actual (and very very slow) command to prepare disk before luks2 format :
cryptsetup plainOpen --key-file /dev/urandom /dev/nvme0n1p2 ecrypt
dd if=/dev/zero of=/dev/mapper/ecrypt bs=1M status=progress
cryptsetup plainClose
Update :
Going to kernel 5.12 with dmcrypt 2.3.4, i use this new perf options :
cryptsetup plainOpen --perf-no_read_workqueue --perf-no_write_workqueue --key-file /dev/urandom /dev/nvme0n1p2 ecrypt
dmsetup table say option are correctly activated :
ecrypt: 0 1999358607 crypt aes-cbc-essiv:sha256 0000000000000000000000000000000000000000000000000000000000000000 0 259:2 0 2 no_read_workqueue no_write_workqueue
I also verifyed that AES is activated with cpuid :
cpuid | grep -i aes | sort | uniq
AES instruction = true
VAES instructions = false
I have the same problem, dd write zero at 900mb/s and slowly decrease to 45 mb/s ...
|
Found the answer, this is much much better with oflag=direct, jumping from 45 Mb/s to 536 Mb/s :)
dd if=/dev/zero of=/dev/mapper/ecrypt oflag=direct bs=1M status=progress
Thanks to these two posts :
NVMe performance hit when using LUKS encryption
https://stackoverflow.com/questions/33485108/why-is-dd-with-the-direct-o-direct-flag-so-dramatically-faster
| Slow /dev/zero format using dd with nvme to prepare crypto, is there nvme specific tool? |
1,484,357,934,000 |
I'm trying to create a LUKS LVM disk partition autmatically using preseed on Debian 10 (Buster). I have only a single disk /dev/sda with the size of 80GB and it has system memory of 4GB
Here is my full preseed configuration:
#### Preseed preconfiguration file (for Debian buster)
### Partman early command
### Kernal parameter
d-i debian-installer/add-kernel-opts string net.ifnames=0 biosdevname=0 console=ttyS0,19200n8
### Localization
d-i debian-installer/locale string en_US.UTF-8
d-i debian-installer/language string en
d-i debian-installer/country string MY
### Keyboard selection
d-i keyboard-configuration/xkb-keymap select us
### Network configuration
d-i netcfg/choose_interface select eth0
d-i netcfg/use_dhcp string false
d-i netcfg/disable_autoconfig boolean true
d-i netcfg/dhcp_failed note
d-i netcfg/dhcp_options select Configure network manually
# IPv4 Static network configuration
d-i netcfg/get_ipaddress string 172.14.5.185
d-i netcfg/get_netmask string 255.255.255.0
d-i netcfg/get_gateway string 172.14.5.1
d-i netcfg/get_nameservers string 139.12.11.5
d-i netcfg/confirm_static boolean true
# Set a hostname
d-i netcfg/get_hostname string sun
d-i netcfg/get_domain string domain.com
# Force a hostname
d-i netcfg/hostname string sun.domain.com
# Disable that annoying WEP key dialog
d-i netcfg/wireless_wep string
### Mirror settings
d-i mirror/country string manual
d-i mirror/http/hostname string deb.debian.org
d-i mirror/http/directory string /debian
d-i mirror/http/proxy string
### Account setup
# Skip creation of a normal user account
d-i passwd/make-user boolean false
# Set root password
# or encrypted using a crypt(3) hash.
d-i passwd/root-password-crypted password $6$R3C6TyiPkyqUwaw7$4rgc4Uluov6wm5ZXmEdssw3pZs5E5dsnOuVPa/VAHAJTsQCsxSeKjIj7hp3xJzZ9t5wQpx6UuYcXZxYpjbkn/
### Clock and time zone setup
# Set hardware clock to UTC
d-i clock-setup/utc boolean true
# Set timezone
d-i time/zone string Asia/Kuala_Lumpur
# Use NTP clock during installation
d-i clock-setup/ntp boolean true
### Partitioning
# LVM LUKS method
d-i partman-auto/method string crypto
d-i partman-lvm/device_remove_lvm boolean true
d-i partman-md/device_remove_md boolean true
d-i partman-lvm/confirm boolean true
d-i partman-auto-lvm/guided_size string max
d-i partman-auto-lvm/new_vg_name string box1
d-i partman-auto/disk string /dev/sda
d-i partman-auto/choose_recipe select boot-crypto
d-i partman-auto/expert_recipe string \
boot-crypto :: \
1024 1024 1024 ext4 \
$primary{ } $bootable{ } \
method{ format } format{ } \
use_filesystem{ } filesystem{ ext4 } \
mountpoint{ /boot } \
. \
15360 15360 15360 ext4 \
$lvmok{ } lv_name{ root } \
in_vg { box1 } \
method{ format } format{ } \
use_filesystem{ } filesystem{ ext4 } \
mountpoint{ / } \
. \
2048 2048 2048 ext4 \
$lvmok{ } lv_name{ tmp } \
in_vg { box1 } \
method{ format } format{ } \
use_filesystem{ } filesystem{ ext4 } \
mountpoint{ /tmp } \
options/nosuid{ nosuid } \
options/noexec{ noexec } \
. \
4096 4096 4096 linux-swap \
$lvmok{ } lv_name{ swap } \
in_vg { box1 } \
method{ swap } format{ } \
. \
80896 80896 1000000 ext4 \
$lvmok{ } lv_name{ home } \
in_vg { box1 } \
method{ format } format{ } \
use_filesystem{ } filesystem{ ext4 } \
mountpoint{ /home } \
options/nosuid{ nosuid } \
d-i partman-basicfilesystems/no_mount_point boolean false
d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true
### Apt setup
d-i apt-setup/cdrom/set-first boolean false
d-i apt-setup/cdrom/set-next boolean false
d-i apt-setup/cdrom/set-failed boolean false
d-i apt-setup/services-select multiselect security, updates
d-i apt-setup/security_host string security.debian.org
### Package selection
tasksel tasksel/first multiselect standard
# Individual additional packages to install
d-i pkgsel/include string openssh-server
popularity-contest popularity-contest/participate boolean false
The other preseed config ran successfully. The disk is created with LUKS LVM but the problem is that there is a missing partition like /home (which is not created from the beginning) but I did defined it in the preseed file above. In addition, the swap disk space should be 4GB but it filled up the rest of the space. Here is the screenshot how this preseed config created the disk structure:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 79G 0 disk
|-sda1 8:1 0 976M 0 part /boot
|-sda2 8:2 0 1K 0 part
`-sda5 8:5 0 78G 0 part
`-sda5_crypt 254:0 0 78G 0 crypt
|-box1-root 254:1 0 14.3G 0 lvm /
|-box1-tmp 254:2 0 1.9G 0 lvm /tmp
`-box1-swap 254:3 0 61.8G 0 lvm [SWAP]
What could be the reason for this? Any mistakes in my preseed file for partitioning?
My partition scheme is this:
TOTAL SPACE is 80 GB
partition: /boot 1GB | FILE SYSTEM: ext4 | bootable flag: on | no need to encrypt
# This is LVM container encryption called box1:
partition: /root (/) 15 GB | FILE SYSTEM: ext4
partition: /tmp 2GB | FILE SYSTEM: ext4 | mount with: nosuid, noexec
partition: swap 4GB
partition: /home 60GB (or the rest space left) | FILE SYSTEM: ext4| mount with: nosuid
|
It's working! First as mentioned by @cas, I made a mistake when declaring the size of the home directory where I accidentally used the size of the overall disk. But the main problem here is the syntax error that prevented home directory from created. Surprisingly, the debconf-set-selections that has syntax checker using an option -c did not complain about this error in preseed file. What I did was, put this missing dot (without \ symbol)
.
after this line:
$lvmok{ } lv_name{ home } \
in_vg { box1 } \
method{ format } format{ } \
use_filesystem{ } filesystem{ ext4 } \
mountpoint{ /home } \
options/nosuid{ nosuid } \
So it will look like this:
$lvmok{ } lv_name{ home } \
in_vg { box1 } \
method{ format } format{ } \
use_filesystem{ } filesystem{ ext4 } \
mountpoint{ /home } \
options/nosuid{ nosuid } \
.
| Debian preseed does not create encrypted disk with LUKS LVM properly |
1,484,357,934,000 |
Using an Ubuntu 12.04 or a Red Hat Enterprise Linux Desktop 6 for Desktop, how can we force the users to change their LUKS passwords at every 90 days?
|
There's not much point in doing this. Ordinarily, the point of changing passwords regularly is that if someone else has learned your password, you limit how long they can use it. But a LUKS password is used to decrypt the LUKS volume's master key, the one that's actually used to encrypt the data, so if someone learns your password, they can use it to get that master key. Changing your password doesn't change the master key — remember, it's the key used to actually encrypt the data; changing it would require re-encrypting the entire drive — so you're not depriving the attacker of access to the drive.
(Note, this assumes a technically-sophisticated attacker, someone able to find or write a program for unlocking a LUKS volume using the master key directly rather than a keyslot passphrase. Changing passwords might help against someone who only knows how to interact with the normal LUKS password prompt — but against someone like that, you probably don't need disk encryption at all.)
| How to force the change of the LUKS password in every 90 days? |
1,484,357,934,000 |
The documentation contains:
Successfully decrypted disks are named as (cryptoX) and have increasing numeration suffix for each new decrypted disk. If the encrypted disk hosts some higher level of abstraction (like LVM2 or MDRAID) it will be created under a separate device namespace in addition to the cryptodisk namespace.
Documentation
My grub.cfg contains the command cryptomount -a. When I boot, I get a passphrase request and a message that the corresponding slot was successfully opened, but the partition can't be found and the system doesn't start. I've opened the Grub command line and manually called cryptomount -a. The command was successful but I can't find any new devices under /dev. The encrypted partition contains an LVM PV and I can't neither see the decrypted device nor the LVs. Where can I find the decrypted disks?
When I decrypt the encrypted device in initramfs with cryptsetup, everything works as expected and I can start the system.
|
Like the documentation says, GRUB will know the first decrypted disk as (crypto0) if it is a regular partition. If it is some other abstraction, e.g. a LVM PV, then any detected LVs should appear as (lvm/<vgname>-<lvname>), although the documentation for this is currently extremely hard to find: I had to read the source code to find it.
Linux software RAID devices will apparently be known in GRUB by names like (md/<RAID array name or number>), and can also be referenced by (mduuid/<long hex number>).
To list all detected disks/partitions/LVs in GRUB prompt, type ls ( and press Tab.
Any device paths starting with /dev/ are meaningless for GRUB at boot time, as the kernel that would implement the device nodes in /dev/ is not running yet. They might be meaningful as kernel boot parameters, but for GRUB itself, they are just strings with no special meaning.
| Where does cryptomount in Grub create decrypted disks |
1,484,357,934,000 |
Ive been at this all day. I've scoured the web and this board and have tried many solutions to this issue but nothing has seemed to work. Someone on here asked a similar question and the solution did not help.
I feel I'm close but don't know how to follow through. Pulled my NVME drive and hooked it via USB to my Linux Mint machine. I can see the drive and I can unlock the drive with my passphrase but I can't mount it. Shouldn't it mount when I unlock it?
What am I doing wrong? What can I do to get this to mount?
Do I have to decrypt the main LVM2 Physical Volume (LVM2 001) first? or just focus on the LUKS partition?
below is some of info and line commands Ive tried. Thank you all. Any help is greatly appreciated.
$ sudo lsblk -f
NAME FSTYPE LABEL UUID FSAVAIL FSUSE% MOUNTPOINT
sda
├─sda1 ext4 a7987e8b-cdc7-43b8-9d3f-0fe58103bd71 160.7M 70% /boot
├─sda2
└─sda5 crypto 44697cdf-8332-4595-870d-21296693002e
└─sda5_crypt
LVM2_m QXqf19-8D7z-W9pC-QkI2-t8Hc-CCek-XuH9TU
├─mint--vg-root
│ ext4 bb06e16e-d776-4282-88d2-c91120979c02 1.6T 4% /run/times
└─mint--vg-swap_1
swap 25824eea-25c6-453a-8d21-704fd2a4be90 [SWAP]
sdd
├─sdd1 vfat DCEE-4749
├─sdd2 ext4 71f85328-bae1-4179-9a6a-8cf6661730e7 342.2M 44% /media/t/7
└─sdd3 crypto 2e3b8613-e988-4aff-a4ba-0915ce305bb4
└─crypted_sdd3
LVM2_m 1UwgAt-xngX-SlvP-bl8w-0rRu-pLGt-XcBHYN
$ sudo lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root mint-vg -wi------- <1.82t
root mint-vg -wi-ao---- <1.82t
swap_1 mint-vg -wi------- 976.00m
swap_1 mint-vg -wi-ao---- 976.00m
$ sudo vgs
VG #PV #LV #SN Attr VSize VFree
mint-vg 1 2 0 wz--n- <1.82t 0
mint-vg 1 2 0 wz--n- <1.82t 0
I've tried to mount sdd3 many times and no luck
$ mount /dev/sdd3
mount: /dev/sdd3: can't find in /etc/fstab.
$ sudo mount /dev/mapper/recoverytarget /mnt/recoverytarget
mount: /mnt/recoverytarget: special device /dev/mapper/recoverytarget does not exist.
$ sudo cryptsetup open /dev/sdd3 luksrecoverytarget --type luks
Enter passphrase for /dev/sdd3:
Device luksrecoverytarget already exists.
$ sudo lsblk -f /dev/sdd3
NAME FSTYPE LABEL UUID FSAVAIL FSUSE% MOUNTPOINT
sdd3 crypto 2e3b8613-e988-4aff-a4ba-0915ce305bb4
└─crypted_sdd3
LVM2_m 1UwgAt-xngX-SlvP-bl8w-0rRu-pLGt-XcBHYN
$ sudo /dev/mapper/crypted_sdd3 /mnt/2e3b8613-e988-4aff-a4ba-0915ce305bb4 ext4 defaults 0 0
sudo: /dev/mapper/crypted_sdd3: command not found
$ sudo mount -av
/ : ignored
/boot : already mounted
none : ignored
$ sudo blkid | grep crypto
/dev/sda5: UUID="44697cdf-8332-4595-870d-21296693002e" TYPE="crypto_LUKS" PARTUUID="5f1dfb0d-05"
/dev/sdc3: UUID="2e3b8613-e988-4aff-a4ba-0915ce305bb4" TYPE="crypto_LUKS" PARTUUID="0be31b07-df9d-43c6-a0d4-ef4e8be65bd0"
$ sudo cryptsetup luksOpen /dev/sdc3/ crypthome
Device /dev/sdc3/ doesn't exist or access denied.
$ sudo vgchange -an --select vg_uuid=f0u7eE-zgoH-mDLS-x7Rs-3RGe-uoob-OFcht2 Volume group "mint-vg" successfully changed 0 logical volume(s) in volume group "mint-vg" now active
$ sudo vgexport --select vg_uuid=f0u7eE-zgoH-mDLS-x7Rs-3RGe-uoob-OFcht2 Volume group "mint-vg" successfully exported
$ sudo pvscan
Error reading device /dev/mapper/luksrecoverytarget at 0 length 512.
Error reading device /dev/mapper/luksrecoverytarget at 0 length 4096.
PV /dev/mapper/luks-2e3b8613-e988-4aff-a4ba-0915ce305bb4 is in exported VG mint-vg [<1.82 TiB / 0 free]
PV /dev/mapper/sda5_crypt VG mint-vg lvm2 [<1.82 TiB / 0 free]
Total: 2 [<3.64 TiB] / in use: 2 [<3.64 TiB] / in no VG: 0 [0 ]
$ sudo vgimport --select vg_uuid=f0u7eE-zgoH-mDLS-x7Rs-3RGe-uoob-OFcht2
Volume group "mint-vg" successfully imported
$ sudo mkdir -p /mnt/--select vg_uuid=f0u7eE-zgoH-mDLS-x7Rs-3RGe-uoob-OFcht2/users
$ sudo mount /dev/--select vg_uuid=f0u7eE-zgoH-mDLS-x7Rs-3RGe-uoob-OFcht2/users
mount: /home/t/vg_uuid=f0u7eE-zgoH-mDLS-x7Rs-3RGe-uoob-OFcht2/users: special device /dev/--select does not exist.
$ sudo mount /dev/mapper/luks-2e3b8613-e988-4aff-a4ba-0915ce305bb4 /mnt/recoverytarget
mount: /mnt/recoverytarget: unknown filesystem type 'LVM2_member'.
$ sudo mount /dev/sdb3 /mnt/recoverytarget
mount: /mnt/recoverytarget: unknown filesystem type 'crypto_LUKS'.
$ sudo vgimport --select vg_uuid=f0u7eE-zgoH-mDLS-x7Rs-3RGe-uoob-OFcht2 /dev/sdb3
Volume group "sdb3" not found
Cannot process volume group sdb3
|
You have a filesystem on top of LVM on top of LUKS partition.
The system can automatically hot-plug the disk, read the partition table and auto-detect the partition table, but because the next layer is LUKS, the automatic processing will stop there.
You'll need to proceed through the remaining layers in order.
First, sudo cryptsetup open /dev/sdd3 luksrecoverytarget --type luks will unlock the LUKS layer and present it in unencrypted form as /dev/mapper/luksrecoverytarget.
But in your case, it's not a straight filesystem, but a LVM physical volume. Before the filesystem can be accessed, the LVM volume group needs to be activated first.
Depending on the udev rules of your distribution, the system may or may not auto-detect the LVM volume group on creation of /dev/mapper/luksrecoverytarget. To be sure, you can run sudo vgscan after unlocking the LUKS layer: this way, you will also see an error message if all the parts of the volume group are not accessible (e.g. if the volume group has been extended to another disk in its original location). After that, the normal procedure would be to run sudo vgchange -ay to explicitly attempt to activate any detected LVM volume groups.
But you seem to have the additional complication of a volume group naming conflict: if the name of the volume group matches the name of an already existing VG, you'll need to change the name of the VG before you can activate it.
To deconflict the VG on the transferred disk, you'll need to identify the VG to rename by its LVM VG UUID. You'll need a command like this:
sudo vgrename f0u7eE-zgoH-mDLS-x7Rs-3RGe-uoob-OFcht2 recoverymint-vg
After that, you should be able to activate the VG with
sudo vgchange -ay recoverymint-vg
Since a LVM volume group may contain more than one filesystem (even if it's just one LVM physical volume), the typical auto-mount systems may consider it too complex for auto-mounting. So the next step would be to run e.g. sudo lvs to verify the name(s) of the LVM logical volume(s) contained within the volume group, and then mount it.
In Linux LVM2 (= the current, non-ancient version), the vgexport/vgimport commands are only really needed when you are making a planned move of LVM disks containing a VG that is known or suspected to cause a conflict on the destination system.
Essentially running vgexport on the source system before the disk(s) are moved will tell the destination system "I'm pretty sure you don't want me; find the other one with the same name". This enables the destination system to boot successfully even in the presence of a VG name conflict.
If you add the disks to the destination system by hot-plugging, LVM is smart enough to prefer an already activated VG over a suddenly appearing potential usurper that just happens to have the same name, but a different VG UUID.
Even a cloned VG with the same UUIDs will be handled correctly if the VG was inactive at the time of cloning: the already-activated version of the VG will take priority over the inactive extra copy, and LVM commands will complain loudly about the out-of-sync extra copy and refuse to do make any changes to the cloned VGs until the extra copy has been given a distinct identity by changing its UUIDs.
(I had to untangle some LVM volume group conflicts in a system that extensively used SAN storage-based on-line snapshots as a first step in cloning disks. No production data was lost, mostly because Linux LVM steadfastly refused to make any state changes once a conflict was detected, until the people responsible for the mess recognized they were in over their heads and started looking for help.)
| How To MOUNT A LUKS Encrypted Linux Filesystem Unlocked Partition VIA USB on another LINUX OS to retrieve files |
1,484,357,934,000 |
I recently created a LUKS2 device with a native --offset of 4MiB. The file command correctly identifies the device and lists its UUID, but it is neither auto-opened at boot nor visible in /dev/disk/by-uuid/... (even after update-initramfs).
Manually running cryptsetup open works as expected but cryptdisks_start fails to open it. It is specified with UUID= in /etc/crypttab like my other devices. Using the "parent" block device path instead of its UUID works.
Inspection with xxd shows the correct magic number ("LUKS" at offset 0) and the header starting at the same offset as my other LUKS2 devices (which are correctly detected). Why is this device failing to be detected? What can I do to allow me to open it via its UUID?
|
Technically, the kernel here is not at fault. The only kernel's involvement here is with the dmcrypt device mapper device configured by cryptsetup.
cryptsetup is able to configure the device mapper device based on the metadata as stored on the block device so is not at fault either.
The fact that there's no /dev/disk/by-uuid entry for the LUKS device stored there points at udev or whatever is responsible to discovering LUKS devices (see also the output of udevadm info /dev/the-block-device).
udev uses blkid (well, the builtin version see rules in /lib/udev/rules.d/60-persistent-storage.rules on Debian for instance) to find out about those.
In your case, blkid reports TYPE="jmicron_raid_member". If it's a RAID array member, it shouldn't be accessed directly, so blkid is right not to try and report what may be stored inside.
If it's not meant to be a jmicron_raid_member, then maybe it just happens to still contain the signature for some RAID configuration, for instance because the SSD used to be connected to a PC with ATA Mode set to RAID instead of AHCI in the BIOS (and you forgot to run blkdiscard before reusing it). Or maybe the 512th last byte happens to be J and 511th M by accident.
For blkid to stop detecting it as a jmicron_raid_member if you're sure it's not meant to be and the last 512-byte unit is otherwise not in use by anything, you'd need to wipe the RAID signature, which for jmraid is apparently found in the last 512 byte unit of the block device, either by hand with something like:
size=$(blockdev --getsize -- "$dev") &&
dd if=/dev/zero of="$dev" seek="$((size - 1))" count=1
Or using util-linux' wipefs:
wipefs -t jmicron_raid_member -- "$dev"
to list the signature.
wipefs -a -t jmicron_raid_member -n -- "$dev"
To show what it would erase.
wipefs -a -t jmicron_raid_member -- "$dev"
To erase.
| The `file` command correctly identifies my LUKS device but the kernel doesn't see it |
1,484,357,934,000 |
Can I use luks (as in OpenSSL) to encrypt bash output?
e.g with OpenSSL:
echo "test" | openssl .....
Can I do that with Luks/Cryptsetup in some way? Like this:
echo "test" | Luks...
|
LUKS is not a command, it is name of a technology and/or metadata format so no, you can't use LUKS for encrypting strings. Same applies for cryptsetup which is only a userspace tool (library) for configuring and managing the LUKS/dm-crypt devices and doesn't do the encrypting itself -- data written/read to/from the device is encrypted by the device mapper crypto plugin in kernel using the kernel crypto API, cryptsetup only tells kernel to create such device and provides encryption key for it (and also takes care of key management) everything else happens in device mapper.
If you only want to use cryptsetup in a non-interactive way to create an encrypted device, that is of course possible:
printf %s "$password" | cryptsetup luksFormat /dev/sdxY -
and similarly for unlocking the device
printf %s "$password" | cryptsetup luksOpen /dev/sdxY name -
and then you can write your data to /dev/mapper/name and close it afterwards using cryptsetup close name.
You can create a disk image and use it directly (so cryptsetup luksOpen disk.img name instead of using a block device), but to actually encrypt something you still need to write it to the created device mapper device.
| Is it possible to use luks on output in bash? |
1,484,357,934,000 |
My luks encrypted lvm is running out of space.
I want to extend the volume group with a new physical volume.
Will the data on that physical volume be encrypted automatically when added to the volume group?
Do I maintain encryption when extending a luks encrypted lvm with a physical volume?
|
Depends on where (on what level) is your encryption configured. Usually you have encrypted physical volumes (so the stack looks like partition->luks/dm-crypt device->physical volume->volume group->logical volumes), in this case you need to make sure the new PV is also encrypted. But you can also have encrypted logical volumes (in this case the luks/dm-crypt device is on top of the LV) in this case you just need to make sure to resize the LV correctly after adding the second PV and all data on the LV will still be encrypted.
| Do I maintain encryption when extending a luks encrypted lvm with a physical volume? |
1,484,357,934,000 |
I have an external USB disk with ext4 unencrypted:
/dev/sda1 3.6T 2.9T 613G 83% /data
I wish to encrypt this disk without losing data. I migrated this disk from Raspberry3 to Raspberry4, because of better performance I now wish to encrypt.
I read about Filesystem stacked level encryption and Block device-level encryption, but it seems LUKS the most secure and the Debian standard.
I read this guide:
WARNING! The following command will remove all data on the partition that you are encrypting. You WILL lose all your information! So make
sure you backup your data to an external source such as NAS or hard
disk before typing any one of the following commands.
# cryptsetup -y -v luksFormat /dev/xvdc
I can't copy the 4 TB data to another disk, because I have no disk with that much capacity.
How to encrypt this disk without backup/restore the existing data? Is it possible?
|
It's possible, but with all in-place conversions, there is a certain risk of data loss.
To make room for the LUKS header, unless you intend to use an external header, you must first shrink the filesystem (with resize2fs if it's ext4). For LUKS1, you should shrink it by 2MiB. For LUKS2, you can shrink it by 4M, 16M or up to 64M. If you intend to use advanced features (dm-integrity) you might have to shrink it even more.
Alternatively to shrinking, you could also make the partition larger, if the disk partition layout allows for that.
Encrypt existing data using the offline cryptsetup-reencrypt utility: (not installed by all distributions, might be in a separate package, otherwise grab from source)
# cryptsetup-reencrypt --new --type luks1 --reduce-device-size 2M /dev/sdXn
Enter new passphrase:
Verify passphrase:
[A wild progress bar appears.]
Using the online cryptsetup reencrypt for LUKS2:
# cryptsetup reencrypt --new --reduce-device-size 16M /dev/sdXn
WARNING!
========
This will overwrite data on LUKS2-temp-2c9761be-a765-4349-aa0a-553203e534f1.new irrevocably.
Are you sure? (Type uppercase yes):
Enter passphrase for LUKS2-temp-2c9761be-a765-4349-aa0a-553203e534f1.new:
Verify passphrase:
[A wild progress bar appears.]
So this works, provided no power or cable blips happened during the entire process.
As the cryptsetup-reencrypt man page puts it:
ALWAYS BE SURE YOU HAVE RELIABLE BACKUP BEFORE USING THIS TOOL.
| How to encrypt an external disk without backing-up/restoring the existing data? |
1,484,357,934,000 |
I am trying to setup a full-encrypted Debian os, alongside my preinstalled unencrypted Ubuntu.
so far, I have(traditional BIOS) installed the Debian with the following scheme..
/boot as extended partition; format-ext4 (unencrypted)
LVM on LUKS:
/ partition -ext4 (encrypted),
SWAP (encrypted)
grub2 of Debian, installed on /boot instead MBR, since Ubuntu's grub2 is my primary bootloader.
then from Ubuntu side, I mounted /boot & LVM partitions, then updated grub.
but, my grub2 dont recognize Debian.
What should I do next ??
|
I also tried an alternative method with grub2.
I made a mistake when mounting the logical root partition. Since, I am not good with cli, so I wanted not to mess with grub2 config file. However, grub2 can handle LVM2 & LUKS partitions efficiently. look here (https://wiki.gentoo.org/wiki/GRUB2#Extended_features).
So,here what I tried alternatively
step1, mounted the /boot partition.
step2, $ sudo modprobe dm-crypt | grep dm-crypt
step3, unlock the luks-encrypted partition with 'cryptsetup' command.
step4, run $ sudo pvscan | vgscan | lvsacan
step5, activate the volume-group
step6, mount the logical root volume. No need to mount the logical swap.
step7, sudo update-grub
Done!
Grub2 will autodetect the installed OS & list it on grub menu.
| How to boot an encrypted Debian, from an unencrypted Ubuntu? |
1,484,357,934,000 |
Which command would you suggest to use in order to find out whether a LUKS encrypted partition is mapped or not (other than looking at or using lsblk output)?
By opened device, I mean a device for which the command
ctrytpsetup luksOpen <device> <map name>
was executed.
|
I would do it like this:
$ sudo dmsetup ls
crypthome (254:0)
$ sudo dmsetup -v table /dev/mapper/crypthome
Name: crypthome
State: ACTIVE
Read Ahead: 256
Tables present: LIVE
Open count: 1
Event number: 0
Major, minor: 254, 0
Number of targets: 1
UUID: CRYPT-LUKS1-87863643a6aa43c191f69ee3a2b3301a-crypthome
0 870313984 crypt aes-xts-plain64 0000000000000000000000000000000000000000000000000000000000000000 0 8:2 4096
| How to find out whether a LUKS encrypted partition is opened of closed? |
1,484,357,934,000 |
I have an encrypted crypt-luks partition that is currently named sda3, and is the last partition on the disk, that is, there are no sda4 or sda5. The encrypted partition contains three logical volumes containing the filesystem.
Is there anyway I can rename the partition from sda3 to sda5? This is a new installation, and I don't mind losing data. I'll be using a recovery USB stick to renumber the partition if this is at all possible.
I tried using gdisk with the advanced mode, and renamed the disk using the t option. Now however I cannot boot from the disk: It asks for the encryption password and loops back when entered. What is the correct way of doing this?
(For those curious, I need this is due to an automatic script that expects my encrypted partition to be on sda5. Unfortunately, the script is run at boot over a network, and I don't have control over it.)
|
The following solution is based on the forum posting udev rule for a symlink
You have /dev/sda3 and you want to create a symlink to it to synthesise an entry for the missing device named /dev/sda5:
cd /dev && ln -s sda3 sda5
This can be managed at boot time within udev with a simple rule that matches the block device sda3.
Create the file /etc/udev/rules.d/80-local, or use a similarly named file, and add these lines to it:
# symlink existing /dev/sda3 to new sda5
SUBSYSTEM=="block", KERNEL=="sda3" SYMLINK+="sda5"
In case you're curious, I picked the SUBSYSTEM and KERNEL values as suitable matches by reviewing the output of udevadm info -a -n /dev/sda3. (I would have preferred to match on a UUID or other unique identifier but I couldn't find one.)
Now tell udev to reload its rules and trigger any new matches:
udevadm control --reload-rules
udevadm trigger --attr-match=subsystem=block
and you will see the symlink automatically created:
ls -l /dev/sda5
lrwxrwxrwx 1 root root 4 Jan 7 17:18 /dev/sda5 -> sda3
I have not been able to test this next step, but depending on where in the boot process you need this symlink to be created you may find it's necessary to update your initramfs. On my Debian system that's done like this:
update-initramfs -u
| Renumber encrypted partition - sda3 to sda5 |
1,484,357,934,000 |
I have a specific situation. On Debian there are additional 3 disks and they are Luks encrypted. After decryption these disks are configured to ZFS pool RAIDZ (Raid5).
After server reboot I need to unlock these three disks one by one and after 2nd disk is unlocked ZFS pool comes online but in degraded state because 3rd disk is not reachable and it stays in that condition despite I unlock the 3rd drive also.
I have to manually run command:
zpool online <pool> <device>
And after that zpool becomes okay.
I would like to somehow unlock all three disks at once do bypass this situation of going ZFS pool to degraded state.
I found this post:
Using a single passphrase to unlock multiple encrypted disks at boot
And answered solution works perfect but the problem is that the passphrase needs to be inputted during boot and in my environment there are some servers where I don't have access to console so I would not be able to enter my passphrase on these. That's why I'm looking for a solution to unlock these drives after system boots and I can access it via SSH.
|
This doesn’t answer your titular question, but it will allow you to unlock your LUKS devices via SSH before the system has finished booting. If you install dropbear-initramfs, you’ll get a lightweight SSH server in early boot. This only supports key-based logins, and you’ll have to add authorized public keys to /etc/dropbear/initramfs/authorized_keys. You’ll also need to ensure that the modules required for your network hardware are available in your initramfs (add them to /etc/initramfs-tools/modules). See /usr/share/doc/dropbear-initramfs/README.Debian for details.
Install cryptsetup-initramfs to also get cryptsetup support in the initramfs. With that in place, you can run
ssh -t [email protected] cryptroot-unlock
to unlock the LUKS devices on the target system. See /usr/share/doc/cryptsetup/README.Debian section 8 for details.
| Debian unlock multiple Luks encrypted disks with passphrase AFTER boot |
1,673,544,383,000 |
I have a LUKS encrypted partition on a second hard drive that I use on my computer. When I turn on my computer, it is encrypted unless I go to it and try to open it, an operation that the system then does on its own because when I did it for the first time I left the password recorded. That is, I click on it and the system mounts it unencrypted for me.
It turns out that for some time now, this operation has been mounting the partition on the HD in question as read-only. It was never like that, it was always mounted with write privileges too. What can I do to solve this problem?
I have the partition password. My operating system is POP OS 22.04.
Another thing: I noticed that there are times when I mount the partition, in the beginning I can, for example, create folders and everything, then a while passes, I can't do it anymore. It's like it went from read-write to read-only.
UPDATE 1:
I used dmesg and found this information:
[ 97.995228] EXT4-fs warning (device dm-3): ext4_clear_journal_err:6017: Filesystem error recorded from previous mount: IO failure
[ 97.995233] EXT4-fs warning (device dm-3): ext4_clear_journal_err:6019: Marking fs in need of filesystem check.
[ 98.027267] EXT4-fs (dm-3): warning: mounting fs with errors, running e2fsck is recommended
[ 98.061947] EXT4-fs (dm-3): recovery complete
[ 98.061957] EXT4-fs (dm-3): mounted filesystem with ordered data mode. Quota mode: none.
[ 104.026099] EXT4-fs error (device dm-3): ext4_validate_block_bitmap:390: comm ext4lazyinit: bg 3999: bad block bitmap checksum
[ 104.026106] Aborting journal on device dm-3-8.
[ 104.065619] EXT4-fs (dm-3): Remounting filesystem read-only
[ 398.089528] EXT4-fs (dm-3): error count since last fsck: 1804
[ 398.089540] EXT4-fs (dm-3): initial error at time 1671056071: ext4_lookup:1836: inode 32640029
[ 398.089552] EXT4-fs (dm-3): last error at time 1673554480: ext4_validate_block_bitmap:390
[ 552.946132] EXT4-fs (dm-3): unmounting filesystem.
[ 781.480164] EXT4-fs warning (device dm-3): ext4_clear_journal_err:6017: Filesystem error recorded from previous mount: IO failure
[ 781.480171] EXT4-fs warning (device dm-3): ext4_clear_journal_err:6019: Marking fs in need of filesystem check.
[ 781.521341] EXT4-fs (dm-3): warning: mounting fs with errors, running e2fsck is recommended
[ 781.547854] EXT4-fs (dm-3): recovery complete
[ 781.568344] EXT4-fs (dm-3): mounted filesystem with ordered data mode. Quota mode: none.
[ 787.456453] EXT4-fs error (device dm-3): ext4_validate_block_bitmap:390: comm ext4lazyinit: bg 3999: bad block bitmap checksum
[ 787.456460] Aborting journal on device dm-3-8.
[ 787.488395] EXT4-fs (dm-3): Remounting filesystem read-only
|
The system log extract reveals that this is not a problem with LUKS encryption, but with the "usage" of the unlocked EXT4 file system on the encrypted partition: at some point in the past, a filesystem inconsistency occurred, e.g. due to it being removed without properly unmounting, power outage, or any other reasons. The error was noted when the filesystem driver tried to start the journal of the file system
Quote:
ext4_clear_journal_err:6017: Filesystem error recorded from previous mount: IO failure
This means that the filesystem is in a "bad" state, and is in need of repair.
Quote:
warning: mounting fs with errors, running e2fsck is recommended
For the moment, the file system is mounted, but with the advice to perform a filesystem check. It is not recommended to use any write operations on filesystems in that state.
Ultimately, the kernel notices further inconsistencies in the filesystem structure
EXT4-fs error (device dm-3): ext4_validate_block_bitmap:390: comm ext4lazyinit: bg 3999: bad block bitmap checksum
For that reason, the kernel has decided to mount it read-only so that you can access files, but not perform any further modifications that may aggravate the internal inconsistency (to the point where it may actually be corrupted). You can see from the timestamps that it takes a moment for that to happen, so there may be a short time window when you actually can (but still shouldn't) write to the partition.
To solve this problem, you should do as the filesystem driver recommends:
Perform a backup of all data on the encrypted partition - it is still readable, after all.
Identify the raw device exposed by LUKS. You can do so by invoking lsblk; the unlocked LUKS partition will be shown as device of type crypt:
~$ sudo lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
...
sdb ..:.. ... ... .. disk
+- sdb1 ..:.. ... ... .. part
+- some_name ..:.. ... ... .. crypt /path/to/mountpoint
Here, all ... are placeholders for actual but varying values. The relevant point is that in the example, the unlocked mapping to the encrypted raw device is /dev/mapper/some_nome, and it is mounted on /path/to/mountpoint.
Unmount the filesystem, but without re-locking the LUKS partition. This needs to be done "manually" because using the "eject" function provided by file managers usually re-locks the partitions in the same process. Make sure no process accesses files or directories on the encrypted partition, then execute
~$ sudo umount /path/to/mountpoint
Perform a file system check on the file system on the unlocked encrypted partition
~$ sudo e2fsck -v /dev/mapper/some_name
You will likely get tons of error messages, and be asked if you want to perform a number of proposed repairs. The exact question depends on the nature of the inconsistency; you will need to consult your favorite search engine on the meaning and to determine if that is a good idea or not.
Once the operation is finished, you can mount the partition again:
~$ sudo mount /dev/mapper/some_name /path/to/mountpoint
| LUKS partition mounting just as read-only |
1,673,544,383,000 |
I followed instructions on Speeding up LUKS decryption in GRUB - GRUB/Tips and tricks - ArchWiki. And I created Full Disk Encryption using the guide: Full_Disk_Encryption_Howto_2019 - Community Help Wiki.
I want to decrease the iterations for my encrypted boot partition:
$ sudo cryptsetup luksDump /dev/nvme0n1p1
LUKS header information for /dev/nvme0n1p1
Version: 1
Cipher name: aes
Cipher mode: xts-plain64
Hash spec: sha256
Payload offset: 4096
MK bits: 512
MK digest: ec 22 27 de c1 ef 40 0f a5 cf 37 d3 96 5c d5 b2 6e c8 dd 90
MK salt: 62 1a 05 81 ba 60 3b 0d b1 8a 9f f0 04 98 27 54
06 b6 8d 72 53 23 09 47 ea 5f 80 1d d7 c5 ca 50
MK iterations: 305173
UUID: 586de9a0-14c7-40d7-b721-7fdba2e3b184
Key Slot 0: DISABLED
Key Slot 1: ENABLED
Iterations: 4882774
Salt: 2a 22 d6 07 a3 48 ad 83 f9 f4 03 a4 a1 e7 95 ab
2c 95 82 cf c1 73 99 1c 74 70 00 5b b8 1b bf 5f
Key material offset: 512
AF stripes: 4000
Key Slot 2: ENABLED
Iterations: 4888466
Salt: 65 fe 32 1d c4 c6 1b 38 28 4c 19 3c c0 27 5a d9
83 92 13 8e f4 84 61 00 b5 f6 6c f8 75 15 36 52
Key material offset: 1016
AF stripes: 4000
Key Slot 3: ENABLED
Iterations: 4888466
Salt: ce 5b b3 e1 f4 85 45 db fd 49 79 71 b1 02 c7 dc
d7 60 a6 36 8b 82 95 20 8e 6e 1d ce 2b 35 1b 13
Key material offset: 1520
AF stripes: 4000
Key Slot 4: DISABLED
Key Slot 5: DISABLED
Key Slot 6: DISABLED
Key Slot 7: DISABLED
We can see that 3 slots are enabled.
Changing the number of iterations
$ sudo cryptsetup luksChangeKey --pbkdf-force-iterations 1000 /dev/nvme0n1p1
Enter passphrase to be changed:
Enter new passphrase:
Verify passphrase:
$ sudo cryptsetup luksDump /dev/nvme0n1p1
LUKS header information for /dev/nvme0n1p1
Version: 1
Cipher name: aes
Cipher mode: xts-plain64
Hash spec: sha256
Payload offset: 4096
MK bits: 512
MK digest: ec 22 27 de c1 ef 40 0f a5 cf 37 d3 96 5c d5 b2 6e c8 dd 90
MK salt: 62 1a 05 81 ba 60 3b 0d b1 8a 9f f0 04 98 27 54
06 b6 8d 72 53 23 09 47 ea 5f 80 1d d7 c5 ca 50
MK iterations: 305173
UUID: 586de9a0-14c7-40d7-b721-7fdba2e3b184
Key Slot 0: ENABLED
Iterations: 4888466
Salt: 93 c2 c4 fe 95 ab 24 44 9e dd 26 90 c1 cf a2 66
19 80 d3 4b f9 e8 b3 5a 0e a1 9f 6a de d8 60 ea
Key material offset: 8
AF stripes: 4000
Key Slot 1: ENABLED
Iterations: 4882774
Salt: 2a 22 d6 07 a3 48 ad 83 f9 f4 03 a4 a1 e7 95 ab
2c 95 82 cf c1 73 99 1c 74 70 00 5b b8 1b bf 5f
Key material offset: 512
AF stripes: 4000
Key Slot 2: ENABLED
Iterations: 1000
Salt: 65 fe 32 1d c4 c6 1b 38 28 4c 19 3c c0 27 5a d9
83 92 13 8e f4 84 61 00 b5 f6 6c f8 75 15 36 52
Key material offset: 1016
AF stripes: 4000
Key Slot 3: DISABLED
Key Slot 4: DISABLED
Key Slot 5: DISABLED
Key Slot 6: DISABLED
Key Slot 7: DISABLED
Questions
After changing the number of iterations, we can see that previously keyslot 0 was disabled and not it has got enabled. Is it a random assignment of key slots? Is that important?
To speed up the boot, do I require to decrease the iterations of all keyslot to 1000? As, I remember key slots are checked sequentially.
How can I make iterations as 1000 for all key slots?
Is the information displayed by above commands private and should not be shared?
|
(1.) cryptsetup swaps keyslots around for internal reasons, unfortunately you just have to deal with it.
From the cryptsetup luksChangeKey manpage:
If a key-slot is specified (via --key-slot),
the passphrase for that key-slot must be given
and the new passphrase will overwrite the
specified key-slot.
If no key-slot is specified and there is still
a free key-slot, then the new passphrase will
be put into a free key-slot before the key-slot
containing the old passphrase is purged.
If there is no free key-slot, then the key-slot
with the old passphrase is overwritten directly.
It also mentions one of the reasons why it prefers to shuffle the keyslots around:
WARNING: If a key-slot is overwritten, a media
failure during this operation can cause the
overwrite to fail after the old passphrase has
been wiped and make the LUKS container
inaccessible.
Some cryptsetup commands let you specify the keyslot to be used, e.g. you can remove a specific slot or add a new key to a specific free slot. So there are various ways to get the keys in the order you want.
(2.) It's preferable to put the key you most often use into the first slot. Otherwise the slow slots will be tried first. It's also possible to specify the desired keyslot on cryptsetup open, but GRUB probably doesn't support it.
For LUKS 2, the keys are also not tried in keyslot order at all. Instead it depends on the order stored in the JSON metadata, as well as a keyslot priority you can set with cryptsetup config --priority, but I don't know if GRUB would honor that.
(3.) By changing each of them, or otherwise by removing the offending ones. (Consider making a backup of the LUKS header before removing keys, as it's possible to lock yourself out this way.)
(4.) It's not possible to derive a LUKS master key or passphrase from luksDump output as the key material is missing entirely. But if you lose this drive somewhere and whoever found it googles the UUID, they might find your post and identify you this way…
| Speeding up LUKS decryption in GRUB using pbkdf-force-iterations |
1,673,544,383,000 |
I was trying to dual boot Arch on my MacBook. At first, I tried to install Arch with LUKS encryption. Unfortunately, in the middle of a guide, I understood that it was a bit outdated and I didn't have the knowledge to proceed with installation without a guide, so I erased everything and started from scratch, this time without encryption. It was good until I was unable to mount /dev/<appleEFIpartition> /mnt/boot (as in this guide) because of the wrong filesystem, namely, crypto_LUKS. I was really surprised at how this was possible as I didn't encrypt my mac bootloader, and it still works flawlessly, I can boot into macOS and use it without any problems (I would expect my computer to break if I encrypted my bootloader). I decided to double-check and mac's diskutil says that my EFI is FAT32 (no mention of crypto_LUKS for any volume).
I am super confused about how this is possible. Here are screenshots of me checking the filesystem first on the arch installation medium and then using diskutil from macOS.
|
Normally, LUKS header does not survive formatting.
Setup:
# truncate -s 100M foobar.img
# losetup --find --show foobar.img
/dev/loop0
# parted /dev/loop0 mklabel gpt mkpart boot 1MiB 100%
LUKS:
# cryptsetup luksFormat /dev/loop0p1
# wipefs /dev/loop0p1
DEVICE OFFSET TYPE UUID LABEL
loop0p1 0x0 crypto_LUKS d9a4c128-1cb9-4252-a7ec-697ae4c35535
loop0p1 0x4000 crypto_LUKS d9a4c128-1cb9-4252-a7ec-697ae4c35535
FAT:
# mkfs.vfat /dev/loop0p1
# wipefs /dev/loop0p1
DEVICE OFFSET TYPE UUID LABEL
loop0p1 0x36 vfat 524F-02F3
loop0p1 0x0 vfat 524F-02F3
loop0p1 0x1fe vfat 524F-02F3
So, after mkfs.vfat, the crypto_LUKS header signature is gone.
However, this is after all Linux... where the LUKS header is a known thing, so it stands to reason that it will be wiped. In another OS that does not use LUKS, it might be a different matter.
After repairing the wiped LUKS header, it's possible to have both:
# wipefs /dev/loop0p1
DEVICE OFFSET TYPE UUID LABEL
loop0p1 0x0 crypto_LUKS key to try again ...
loop0p1 0x4000 crypto_LUKS
loop0p1 0x36 vfat 615E-AF44
loop0p1 0x1fe vfat 615E-AF44
At this point, the filesystem still mounts fine, if specified:
# mount /dev/loop0p1 /mnt/foobar
mount: /mnt/foobar: unknown filesystem type 'crypto_LUKS'.
dmesg(1) may have more information after failed mount system call.
# mount -t vfat /dev/loop0p1 /mnt/foobar
# grep foobar /proc/mounts
/dev/loop0p1 /mnt/foobar vfat rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro 0 0
So we have both LUKS and vfat magics on the same device.
At this point, you can use wipefs to remove just the LUKS headers:
# umount /mnt/foobar
# wipefs -a -t crypto_LUKS /dev/loop0p1
/dev/loop0p1: 6 bytes were erased at offset 0x00000000 (crypto_LUKS): 4c 55 4b 53 ba be
/dev/loop0p1: 6 bytes were erased at offset 0x00004000 (crypto_LUKS): 53 4b 55 4c ba be
And it's back to vfat only:
# wipefs /dev/loop0p1
DEVICE OFFSET TYPE UUID LABEL
loop0p1 0x36 vfat 615E-AF44
loop0p1 0x1fe vfat 615E-AF44
and it's detected as such
# file -s /dev/loop0p1
/dev/loop0p1: DOS/MBR boot sector
# blkid /dev/loop0p1
/dev/loop0p1: SEC_TYPE="msdos" UUID="615E-AF44" BLOCK_SIZE="512" TYPE="vfat" PARTLABEL="boot" PARTUUID="e3d8e408-2e48-45c4-bd6d-9be685d95ed5"
and it mounts with filesystem auto detection again so -t vfat is no longer necessary
# mount /dev/loop0p1 /mnt/foobar
| lsblk says that filesystem of EFI partition is crypto_LUKS, while diskutil says that it's FAT32 (dualbooting arch/mac) |
1,673,544,383,000 |
When using cryptsetup with LUKS, the manual uses the terms "key" and "size" multiple time, for example:
--keyfile-size (in bytes)
--key-size (in bits)
The allowed values for --key-size is 256 bits (default) or 512 bits.
Later, under the clause 'Default compiled-in key and passphrase parameters:' it says:
Maximum keyfile size: 8192kB, Maximum interactive passphrase length 512 (characters)
I'm getting confused in the meaning of these keys.
What is the point of the key which is related to flag --key-size?
Shouldn't it be the same key which is related to flag --keyfile-size or to the passphrase?
|
--key-size is the size of the volume key, which is the key that encrypts all of the data in the volume. It is automatically generated when you format the volume and is encrypted by your passphrase. --keyfile-size is the maximum number of bytes to read from a keyfile, which you would use if you want to unlock the volume using a file instead of a passphrase. You only need --keyfile-size if you don't want cryptsetup to read the whole file up to the maximum keyfile size.
| cryptsetup with LUKS: key size differences |
1,673,544,383,000 |
When installing Elementary OS, I've chosen too small a size for /boot and it constantly bites me when doing updates.
The rest of the drive is a single LUKS encrypted root partition:
lsblk --fs
NAME FSTYPE LABEL UUID FSAVAIL FSUSE% MOUNTPOINT
...
nvme0n1
├─nvme0n1p1 vfat F37A-4778 224.3M 15% /boot/efi
├─nvme0n1p2 ext4 f68b8c29-141b-4bec-8812-c5203be4f684 41.7M 83% /boot
└─nvme0n1p3 crypto_LUKS 715ee16e-ba60-487a-8944-23b3b561b2bb
└─cryptdata LVM2_member UFo5le-jPA4-5k4d-fpV3-7eGx-fTGR-6mU5Bo
├─data-root ext4 cd4a0015-3306-4c64-988c-83235baca874 581.3G 31% /
└─data-swap swap 65e49edd-8a15-4d30-b966-4df0bcdce12f [SWAP]
I can't simply shrink the encrypted partition to get back the space for my /boot so I wanted to make a backup using fsarchiver, reinstall and then reapply the backup. I think it is the only way to fit the data back into a smaller partition.
I've found this answer: https://unix.stackexchange.com/a/101925 but I am not sure how to use it. AFAIU, I don't have to perform the first step because I want to archive the partition I am currently using nvme0n1p3 which is already opened. So I've cd'ed into an external drive and tried:
sudo fsarchiver savefs `date +%Y_%m_%d`_root.fsa /dev/nvme0n1p3 -v -j11
but I got:
filesys.c#140,devcmp(): Warning: [/dev/fuse] is not a block device
oper_save.c#1037,filesystem_mount_partition(): cannot mount partition [/dev/nvme0n1p3]: filesystem may not be supported by either fsarchiver or the kernel.
removed 2022_04_23_root.fsa
Should I open the partition with cryptsetup somehow? Is it because I didn't use LiveCD?
|
From the man page of fsarchiver:
fsarchiver [ options ] savefs archive device ...
savefs Save device filesystem to archive.
So the device parameter is expected to be a reference to a filesystem. Your parameter /dev/nvme0n1p3 is a device, but it doesn't contain a filesystem. This is why you got the error message:
oper_save.c#1037,filesystem_mount_partition(): cannot mount partition [/dev/nvme0n1p3]: filesystem may not be supported by either fsarchiver or the kernel.
/dev/nvme0n1p3 contains LUKS encrypted data, which (when decrypted) contains LVM data. Your actual ext4 filesystem is in the logical volume data-root, which is listed in your lsblk output. fsarchiver should be able to access the filesystem through this logical volume. So the correct device parameter for fsarchiver would be probably /dev/mapper/data-root.
I don't know if this works in a running system. Creating a backup of a complete filesystem, that is something i prefer to do on a non-mounted or readonly-mounted filesystem (using a LiveCD and cryptsetup).
| Can I backup LUKS encrypted partition with fsarchiver? |
1,673,544,383,000 |
Is there any way to check if a LUKS device is unlocked, without having sudo permissions?
I'm aware of two questions, but all the answers require sudo.
It seems that I've found an indirect way (processing the CleartextDevice value of udisksctl info's output), but even assuming it's a stable solution, it's a hack at best.
Gnome-disks, for example, doesn't require sudo permissions, but it still decodes the locked/unlocked status of LUKS devices.
|
Gnome-disks, for example, doesn't require sudo permissions, but it still decodes the locked/unlocked status of LUKS devices.
GNOME Disks uses UDisks to get the information. There's nothing hacky about it, the CleartextDevice property will be always either / if the device is locked or a valid object path in form of /org/freedesktop/UDisks2/block_devices/dm_2d<num>, where dm_2d<num> translates to dm-<num>, the device mapper cleartext device name (- is encoded as _2d on DBus). If you don't want to parse udisksctl output, you can use busctl to get only the CleartextDevice property. It can also format the output in JSON for simpler parsing.
Locked LUKS device:
$ busctl get-property org.freedesktop.UDisks2 /org/freedesktop/UDisks2/block_devices/sda1 org.freedesktop.UDisks2.Encrypted CleartextDevice -j
{
"type" : "o",
"data" : "/"
}
Unlocked LUKS device:
$ busctl get-property org.freedesktop.UDisks2 /org/freedesktop/UDisks2/block_devices/nvme0n1p3 org.freedesktop.UDisks2.Encrypted CleartextDevice -j
{
"type" : "o",
"data" : "/org/freedesktop/UDisks2/block_devices/dm_2d0"
}
UDisks DBus API is guaranteed to be stable, the object path for the device will be always /org/freedesktop/UDisks2/block_devices/<name>.
But you can always simply check whether the LUKS device has a child. The cleartext device will always be a child of the LUKS device so you can check either from lsblk or from sysfs.
Locked LUKS device:
$ ls /sys/block/sda/sda1/holders/
Unlocked LUKS device:
$ ls /sys/block/nvme0n1/nvme0n1p3/holders
dm-0
| How to check if a LUKS device is unlocked, without sudo permissions? |
1,673,544,383,000 |
Hello I have a question about LUKS encryption. I have used LUKS to encrypt a disk on my server but when I create a file and add content to it, and cat the file, the content is still in plain text. Even when I create a backup of the file, and put it on the non-encrypted hard drive, the data is in plain text. I'm not sure how I can say that encryption is happening. Am I missing something? Is this how LUKS is supposed to work?
/dev/sdb: UUID="d7f667ed-50a4-4324-8708-6720d390bfd2" TYPE="crypto_LUKS"
[root@host1 ~]# cat /opt/my_encrypted_backup/test12
This is a test
[root@host1 ~]# clear
[root@host1 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 8G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 7G 0 part
├─centos-root 253:0 0 6.2G 0 lvm /
└─centos-swap 253:1 0 820M 0 lvm [SWAP]
sdb 8:16 0 1G 0 disk
└─mybackup 253:2 0 1022M 0 crypt /opt/my_encrypted_backup
sr0 11:0 1 1024M 0 rom
[root@host1 ~]#
[root@host1 ~]#
[root@host1 ~]# blkid /dev/sdb
/dev/sdb: UUID="d7f667ed-50a4-4324-8708-6720d390bfd2" TYPE="crypto_LUKS"
[root@host1 ~]#
[root@host1 ~]#
[root@host1 ~]# cat /opt/my_encrypted_backup/test12
This is a test
[root@host1 ~]# cp /opt/my_encrypted_backup/test12 /
[root@host1 ~]# cat /test12
This is a test
[root@host1 ~]#
|
LUKS/dm-crypt works on the block device level, not on the filesystem level so yes, this is correct and this is how it works.
When you open the encrypted device (/dev/sdb in your case) a new virtual device mapper device is created (/dev/mapper/mybackup in your case) on top of it. All data on sdb is encrypted and mybackup is used to access the data in plain -- from system point of view, mybackup contains a normal unencrypted filesystem and everything on it is unecrypted, this way the system can work with encrypted data without need for additional encryption support in every application that reads/writes data to disk.
When data is read from mybackup, device mapper (kernel module) reads the data from sdb and decrypts it before returning it in plain text. Similarly for writes, you write plain text to mybackup and before writing to sdb it's encrypted. So everything on your disk is accessible in plain text when the device is opened.
So your data is "safe" only when the device is not opened. Main use case for LUKS/dm-crypt (or disk encryption in general) is to protect the data in case of your disk (or entire computer) gets stolen. It does not protect the data when the system is running and the device is opened because the master key is stored in memory, you can get it using dmsetup table --showkeys.
| Unable to validate LUKS encryption |
1,673,544,383,000 |
I've made a small mistake, I've removed my boot partition by mistake.
Using testdisk I was able to recover the boot partition without problem but I either misused it or did not understand and only write partition table with my boot partition.
So now my / and swap partition are missing from my system.
I've found this answer from the great Gilles however,
my system is using EFI and my partition is encrypted, does the same solution apply to restore my partition table and what partition format should I use with an encrypted ext4 and swap partition ?
Also in the same question from SuperUser, I've come accross the fact that I should use gdisk and substract 1 to sector size is all those informations accurate and up-to-date ?
Edit 1:
testdisk find those partition with a deep search:
Disk /dev/nvme0n1 - 512 GB / 476 GiB - CHS 488386 64 32
Partition Start End Size in sectors
P EFI System 2048 1619967 1617920 [EFI System Partition] [ESP]
D MS Data 2054 1619973 1617920 [NO NAME]
D EFI System 4096 618495 614400 [EFI System Partition]
D MS Data 4102 618501 614400
D MS Data 37699 43872 6174
D MS Data 43872 50045 6174 [Boot]
D Linux filesys. data 618494 1000206893 999588400
D Linux filesys. data 618496 622591 4096
D Linux filesys. data 618496 1000206895 999588400
D MS Data 374180459 374183338 2880 [NO NAME]
D MS Data 374180483 374183362 2880 [NO NAME]
D MS Data 374181379 374184258 2880 [NO NAME]
>D Linux filesys. data 965039160 965043255 4096
2 of them (the one with 4096 block size) as LUKS.
howerver with "bad structue" and from this mess I've know Idea what I could or should restore.
My orginal disk had a gpt boot partiton, one main encrypted partition and a encrypted swap partition in the end.
My computer is still on and I've been able to backup LUKS header and I have access to all data and relevant informations, I just don't know how to exploit it.
|
Finally I've used testdisk to solve the issue I've identify my other partition :
#main partition
/sys/class/block/nvme0n1p2/start
618496
/sys/class/block/nvme0n1p2/size
964420664
#Swap partition
/sys/class/block/nvme0n1p3/start
965039160
/sys/class/block/nvme0n1p3/size
35167740
So with that in mind I needed to identify my boot drive properly in testdisk and it was this one :
D EFI System 4096 618495 614400 [EFI System Partition]
I selected this selection and add two other partition corresponding to the value found in /sys/class/block.
testdisk uses start and end sector not start sector and count. So to find end sector you need to add comute start+count-1.
As partition type I chooses Luks partition in linux subcategorie. Et voilà.
| Recover partition table from running system and encrypted disk |
1,673,544,383,000 |
Following various guides online, I've attempted to reduce my LUKS-encrypted hard-drive partition (specifically, root / data). I've gotten to the point where GParted recognizes the new unallocated space, but it is "stuck inside" the original partition. In the screenshot below, you can see how the unallocated space is just 1 MB (nothing), but the highlighted data partition is half unallocated internally:
And if you ask what's-up with the data partition, it says it has the unallocated space I want:
So I queue up a resize where I shrink it to to its minimum size (~250 GB), and it shows me this beautiful preview of exactly what I want (giving me the ~198 GB unallocated as a separated partition):
But when I execute the resize, it fails as shown:
It thinks it's already the reduced size? But gah, it doesn't give me that "unallocated space" as a partition! The beautiful preview above reverts back to the first screenshot in this post.
I have also tried the KDE Partition Tool and it behaves basically the same way. Additionally, I've tried carrying out the resize from a separate live disk so that the partition I'm resizing isn't mounted, and again, same exact behavior. Another interesting point is what the Disks utility thinks:
I am definitely not experienced with disk management so I have of course backed up my data and am considering just wiping the machine and making the partition smaller from the start, but I feel like I'm very close here? Is there a simple step missing or is this far from done?
|
The problem is that while you resized the filesystem inside of the partition, the partition itself was not resized. Think of it like putting your foot inside of a shoe that fits perfectly. You have made your foot (the filesystem) smaller, but the shoe (partition) is the same size, thus there is unused space in the shoe. You need to get a smaller shoe.
A partition is just a concept stored in the GPT (GUID Partition Table). It stores the start position and end position of the partition. You need to compute the new end partition of the partition and update the GPT.
The formula is NEW_PARTITION_SECTOR_END = PARTITION_SECTOR_START + (LUKS_SIZE_SECTORS + LUKS_OFFSET_SECTORS) - 1. This I got from https://wiki.archlinux.org/index.php/Resizing_LVM-on-LUKS#Resize_the_partition
In your case, you want to do "sudo parted /dev/nvme0n1" and then use the "resizepart" command. You can get the values of PARTITION_SECTOR_START from parted itself with the print command. The LUKS_OFFSET_SECTORS and LUKS_SIZE_SECTORS can be obtained from "cryptsetup status cryptdata". Add them all together and that will give you the new end value.
Important: Note that when you use parted, make sure to type the "unit" command first to change the units to "s" which stands for sectors.
| Resizing LUKS encrypted partition - had success but can't use the unallocated space now? |
1,673,544,383,000 |
After all these years of using Linux, I have never goofed up this badly. I should have known better, I honestly don't know what I was thinking.
While trying to fix a small error message I was getting (this is irrelevant to my now much bigger issue), I found a post that said to "just run pacdiff and overwrite old files", and without much looking into it, I began to overwrite..
I guess I did have the fortitude to back up /etc/shadow before overwriting it and stopped overwriting after just a few entries, but I am now locked out of root and all my users. I'm on the computer right now as I'm scared to restart as I also overwrote /etc/grub.d (which I did not backup)! The /etc/shadow backup is in my /home and is owned by root so I cannot read it now, but I do have it.
What exactly does pacdiff and (O)verwrite with pacnew do? I have found instructions to recover /etc/shadow file, but will I be able to get into grub-boot loader on restart now?
My root and home partition are not encrypted, but I do have a LUKS encrypted partition. If worse comes to worse, and I have to reinstall without formatting my /home and encrypted partition, is any instance of cryptsetup able to open a LUKS encrypted partition with the passphrase? The information to mount and open is stored in the LUKS partition header, so I should be good, right? I am unable to find out which cipher I am using as I don't have root access, but I'm almost positive it's whatever the default is.
How do I proceed from here? I'm not going to shutdown this machine until I have a plan in place. I'm on a dual boot Manjaro/Windows. I do have a bootable Manjaro USB made and another machine if need be. Any help would be much appreciated. This is not my proudest moment, but a great lesson learned. I need you guys more than ever.
|
I have never used Manjaro, but the process that works for Arch Linux should be fine in your case too.
You should be able boot off a Manjaro live USB, mount the root file system of your Manjaro installation, mount your existing /home directory and put the backup copy you have of shadow back to its place.
Then you should also be able to boot your installed Manjaro, because /etc/grub.d is only used to (re-)create your GRUB configuration and is not required during the boot process. It is however important that you restore (editing them again, if you have no backup) the files it contains, otherwise your system risks becoming unbootable (or, more likely, not dual-bootable anymore) the next time some package update triggers the re-creation of your boot loader configuration.
This also likely worked if you had an encrypted root file system. udev takes care of activating any block devices (e.g. MD RAID arrays or LVM volumes) as soon as they become available, and the only things usually left to you are:
Opening encrypted devices; in your case, you should be able to:
cryptsetup open /dev/your_encrypted_device decrypted_device_name
Unless something wiped your LUKS headers this will only require the passphrase. (Note that there is no way to recover your data if the LUKS headers have been wiped or damaged and you don't have a backup).
Mounting file systems. E.g. mount /dev/sdaN / or mount /dev/mapper/mapped_dev /.
lsblk may help you explore your device tree and locate the right devices to open/mount (look at the TYPE column).
When pacman installs a new version of a file whose modification time does not match the one recorded in the packages database, the existing file is not overwritten and a .pacnew file is created instead.
Promptly taking care of .pacnew files is important because, on a rolling-release distribution, any package update may introduce breaking changes. For instance, an existing configuration file may mention options that have been deprecated in the to-be-installed version of a program, which needs different options instead. Distribution maintainers can not take care of all the possible cases and checking configuration files is left to the user.
pacdiff is aimed at helping in this process: it walks through the pacnew (and .pacsave) files tracked by the package manager and offers you to review them. "(O)verwrite with pacnew" does just what is says: the existing file is replaced with the .pacnew version and your custom configuration is lost.
While the most proper action is usually to review the existing and .pacnew versions of a file and merge them when needed, some .pacnew files are not meant to be acted upon. Assuming Manjaro aligns with Arch in this respect, this is true for the user database (which includes /etc/passwd and /etc/shadow) "unless Pacman outputs related messages for action".
| Locked out: overwrote /etc/shadow and /etc/grub.d with pacnew |
1,673,544,383,000 |
I have a master key for an encrypted partition on a machine that I have SSH + root access to. I don't have access to any of the passphrases associated with the partition. Is there a way that I can verify that the master key is valid for that partition?
I can't unmount the partition as it is the root partition for the machine, so I don't think I can use luksOpen for example.
|
Like @HaukeLaging said, dmsetup table --showkeys might show the master key of a still open LUKS container (might not work for LUKS2 containers, see also 6.10 How do I recover the master key from a mapped LUKS1 container?).
You could copy like the first 128M of the device then experiment with it at home.
ssh root@server head -c 128M /dev/sdxy > sdxy.img
Possible experiment:
hexedit master.key # hexedit or xxd -r -p to produce binary file
hexdump -C master.key # to verify correctness
cryptsetup luksAddKey --master-key-file master.key sdxy.img
cryptsetup luksOpen sdxy.img luksxy
file -sL /dev/mapper/luksxy
If you get random data instead of a known filesystem or LVM header, it was the wrong key or there is some other problem with the LUKS header.
You can run the same experiment on the server directly, but there may be possible side effects with another device / duplicate UUIDs appearing etc. so it's better to do it on a separate machine or inside VM.
If the LUKS header is damaged so luksAddKey doesn't work, you can also luksFormat a new one. However in that case in addition to the master key, you also must specify the correct cipher and data offsets.
However, if you have any doubts regarding this LUKS container, you should backup all your files while the machine is still running. Storing the master key all over the place also circumvents the LUKS security concept, so it's best to make a new LUKS container with new master key from scratch.
| How can I verify a LUKS master key? [duplicate] |
1,673,544,383,000 |
I find it cool that you can change the passphrase and even have multiple keyslots with LUKS. But can you change the pbkdf after formatting?
When running luksFormat you give --pbkdf and arguments for that:
cryptsetup -y -v luksFormat --sector-size 4096 \
--pbkdf-memory 4000000 --pbkdf argon2id --iter-time 300 \
/dev/sda4
Is it possible to change these without dataloss?
E.g. change the --iter-time from 300 to 3000 to:
cryptsetup -y -v luksFormat --sector-size 4096 \
--pbkdf-memory 4000000 --pbkdf argon2id --iter-time 3000 \
/dev/sda4
|
You can specify what arguments to use every time you add a key.
So simply add a new key and remove the old:
cryptsetup luksAddKey --pbkdf-memory 4000000 --pbkdf argon2id --pbkdf-parallel 1 --iter-time 3000 /dev/sda4
| LUKS: Change --pbkdf arguments without reformat? |
1,673,544,383,000 |
Google cloud services (computing instance) offer encryption by default for disk storage, the customer can provide its own key with the feature customer supplied encryption (detailed here also).
How can we apply a disk encryption with cryptsetup without giving the encryption key to google?
|
On Linux, when using an encrypted disk (luks), it is unlocked at boot time with a password the idea here is to encrypt the disk with cryptsetup on top of the google system (default encryption) and get an earlier access to the instance to be able to unlock the drive at the boot time. This can be implemented with the help of the remote serial console feature (note that an opensuse VM was used for this howto, the different steps should not differ for other distros).
Con:
Disk speed will be reduced by 10~15%.
At boot/reboot time the encryption password need to be introduced over a serial session.
Reboot on failure/migration may require manual password introduction (if not automated).
Pro:
Data access is truly limited to the customer/owner.
Customer privatized disk encryption at rest.
Customer privatized disk encryption for snapshot backups and images.
Google can not access the disk's data (or at least it would be very hard).
The disk encryption key is not given to Google.
Customizable encryption method, algorithm and key size.
Data protection improvement etc.
Implementation summary:
0 Have an existing VM instance
1 Enable instance/VM serial access
2 Create an additional (target) encrypted hard drive
3 Copy the current hard drive to the encrypted one
4 Replace the old drive with the new one
5 Start the VM and introduce the password over the serial console
How to encrypt the disk of a VM (gcloud, cryptsetup):
Prerequisite:
Create a new temporary VM on the target zone (this need to be a copy of the target machine, you can backup the disk with a snapshot then restore the snapshot to a new disk)
Create a new empty disk (to be encrypted later), this is the target disk, its size need to be at least 256 MB larger than the source disk (for the new /boot partition), also the disk can be more larger if you want to expand the space.
Mount both disks to the temporary VM and start it.
Temporary VM Config:
/dev/sda : main disk, copy of the original source disk
/dev/sdb : new empty disk larger than /dev/sda
Serial console:
Summary: enable serial port connection, and connect to the machine over serial port (doc1, doc2, doc3)
Under metadata add serial-port-enable with the value TRUE (and enable serial port on the instance options)
Connect to the serial port with ssh/gcloud; gcloud example:
gcloud compute --project=prj-name connect-to-serial-port vm-name --zone=us-central2-b
Update grub config:
Summary: enable serial console (makes grub accessible with the serial console)
Add/edit this to /etc/default/grub
# ...Enabling serial console...
GRUB_TIMEOUT=15
GRUB_TERMINAL="serial"
GRUB_SERIAL_COMMAND="serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1"
# ...End
Apply the settings with grub2-mkconfig -o /boot/grub2/grub.cfg
Reboot and check if grub is accessible on the serial console.
Format the target disk:
Summary: we need to create 2 partitions one for /boot (un-encrypted) and an other for the system / (encrypted), it does not matter if you already had a separate partition for /boot or not on your old system, on the new one we would need to have it for the system to boot grub and ask for the password to unlock the encrypted partition.
Format the empty disk and create 2 partitions one sized at least 256 MB (to contain /boot) and the other one with the remaining space; Use fdisk /dev/sdb to do so, create the first one with 256 MB or more as a primary parition and enable the bootable flag; then create a second primary partition sized with the remaining space (note that if you were using a partition for the swap on the old system you need to create that partition as well)
/dev/sda :
/dev/sdb :
|- sdb1 : 256 MB primary and bootable (empty)
|- sdb2 : xx GB primary (empty)
Set the file system to ext4 for the boot partition with mkfs.ext4 /dev/sdb1
Wipe the second partition for an additional security with
dd if=/dev/urandom of=/dev/sdb2 bs=4096 status=progress
Setup the encryption for sdb2 with
cryptsetup -y -v --cipher aes-xts-plain64 --key-size 256 --pbkdf-force-iterations=100200 --hash sha256 --type luks1 --label=linux --use-random luksFormat /dev/sdb2
Change the cipher, the key size, encryption type etc. to match your needs
Check the encrypted partition with cryptsetup luksDump /dev/sdb2
Unlock the encrypted partition with cryptsetup luksOpen /dev/sdb2 crypteddisk
Set the encrypted mapped partition to ext4 with mkfs.ext4 /dev/mapper/crypteddisk
Close the encrypted partition cryptsetup close /dev/mapper/crypteddisk
Clone the source disk:
Summary: we need to copy our system / to the new encrypted partition /dev/mapper/crypteddisk (sdb2) for this step you can use different tools, in this howto we will be using dd, important note here, for dd to copy a disk without any error the source partition need to unmounted. If you want to avoid any data loss you can create an other temporary VM and attach to it the source and target disk as additional disks to perform this step... Otherwise to avoid a too long migration process i closed most of the running process and used dd without un-mounting the source partition (not recommended), then used fsck to correct any error due to the fact that the source was not un-mounted.
Unlock the encrypted partition with cryptsetup luksOpen /dev/sdb2 crypteddisk
Copy the source partition to the target with the following (supposing / is /dev/sda1)
dd if=/dev/sda1 of=/dev/mapper/crypteddisk bs=4096 status=progress
Check and fix the new encrypted partition with fsck /dev/mapper/crypteddisk
Check the disks structures with fdisk -l (don't pay attention to crypteddisk size, we are fixing that later)
Partitions UUID:
Get all the UUID of all the partitions and keep that info.
blkid /dev/sda
blkid /dev/sda1
blkid /dev/sdb
blkid /dev/sdb1
blkid /dev/sdb2
blkid /dev/mapper/crypteddisk
Resize the disk:
Summary: in this step we will expand the size of the new encrypted partition.
Expand the encrypted partition with
cryptsetup resize crypteddisk -v
e2fsck -f /dev/mapper/crypteddisk
resize2fs /dev/mapper/crypteddisk
Backup the MBR:
This is not required but it may be useful
dd if=/dev/sdb of=/backup/location/sdb.mbr count=1
dd if=/dev/sda of=/backup/location/sda.mbr count=1
Setup the boot partition:
Mount the new boot partition and copy /boot content to it.
mkdir /tmp/boot
mount /dev/sdb1 /tmp/boot
cp -a /boot/* /tmp/boot/
ls -l /tmp/boot/*
umount /tmp/boot
rmdir /tmp/boot
Remove the old /boot folder content and leave it as a mount location.
mkdir /tmp/system
mount /dev/mapper/crypteddisk /tmp/system
rm -rf /tmp/system/boot/*
ls -l /tmp/system/boot/*
umount /tmp/system
rmdir /tmp/system
Chroot and setup the new system:
Load the new encrypted disk as the current one (chroot) and setup it to apply the new system config, encryption etc. (also make sure /mnt is empty before proceeding).
mount /dev/mapper/crypteddisk /mnt/
mount /dev/sdb1 /mnt/boot
for i in sys dev proc; do mount --bind /$i /mnt/$i; done
chroot /mnt
From now on we are on the new system (keep in mind that sdb need to be considered sda on the configs files)
Update /etc/fstab config (make sure to use sdb1 uuids not sda1), here is cat /etc/fstab output:
# Main Partition ----------------------
# Entry for /dev/mapper/crypteddisk (sda2) :
UUID=CHANGE-THIS-WITH-CRYPTEDDISK-UUID / ext4 noatime,acl 0 0
# Boot Partition ----------------------
# Entry for /dev/sda1 :
#/dev/sda1 /boot ext4 defaults 1 2
UUID=CHANGE-THIS-WITH-THE-CURRENT-SDB1-UUID /boot ext4 noatime,acl 1 2
# Swap Partition/File -----------------
/swap/swapfile swap swap defaults 0 0
#
Update /etc/crypttab config (if crypttab file does not exist, create it with -rw-r--r-- permissions), also make sure to use sdb2 uuids not sda1 nor crypteddisk, here is cat /etc/crypttab output:
crypteddisk UUID=CHANGE-THIS-WITH-CURRENT-SDB2-UUID
Update the grub config on /etc/default/grub, you only need to change GRUB_ENABLE_CRYPTODISK, GRUB_CMDLINE_LINUX and GRUB_DISABLE_OS_PROBER here is cat /etc/default/grub output:
GRUB_DISTRIBUTOR=My-Custom-Server...
# .................................... Command line
#GRUB_CMDLINE_LINUX=" root=/dev/sda1 disk=/dev/sda resume=swap console=ttyS0,38400n8 quiet"
GRUB_CMDLINE_LINUX=" root=/dev/mapper/crypteddisk luks_root=/dev/sda2 luks="root" disk=/dev/sda resume=swap console=ttyS0,38400n8 quiet"
# .................................... Options
GRUB_DEFAULT=0
GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_GFXMODE=800x600
GRUB_GFXPAYLOAD_LINUX=keep
GRUB_THEME=/boot/grub2/theme/theme.txt
GRUB_BACKGROUND=
# .................................... Enabling serial console...
GRUB_TIMEOUT=30
GRUB_TERMINAL="serial"
GRUB_SERIAL_COMMAND="serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1"
# .................................... Enabling cryptsetup
GRUB_ENABLE_CRYPTODISK="y"
# .................................... Ignore other os
GRUB_DISABLE_OS_PROBER="true"
# ....................................
Apply grub changes with:
grub2-mkconfig -o /boot/grub2/grub.cfg
Update the init ram disk and force encryption modules to be included with:
mkinitrd -d /dev/mapper/crypteddisk -f "dm luks"
Update the MBR and reinstall grub on the new disk to make it bootable
grub2-install /dev/sdb
Exit the chroot and un-mount everything
exit
cd /
for i in sys dev proc; do umount /mnt/$i; done
unmount /mnt/boot
unmount /mnt
If you have any issue un-mounting a partition use -l option for instance umount -l /mnt/sys
Apply the magic:
Turn off the temporary VM; Detach all the disks; Attach the encrypted disk as the boot disk.
Turn on the temporary VM; Connect to it with the serial console and voila! (you will be asked the password to unlock the crypted partition at boot time).
Test if everything is fine, then use the new encrypted disk on the production VM and delete the temporary copy disk and the temporary VM.
Additional infos are available here and here. Enjoy ;)
| How to force a custom disk encryption on a google cloud compute instance (gcloud)? |
1,673,544,383,000 |
I'm trying to understand the relationship between LUKS detached headers and their respective block device. From what I understand "formatting" with a detached header doesn't actually change the content of it's respective block device, that only occurs when you begin to write to the opened (cryptsetup luksOpen) partition.
So I would like to know:
Can a single encrypted partition have two independent headers. For example if I had a removable drive intermittently plugged into two different computers, could each computer have it's own independent copy of the header without any need to re-sync the two copies of the header.
Can a single detached header be used for two separate drives. For example if I had two encrypted backup drives, could a single header be used for both, or is the header in some way bound to the partition?
|
It's possible. If you read the cryptsetup manual and FAQ, you'll find that such things are discouraged. But there is nothing anywhere preventing you from doing so anyway.
You can use as many copies of the header as you like and even modify those copies, e.g. so one copy uses passphrase A, the other uses passphrase B - or one could be in LUKS1 format while the other is in LUKS2. Anything goes as long as the encryption itself remains unchanged. The downside is that you cannot revoke a passphrase if you do not have control of all the LUKS header copies.
You can use the same header for as many drives as you like, and it would work, but the downside is, they would all be encrypted using the very same master key. It's more common to use different headers (different master keys) perhaps with identical passphrase to them, e.g. systemd supports re-using the same passphrase to open many independent LUKS containers on bootup.
The LUKS header is just a fancy way of storing the actual encryption key (what LUKS calls the "master key") and related metadata (like which cipher to use and the data offset). It does not record partition names or sizes so there are not many restrictions. LVM or mdadm metadata is a lot more picky about these things.
| What are the limitations of a detached LUKS header |
1,673,544,383,000 |
I have a triple boot setup (3xLinux). All Linuces share /home and swap, and their / partitions are next to each other. All reside in an LVM on LUKS:
# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
nvme0n1 259:0 0 951.8G 0 disk
|-nvme0n1p1 259:1 0 800M 0 part /boot/efi
|-nvme0n1p2 259:2 0 32G 0 part
|-nvme0n1p3 259:3 0 619M 0 part
`-nvme0n1p4 259:4 0 706.5G 0 part
`-cryptolvm 254:0 0 706.5G 0 crypt
|-cryptolvm-swap 254:1 0 32G 0 lvm [SWAP]
|-cryptolvm-home 254:2 0 430.0G 0 lvm /home
|-cryptolvm-centos 254:3 0 41G 0 lvm /mnt/centos
|-cryptolvm-arch 254:4 0 41G 0 lvm /
`-cryptolvm-opensuse 254:5 0 41G 0 lvm /mnt/opensuse
openSUSE manages the GRUB2 (with full encryption, i.e. disk unlock password needed before grub menu which resides on the openSUSE system partition /).
Problem: Arch does not unlock the cryptodisk /dev/nvme0n1p4 and therefore cannot access its / during boot. It drops me to an emergency prompt.
This is the setup an Arch Linux:
mkinitcpio configuration (and yes, I have re-created /boot/initramfs-linux.img after changing this):
# grep crypt /etc/mkinitcpio.conf | tail -1
HOOKS=(base udev autodetect modconf keyboard block encrypt lvm2 filesystems fsck)
GRUB2 configuration on openSUSE:
# grep --after=18 Arch /mnt/opensuse/boot/grub2/grub.cfg
menuentry 'Arch Linux (rolling) (on /dev/mapper/cryptolvm-arch)' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-simple-aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' {
insmod part_gpt
insmod cryptodisk
insmod luks
insmod gcry_rijndael
insmod gcry_rijndael
insmod gcry_sha256
insmod lvm
insmod ext2
cryptomount -u 99999999999999999999999999999999
set root='lvmid/VVVVVV-VVVV-VVVV-VVVV-VVVV-VVVV-VVVVVV/qqqqqq-qqqq-qqqq-qqqq-qqqq-qqqq-qqqqqq'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint='lvmid/VVVVVV-VVVV-VVVV-VVVV-VVVV-VVVV-VVVVVV/qqqqqq-qqqq-qqqq-qqqq-qqqq-qqqq-qqqqqq' aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa
else
search --no-floppy --fs-uuid --set=root aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa
fi
linuxefi /boot/vmlinuz-linux cryptdevice=UUID=99999999999999999999999999999999:cryptolvm root=/dev/mapper/cryptolvm-arch resume=/dev/cryptolvm/swap splash=silent quiet showopts
initrdefi /boot/initramfs-linux.img
}
LVM devices:
# vgs -v
VG Attr Ext #PV #LV #SN VSize VFree VG UUID VProfile
cryptolvm wz--n- 4.00m 1 5 0 706.45g <120.51g VVVVVV-VVVV-VVVV-VVVV-VVVV-VVVV-VVVVVV
# lvs -v | grep arch
arch cryptolvm 1 -wi-ao---- <40.96g -1 -1 254 4 qqqqqq-qqqq-qqqq-qqqq-qqqq-qqqq-qqqqqq
Disk/partition UUIDs:
# blkid | egrep '(p4|arch)'
/dev/nvme0n1p4: UUID="99999999-9999-9999-9999-999999999999" TYPE="crypto_LUKS" PARTUUID="cccccccc-cccc-cccc-cccc-cccccccccccc"
/dev/mapper/cryptolvm-arch: UUID="aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa" PARTUUID="cccccccc-cccc-cccc-cccc-cccccccccccc"
Workaround:
GRUB2 (or initramfs) drops me to a prompt because it cannot mount /dev/mapper/cryptolvm-arch to / (or, to /new_root). So during each boot I enter manually:
> cryptsetup open /dev/nvme0n1p4 cryptolvm
(...)
> mount /dev/mapper/cryptolvm-arch /new_root
> ^D
Why is this necessary? The mount is given twice (cryptomount and cryptdevice) in grub.cfg (and this is indeed used).
EDIT:
Perhaps this has to do with EFI? Would I receive an EFI error if it were? openSUSE boots via EFI, chain-loads the grub.cfg from its /, then boots Arch - is linuxefi correct here?
Just before GRUB2 drops me to the emergency shell I can type keys and they appear on the screen. When the shell opens the typed characters are still in the buffer and are entered in that shell.
|
Start Your system with the rd.debug (init-ramdisk debug) kernel flag added. This should shed some light on what is going wrong.
If You have it You kan bost the last one or two screens with xtrace output if You cannot the the problem Yourself then.
You can also direct the output to files in addition (i.e. add rd.log=all flag to kernel options) and should be able to get the log as copyable and better scrollable text after boot finished.
And, what I forgot, in Your above snippets You anonymized for whatever reasons the UUID and I don't know what is Your original config, but You have forgoten the dashes.
Example from my system (the blkid is the command that is run to find the physical device from Your cryptdevice=UUID=21685fd6-f2e3-4037-8645-3957cff3568c:cryptolvm kernel option, the part between cryptodevice= up to the first colon will be searched with the below command):
[root@ArchTestVM ~]# blkid -lt "UUID=21685fd6-f2e3-4037-8645-3957cff3568c" -o device
/dev/nvme0n1p2
[root@ArchTestVM ~]# blkid -lt "UUID=21685fd6f2e3403786453957cff3568c" -o device
[root@ArchTestVM ~]#
| LVM on LUKS FDE: GRUB won't mount my root partition / during boot even though cryptomount and cryptdevice are given in grub.cfg |
1,673,544,383,000 |
I have a single HDD and there's LVM set up on top of LUKS
└─sda5 8:5 0 883,2G 0 part
└─sda5_crypt (dm-0) 252:0 0 883,2G 0 crypt
├─vg1-root (dm-1) 252:1 0 30G 0 lvm /
├─vg1-swap (dm-2) 252:2 0 4G 0 lvm [SWAP]
├─vg1-usr (dm-3) 252:3 0 15G 0 lvm /usr
└─vg1-home (dm-4) 252:4 0 834,2G 0 lvm /home
Now I bought a bigger HDD and want to move onto it. What should I do after a create a new LUKS partition on a new HDD?
|
Ideally, you initialize the new LUKS partition as a LVM PV, add it to your volume group with:
vgextend vg1 /path/to/new/LUKS/device
Then use the LVM pvmove command to migrate your data to it like so:
pvmove /path/to/old/LUKS/device /path/to/new/LUKS/device
When the data migration is done, be sure to remove the old LUKS partition from the volume group with:
vgreduce vg1 /path/to/old/LUKS/device
This can all be done with the system online, although it is marginally safer and probably significantly faster to do it from a LiveCD like SystemRescueCD. Also, if you have a new enough version of LVM, you probably want to use the --atomic option for pvmove, that will ensure that you don't end up with some LV's on the new device and some on the old device if the pvmove command fails.
| Best way to move LVM on luks to a new hdd? |
1,673,544,383,000 |
If i’m rebuilding an encrypted RAID 1 with the whole array encrypted with LUKS, if I decrypt the array to use it, will the data still be encrypted, or will the array rebuild decrypted?
|
This looks like a misunderstanding, or possibly incorrect terminology.
I'm assuming that "encrypted RAID 1 with the whole array encrypted with LUKS" you mean that you've first built up a RAID array out of physical /dev/sd* devices, creating an array device, and then set up a LUKS encryption on top of the array device. It is possible to do it the other way too (i.e. first encrypt a number of devices, then RAID on top of the encrypted devices).
You don't need to decrypt the array to use it: you need to open it.
cryptsetup luksOpen will not decrypt the data on the disk. It adds a device-mapper dm-crypt layer on top of the encrypted disk/array that decrypts anything you read from the disk on the fly, and also encrypts everything you write through it. As a result, you can use the resulting mapped device just like a regular, unencrypted disk or array. The data on the disk is still encrypted.
If the underlying disk is a RAID array, you just need to take care not to mix any mapped devices "above" the encryption layer with the ones "below" it. That should not be too difficult, as the software RAID 1 works with a similar principle: there is a device-mapper raid1 layer with the component devices "below" it and the device representing the whole array "above" it. The aim is that the array device can be used just the same regardless of whether the devices "below" are fully intact or undergoing a rebuild.
The dmsetup ls --tree -o blkdevname command can be helpful in understanding the storage configuration if you're using RAID, disk encryption, LVM and/or multipathing in a combination.
If you've done it the other way (i.e. RAID "on top of" the encryption layer), then you'll need to first re-establish the encryption layer on the replacement disk before letting the array rebuild on it. In that case it would be possible to accidentally omit the encryption layer on the replacement RAID component device and let the array rebuild unencrypted on a /dev/sd* device.
| Is it safe to use LUKS encrypted raid 1 during rebuild? |
1,673,544,383,000 |
I have 2 LUKS containers, one with default OpenSUSE installer settings, another one with -h sha512 -s 512 -i 5000 and detached header. On top of each of them there is LVM - one with only 1 OS volume which is btrfs, another one (detached) with 3 volumes - swap, ssd cache and btrfs data. The problem is that btrfs on OS volume perform A LOT better than data volume. The one with OS performs more or less like raw btrfs on LUKS without LVM, the one with data achieves like... 50MB/s sequential on Samsung SSD PRO... (It's slower than WD Green HDD) I've planned to use this volume for VMs but it's slow as hell, Win10 is booting like a minute or so, comparing to few seconds when on OS partition.
OS volume was created by OpenSUSE installer with default settings. The one with data was created manually with mkfs.btrfs without any flags except label. Here are mount parameters:
/dev/mapper/linux-suse on / type btrfs (rw,relatime,ssd,discard,space_cache)
/dev/mapper/data-data on /home/lapsio/VMs type btrfs (rw,noatime,compress=lzo,ssd,space_cache)
First thing to blame would be ofc compression, but actually VMs dir has set chattr -R +C VMs/ flag on it as well as on all files inside. I've also tried to defragment this dir but it doesn't seem to work.
|
Oh my... I didn't mention this drive was moved from laptop where as the only drive it was 99% filled up with data. First LVM is mounted automatically at OS startup and has enabled TRIM (I know it's not recommended on encrypted devices as it reveals data organization on disk but OS partition contains only OS, not actual important data), second LVM was mounted manually from command line and didn't have enabled TRIM (because well I'm not planning to use TRIM there anyway). But in matter of fact this 180gb partition (on 256gb drive) or rather data cells covering this part of drive weren't trimmed at all since it was mounted in PC.
After I've manually TRIMed this LUKS partition it works fine
| btrfs on LVM on LUKS - one LUKS container performs WAY better than the other |
1,673,544,383,000 |
I created a separate partition on a CentOS install (VirtualBox), and am attempting to encrypt it using cryptsetup and LUKS.
I'm using the following commands to get this set up:
cryptsetup luksOpen /dev/mapper/VolGroup-db00 db_fips (no error, all clear)
mkfs -t ext4 /dev/mapper/db_fips (no error, all clear)
e2fsck -f /dev/mapper/db_fips
e2fsck 1.41.12 (17-May-2010)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/mapper/db_fips: 11/131072 files (0.0% non-contiguous), 17196/523776 blocks
Ok, the volume is created.
So next I reboot.
After logging in, the /dev/mapper/db_fips volume is gone.
[root@dhcp ~]# ll /dev/mapper/db_fips/
ls: cannot access /dev/mapper/db_fips/: No such file or directory
# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
LogVol01 VolGroup -wi-ao---- 1.46g
LogVol02 VolGroup -wi-ao---- 500.00m
LogVol03 VolGroup -wi-ao---- 1000.00m
LogVol04 VolGroup -wi-ao---- 500.00m
LogVol05 VolGroup -wi-ao---- 300.00m
LogVol06 VolGroup -wi-ao---- 3.00g
db00 VolGroup -wi-a----- 2.00g
Why is the db_fips volume I just created gone?
/dev/mapper/VolGroup-db00 still exists, and shows to be encrypted (?)
blkid /dev/mapper/VolGroup-db00
/dev/mapper/VolGroup-db00: UUID="some uuid" TYPE="crypto_LUKS"
If /dev/mapper/VolGroup-db00 is what I actually encrypted, why did I need to issue cryptsetup /dev/mapper/VolGroup-db00 luksOpen db_fips, and why is that no longer available?
|
Creating an encrypted volume does just that: create an encrypted volume on the disk. Using the volume on your live system is a concept that only makes sense as long as the system remains live: it needs to be done all over again if the system reboots. So you need to arrange for the volume to be brought up during the system startup. To do that, list it in the file /etc/crypttab. Add a line like this:
db_fips /dev/VolGroup/db00
Your system startup scripts will take care of calling cryptsetup luksOpen; you'll be prompted for the password. This is analogous to listing a filesystem in /etc/fstab so that it is mounted during startup.
| luks volume disappears after reboot |
1,673,544,383,000 |
I've been working a bash script to automate the process of opening and closing an LVM over LUKS external hard drive. However I continue to receive errors on line 28:
$(vgchange -a n ; cryptsetup luksClose vol)
The error I receive:
$ sudo ./encryption.sh -l
Locking System..............
./encryption.sh: line 28: 0: command not found
System Locked!
Here is the rest of the code for reference:
if [ $1 = -u ] ; then
$(cryptsetup luksOpen /dev/sdb2 vol)
echo "Unlocking.................." | pv -qL 10
$(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)
echo "System Mounted!" | pv -qL 10
# exit 0
fi
if [ $1 = -l ] ; then
$(umount /mnt/var ; umount /mnt/home ; umount /mnt/boot ; umount /mnt/)
echo "Locking System.............." | pv -qL 10
$(vgchange -a n ; cryptsetup luksClose vol)
echo "System Locked!" | pv -qL 10
exit 0
fi
Other information:
I receive no apparent error when running the command in question by itself interactively.
I'm new to writing bash, so any recommendations and constructive criticism is appreciated.
The process appears to complete successfully, but I don't understand the error or how to make them go away.
Upon further research when running the troubled code alone in interactive mode it does provide output after being executed.
This is given after posting the troubled code interactively.
0 logical volume(s) in volume group "vol" now active
|
By putting commands inside a $( .. ) block you're doing command substitution. That means that the commands inside that block is executed, and the output of those commands will be evaluated by bash as other commands to be executed. So if the command outputs the text
0 logical volume(s) in volume group "vol" now active
then the shell will try to run that as a command, and as it starts with 0 it looks for a command with that name.
Why are you putting the commands in $( .. ) block? What are you trying to achieve with that?
| BASH - Command not found - LVM over LUKS Automation Script |
1,673,544,383,000 |
I overwrote some LVM2 metadata in much the same way as Recovering overwritten LVM metadata . That is, I attempted to install Debian 6.0.7 on a system with existing encrypted volumes and LVM2 volumes.
The structure of the disk was that a LUKS volume covered a 90% partition (sdc1) on the disk; an LVM2 physical volume used up the LUKS volume; and this physical volume had its own volume group and two logical volumes.
I used these commands to generate a hex dump:
cryptsetup luksOpen /dev/sdc1 sdc1_crypt
dd if=/dev/mapper/sdc1_crypt of=text count=100000
hexdump -C text | less
Part of the hex dump:
00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
00000200 4c 41 42 45 4c 4f 4e 45 01 00 00 00 00 00 00 00 |LABELONE........|
00000210 1a d0 74 52 20 00 00 00 4c 56 4d 32 20 30 30 31 |..tR ...LVM2 001|
00000220 39 4b 4d 34 48 30 37 43 6c 5a 6d 62 5a 46 32 43 |9KM4H07ClZmbZF2C|
00000230 78 6b 69 72 72 58 61 62 52 64 35 48 38 66 62 79 |xkirrXabRd5H8fby|
00000240 00 10 0e 8c d1 00 00 00 00 00 03 00 00 00 00 00 |................|
00000250 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000260 00 00 00 00 00 00 00 00 00 10 00 00 00 00 00 00 |................|
00000270 00 f0 02 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000280 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
00000800 d2 6d b3 03 e3 88 08 0f 0f 60 17 31 60 2a a5 86 |.m.......`.1`*..|
00000810 a8 2b 87 77 cb 73 bf 52 c6 36 92 ec ee 9f b7 e0 |.+.w.s.R.6......|
*
00000a00 f4 6c 87 31 71 aa 28 b8 44 9e 03 75 fc 58 9b b4 |.l.1q.(.D..u.X..|
00000a10 a8 2b 87 77 cb 73 bf 52 c6 36 92 ec ee 9f b7 e0 |.+.w.s.R.6......|
*
00000c00 13 30 81 66 9a 7a 33 eb dd e7 b6 93 c5 e6 42 f0 |.0.f.z3.......B.|
00000c10 a8 2b 87 77 cb 73 bf 52 c6 36 92 ec ee 9f b7 e0 |.+.w.s.R.6......|
*
00000e00 c2 71 8f 11 f4 70 b4 e3 af e0 a0 d7 86 bd ad 5b |.q...p.........[|
00000e10 a8 2b 87 77 cb 73 bf 52 c6 36 92 ec ee 9f b7 e0 |.+.w.s.R.6......|
*
00001000 1b c7 35 60 20 4c 56 4d 32 20 78 5b 35 41 25 72 |..5` LVM2 x[5A%r|
00001010 30 4e 2a 3e 01 00 00 00 00 10 00 00 00 00 00 00 |0N*>............|
00001020 00 f0 02 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00001030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
***
00004c00 82 12 42 63 c4 c1 b3 2b f5 f9 d1 17 06 60 64 c3 |..Bc...+.....`d.|
00004c10 a8 2b 87 77 cb 73 bf 52 c6 36 92 ec ee 9f b7 e0 |.+.w.s.R.6......|
*
00004e00 4a eb 67 e4 80 7d e7 72 d3 b4 52 36 31 3d 36 01 |J.g..}.r..R61=6.|
00004e10 a8 2b 87 77 cb 73 bf 52 c6 36 92 ec ee 9f b7 e0 |.+.w.s.R.6......|
*
00005000 dc da e7 8d 9b f1 37 8f 97 92 ee a4 8d 9a 42 1e |......7.......B.|
00005010 a8 2b 87 77 cb 73 bf 52 c6 36 92 ec ee 9f b7 e0 |.+.w.s.R.6......|
*
00005200 d2 2d 71 cb d1 31 27 c8 aa aa 03 60 a2 5f 8e 14 |.-q..1'....`._..|
00005210 a8 2b 87 77 cb 73 bf 52 c6 36 92 ec ee 9f b7 e0 |.+.w.s.R.6......|
*
00005400 fe 7b fd cd 20 5b cd 99 9a bf 23 92 10 b5 f9 c2 |.{.. [....#.....|
00005410 a8 2b 87 77 cb 73 bf 52 c6 36 92 ec ee 9f b7 e0 |.+.w.s.R.6......|
*
00005600 86 a2 ce 88 2f ba 9b 3b ba 55 f4 d2 a5 a1 3e b7 |..../..;.U....>.|
00005610 a8 2b 87 77 cb 73 bf 52 c6 36 92 ec ee 9f b7 e0 |.+.w.s.R.6......|
*
00005800 33 37 62 46 24 43 3b a1 6b 4d 65 8f 5a ca 1b 46 |37bF$C;.kMe.Z..F|
00005810 a8 2b 87 77 cb 73 bf 52 c6 36 92 ec ee 9f b7 e0 |.+.w.s.R.6......|
*
00005a00 bd d5 b4 41 46 08 b9 b9 87 a2 53 ab ff 01 2a 1b |...AF.....S...*.|
00005a10 a8 2b 87 77 cb 73 bf 52 c6 36 92 ec ee 9f b7 e0 |.+.w.s.R.6......|
*
00005c00 2f a8 ae 97 6d 56 8a 71 9e 16 60 2c f3 68 c2 f4 |/...mV.q..`,.h..|
00005c10 a8 2b 87 77 cb 73 bf 52 c6 36 92 ec ee 9f b7 e0 |.+.w.s.R.6......|
*
00005e00 d3 44 a7 ca bc 21 61 f4 58 c4 f2 78 9c 34 95 18 |.D...!a.X..x.4..|
00005e10 a8 2b 87 77 cb 73 bf 52 c6 36 92 ec ee 9f b7 e0 |.+.w.s.R.6......|
*
00006000 5d df c9 11 56 ec 92 03 ac 02 4e 91 40 76 a6 b3 |]...V.....N.@v..|
00006010 a8 2b 87 77 cb 73 bf 52 c6 36 92 ec ee 9f b7 e0 |.+.w.s.R.6......|
*
00006200 e2 19 26 d8 4e bc ae 44 a1 47 f9 bd 6d 0f 86 57 |..&.N..D.G..m..W|
00006210 a8 2b 87 77 cb 73 bf 52 c6 36 92 ec ee 9f b7 e0 |.+.w.s.R.6......|
*
00006400 82 52 57 e2 35 e7 82 af 53 fb d4 04 93 89 48 aa |.RW.5...S.....H.|
00006410 a8 2b 87 77 cb 73 bf 52 c6 36 92 ec ee 9f b7 e0 |.+.w.s.R.6......|
*
00006600 49 86 60 90 1e a5 da d3 55 4c 26 31 80 fb a5 2d |I.`.....UL&1...-|
00006610 a8 2b 87 77 cb 73 bf 52 c6 36 92 ec ee 9f b7 e0 |.+.w.s.R.6......|
*
00006800 cf 2a ae 71 e8 5b ac 8e dd 70 9e 05 2b bb c5 9c |.*.q.[...p..+...|
00006810 a8 2b 87 77 cb 73 bf 52 c6 36 92 ec ee 9f b7 e0 |.+.w.s.R.6......|
*
00006a00 43 e2 38 92 9a 1d c7 c4 fe bf df 13 7f bf 5b f9 |C.8...........[.|
00006a10 a8 2b 87 77 cb 73 bf 52 c6 36 92 ec ee 9f b7 e0 |.+.w.s.R.6......|
*
00006c00 38 40 94 3c 21 3e ce 63 e8 c3 5d 1d 35 08 3e 7c |[email protected]..].5.>||
00006c10 a8 2b 87 77 cb 73 bf 52 c6 36 92 ec ee 9f b7 e0 |.+.w.s.R.6......|
*
00006e00 71 52 d0 15 44 78 ad 13 fa c5 a0 ec 74 4c a7 5b |qR..Dx......tL.[|
00006e10 a8 2b 87 77 cb 73 bf 52 c6 36 92 ec ee 9f b7 e0 |.+.w.s.R.6......|
*
00007000 4f 2d b5 50 57 6b ac 02 23 82 28 05 f5 5e d1 f1 |O-.PWk..#.(..^..|
00007010 a8 2b 87 77 cb 73 bf 52 c6 36 92 ec ee 9f b7 e0 |.+.w.s.R.6......|
*
00007200 37 43 9a f7 68 e7 94 59 13 10 66 e8 56 53 e3 cb |7C..h..Y..f.VS..|
00007210 a8 2b 87 77 cb 73 bf 52 c6 36 92 ec ee 9f b7 e0 |.+.w.s.R.6......|
If the installation had overwritten the LUKS block with a new one that used the same passphrase, could I still see the recurring "+.w.s.R.6", or would that be improbable? If this isn't what happened, what did?
I think the installation had overwritten the PV metadata, which accounts for the readable LVM2 line at 0x1000. But searching the disk for keywords that existed on the disk prior to installation returned nothing.
|
You can use gpart to search for file systems on /dev/dm-2. After that or even as an alternative you can create dm volumes without LVM using dmsetup directly. On my systems the first LV always starts at offset 384:
dmsetup create restore-lv --table "0 25165824 linear /dev/dm-2 384"
The size is not important (and usually wrong) for the test. Then you check whether there is a file system. For ext? with
dumpe2fs -h /dev/mapper/restore-lv
If that really was the position of the LV then dumpe2fs (or the respective program for your file system type) should tell you the size of the file system (which usually is the same size as the LV):
Block count: 53248
Block size: 1024
In this case the FS / LV size is 53248*1024=54525952 bytes (106496 sectors). So the correct dmsetup command would have been
dmsetup create restore-lv1 --table "0 106880 linear /dev/dm-2 384"
and the next one is at 106496+384=106880:
dmsetup create restore-lv --table "0 106880 linear /dev/dm-2 106880"
Of course, if your LVs were fragmented then this won't work. But if it works then you can check whether lvcreate recreated the LVs correctly later.
| Reading encrypted partition with broken LVM2 inside? |
1,673,544,383,000 |
I had a working ubuntu with root and swap partitions encrypted with an LVM on LUKS set-up. Name of the LVM virtual group is vg-ubuntu.
Due to a maintenance need (a boot partition, not on LVM, becomming too small), I used LVM ability to move data to another partition (vgextend, pvmove, etc. using a live USB OS). As it was temporary, I did not encrypt this new partition. Ubuntu was still booting.
But, when I tried to move back to the original encrypted partition, ubuntu was not booting: it couldn't find vg-ubuntu.
I found some guides to solve similar issues, indicating to chroot and then update-initramfs, similar to what to do when encrypting the partition for the first time, but it did not work.
I also tried to move the data and then encrypt, but with no success. Moving the data worked fine with ubuntu booting, but after encryption, it was not able to find the VG.
|
After a couple of days of research, I found the solution in this blog.
The important step is to reinstall lvm2 and cryptsetup-initramfs after the chroot and before update-initramfs
chroot /mnt
apt install lvm2 cryptsetup-initramfs
update-initramfs -c -k all
In my case, it was necessary to do this reinstall, even though ubuntu had been on an encrypted device before.
| LVM on LUKS - linux not booting with error "vg-xxx" not found after moving to encrypted partition |
1,673,544,383,000 |
I have an Arch installation on a LUKS-encrypted LVM. After I installed Debian on a different NVME drive I'm no longer able to cryptsetup open the partition from other systems, nor can I boot into Arch.
# cryptsetup open /dev/nvme0n1p3 arch
Device /dev/nvme0n1p3 is not a valid LUKS device.
Here is a hexdump -C of the first 35kb of said partition.
Notes:
When I was installing Arch I first made a partition and assigned it as an LVM partition, then set up and opened LUKS, then set up LVM itself.
When Arch was operational, sometimes the decryption process would fail and throw me into GRUB rescue shell saying that the logical volume was not found. I presume it's because the motherboard passes NVMEs in different order yet in GRUB config file the partition was set as /dev/nvme0n1p3:<LVM VG:LV>, not as a UUID. Back then it could be fixed by unplugging the laptop's power cable until the decryption prompt appeared. After the failure nothing works anymore, including removing all other drives.
Is it toast or can I do something to recover it?
|
The issue was solved using Method #1 created and kindly suggested by frostschutz. Everything worked out smoothly and without any errors. After dumping and repairing a LUKS header file I was able to use it to open the partition. Then I mounted the volume after scanning for it using lvscan.
For more extreme cases there is also Method #2.
From now on I'll be smarter and will start making header backups :)
| Encrypted LVM "is not a valid LUKS device", cannot boot or open |
1,673,544,383,000 |
My /home partition (on Linux Debian testing) is encrypted with LUKS.
$ mount|grep home
/dev/mapper/home-crypt on /home type ext4 (rw,relatime)
Configuration via /etc/crypttab:
home-crypt UUID=830807e5-01fb-4d82-b2ce-c2e51b176560 none luks,timeout=180
During boot, the LUKS password to decrypt my home partition is required via prompt. But this prompt is mixed among other kernel/system logs.
How to add a waiting time so that this prompt is displayed after all others logs during boot ?
|
You can delay the mounting of the LUKS-encrypted partition by specifying a systemd service unit that waits for a set time before proceeding with the unlocking and mounting.
Create a custom systemd service file, for example /etc/systemd/system/delay-luks-prompt.service, and add the following content:
[Unit]
Description=Delay for LUKS prompt
After=local-fs.target
[Service]
ExecStart=/bin/sleep 30
Type=oneshot
[Install]
WantedBy=multi-user.target
This will cause a delay of 30 seconds.
Add this custom service as a dependency for the [email protected] to ensure it waits for the delay:
Edit the /lib/systemd/system/[email protected] file and locate the [Unit] section. Add the line:
After=delay-luks-prompt.service
Your [Unit] section might then look like:
[Unit]
Description=Cryptography Setup for %I
Documentation=man:[email protected](8) man:crypttab(5)
DefaultDependencies=no
Conflicts=umount.target
Before=umount.target
After=cryptsetup-pre.target
After=delay-luks-prompt.service
BindsTo=dev-mapper-%i.device
...
Enable and start the custom service:
systemctl enable delay-luks-prompt.service
systemctl start delay-luks-prompt.service
Regenerate your initramfs:
update-initramfs -u
Reboot and test.
This should result in the LUKS password prompt for your /home partition being delayed by 30 seconds, allowing other boot logs to display first.
REMEMBER TO BACK UP FILES BEFORE DOING CHANGES
| How to configure waiting time for LUKS password |
1,673,544,383,000 |
It seems that modern SSDs degrade in performance the more data they are holding.
My understanding is that this is because manufacturers put less and less storage cells on the SSDs relative to their total capacity and now we reached a point where a single cell stores up to 4 bits (QLC) instead of just one, greatly reducing the performance.
One trick modern SSDs use is SLC caching which means that performance is increased by only storing 1 bit per cell. But with a QLC (4 bits per cell) SSDs, you can only do this until the SSD is 1/4 (25%) full and with TLC (3 bits per cell) that would be at 1/3 (33%).
This is just my poor understanding of the technology, I'm sure it's more complicated in reality, but I have seen countless reports of QLC SSDs dropping in performance once a certain threshold is reached.
The important question is, what happens if I use LUSK disk encryption on such an SSD? Will it think that is 100% full and thus not be able to use SLC caching?
|
The important question is, what happens if I use LUSK disk encryption on such an SSD? Will it think that is 100% full
From the point of view of the disk there is no difference between LUKS and any other "non encryption" filesystem like Ext or XFS. Formatting a device to LUKS doesn't encrypt the entire device, only blocks of newly written data to the filesystem on top of the LUKS/dm-crypt device are encrypted and written to the disk.
Only think you should make sure to do with LUKS and SSD is to allow the discard option in /etc/crypttab to make sure TRIM goes through the dm-crypt device to the disk.
| Does LUKS disk encyption break SLC caching on QLC/TLC SSDs? |
1,673,544,383,000 |
Following the example of how to add a FIDO2 key from a YubiKey, but I can't figure out how to use the YubiKey to unlock it form the command line. The instructions talk about unlocking at boot--but that's not what I want.
Setup
Make a 128 MiB file, make it a block device on loop0 and setup LUKS.
$ dd if=/dev/urandom of=disk.bin bs=1M count=128
128+0 records in
128+0 records out
134217728 bytes (134 MB, 128 MiB) copied, 0.534038 s, 251 MB/s
$ losetup /dev/loop0 disk.bin
$ cryptsetup luksFormat -y /dev/loop0
WARNING!
========
This will overwrite data on /dev/loop0 irrevocably.
Are you sure? (Type 'yes' in capital letters): YES
Enter passphrase for temp.bin:
Verify passphrase:
Add the Yubikey.
$ systemd-cryptenroll /dev/loop0 --fido2-device=auto --fido2-with-client-pin=yes
üîê Please enter current passphrase for disk /dev/loop0: ****
Requested to lock with PIN, but FIDO2 device /dev/hidraw9 does not support it, disabling.
Initializing FIDO2 credential on security token.
üëÜ (Hint: This might require confirmation of user presence on security token.)
Generating secret key on FIDO2 security token.
üëÜ In order to allow secret key generation, please confirm presence on security token.
New FIDO2 token enrolled as key slot 1.
Remove the the non-FIDO2 key.
$ cryptsetup -q -v luksKillSlot /dev/loop0 0
Keyslot 0 is selected for deletion.
Key slot 0 removed.
Command successful.
Problem
Now what? This doesn't work:
$ cryptsetup open /dev/loop0 loop0_encrypted
Enter passphrase for disk.bin:
I now have a LUKS disk but I don't know how to unlock it. All tutorials I found say to make modifications to /etc/crypttab and give instructions for mounts at boot. I want to mount without rebooting and (preferably) without modifying /etc/crypttab. What am I missing?
|
Using systemd-cryptenroll to set up the encryption suggests that you need a similar tool of the systemd family to unlock it.
Turns out it is essentially Example 3 in the systemd-specific version of the crypttab(5) man page.
sudo /usr/lib/systemd/systemd-cryptsetup attach loop0_encrypted /dev/loop0 - fido2-device=auto
The equivalent /etc/crypttab entry would be:
loop0_encrypted /dev/loop0 - fido2-device=auto
Note that for example, on Debian 12, the crypttab(5) man page says:
ON DIFFERENT CRYPTTAB FORMATS
Please note that there are several independent cryptsetup wrappers with their own crypttab format. This manpage covers Debian's implementation for initramfs scripts and SysVinit init scripts. systemd brings its own crypttab implementation. We try to cover the differences between the systemd and our implementation in this manpage, but if in doubt, better check the systemd crypttab(5) manpage, e.g. online at https://www.freedesktop.org/software/systemd/man/crypttab.html.
| FIDO2 (YubiKey) to unlock LUKS from command line |
1,673,544,383,000 |
What's the easiest way to format an external SSD with encryption and RAID1-style data replication?
As I recently grew suspicious of my SSD+luks+btrfs setup, I've started wondering how to reduce risk of data loss in certain infrequently used external disks of mine.
While the btrfs and dm-crypt documentation is very helpful, I would prefer to use a method with reasonable defaults that I can trust to evolve over time, without having to study the entire matter from scratch each time.
Ideally, the solution would involve blivet-gui, as I would like to have a better understanding of it since it's used by the Fedora installer.
|
From kernel 4.5, this can be done after filesystem creation. Just create a single btrfs volume with blivet-gui in the usual way (with encryption), and then use btrfs-balance / convert to switch the data to a DUP profile after the partition has been created and mounted, like:
sudo btrfs balance start -mconvert=dup /run/media/<path>
sudo btrfs balance start -dconvert=dup /run/media/<path>
After writing some files you'll then see something like:
$ lsblk | tail -n3
sdf 8:80 0 232,9G 0 disk
└─sdf1 8:81 0 232,9G 0 part
└─luks-<UUID> 253:7 0 232,9G 0 crypt /run/media/<path>
$ sudo btrfs filesystem df /run/media/<path>
Data, DUP: total=108.00GiB, used=106.64GiB
System, DUP: total=32.00MiB, used=16.00KiB
Metadata, DUP: total=2.00GiB, used=169.94MiB
GlobalReserve, single: total=131.78MiB, used=0.00B
Of course, dup is no substitute for backups or even RAID1 across two distinct physical devices. See the warnings at dup profiles on a single device:
Whether there are really 2 physical copies highly depends on the underlying device type.
For example, a SSD drive can remap the blocks internally to a single copy--thus deduplicating them. This negates the purpose of increased redundancy and just wastes filesystem space without providing the expected level of redundancy.
So, deduplication probably helps more on an HDD than on an SSD. It's also not clear how encryption affects deduplication and wear-leveling techniques.
| How to create a data-redundant encrypted filesystem on an external SSD? |
1,673,544,383,000 |
I am trying to expand an existing RAID1 array with an ext4 filesystem on a LUKS volume on Debian GNU/Linux 10 (buster).
This is my disk layout from lsblk:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 9,1T 0 disk
├─sda1 8:1 0 10M 0 part
├─sda2 8:2 0 477M 0 part
│ └─md0 9:0 0 476,7M 0 raid1 /boot
├─sda3 8:3 0 55,9G 0 part
│ └─md1 9:1 0 55,9G 0 raid1 /
└─sda4 8:4 0 7,2T 0 part
└─md2 9:2 0 7,2T 0 raid1
└─md2_crypt 253:0 0 7,2T 0 crypt /data
sdb 8:16 0 9,1T 0 disk
├─sdb1 8:17 0 10M 0 part
├─sdb2 8:18 0 477M 0 part
│ └─md0 9:0 0 476,7M 0 raid1 /boot
├─sdb3 8:19 0 55,9G 0 part
│ └─md1 9:1 0 55,9G 0 raid1 /
└─sdb4 8:20 0 7,2T 0 part
└─md2 9:2 0 7,2T 0 raid1
└─md2_crypt 253:0 0 7,2T 0 crypt /data
I want to expand /data to take up the remaining free space. So this means expanding sda4, sdb4, and md2 and thus also md2_crypt and the filesystem on it.
This is how I plan to do this, but I am not sure this is correct:
Unmount /data (umount /data)
Close LUKS volume (cryptsetup luksClose md2_crypt)
Fail and remove sda4 (mdadm -f /dev/md2 /dev/sda4 && mdadm -r /dev/md2 /dev/sda4)
Delete partition /dev/sda4 and create a new one that takes up entire free disk space. (cgdisk /dev/sda4) Maybe I can just grow existing without deleting?
Add back the resized sda4 (mdadm --add /dev/md2 /dev/sda4)
Wait for it to sync (mdadm --wait /dev/md2)
Repeat steps 4..6 with sdb4 instead of sda4.
Remove write intend bitmap from raid array (mdadm --grow /dev/md2 -b none)
Extend raid array (mdadm --grow /dev/md2 --size max)
Wait for it to sync (mdadm --wait /dev/md2)
Add back bitmap (mdadm --grow /dev/md2 --bitmap internal)
Resize LUKS volume to take all available space (cryptsetup luksOpen md2_crypt && cryptsetup resize md2_crypt)
fsck file system (e2fsck -f /dev/mapper/md2_crypt)
Grow ext4 filesystem (resize2fs /dev/mapper/md2_crypt)
Mount filesystem again (mount /data)
Is this approach correct? Am I missing important steps? Is the order correct?
I am particularly concerned about the LUKS part as I have never grown LUKS before.
Also, I am concerned about the write intend bitmap. Not sure if and when this is to be removed/added or if at all necessary.
Additional details:
This is my /proc/mdstat
Personalities : [raid1] [linear] [multipath] [raid0] [raid6] [raid5] [raid4] [raid10]
md2 : active raid1 sda4[3] sdb4[4]
7754802503 blocks super 1.2 [2/2] [UU]
[=============>.......] check = 66.6% (5170546304/7754802503) finish=237.0min speed=181708K/sec
bitmap: 0/15 pages [0KB], 262144KB chunk
md1 : active raid1 sdb3[4] sda3[3]
58560512 blocks super 1.2 [2/2] [UU]
md0 : active raid1 sdb2[4] sda2[3]
488128 blocks super 1.2 [2/2] [UU]
unused devices: <none>
(it will be done sync'ing before I start this)
mdadm --detail /dev/md2
/dev/md2:
Version : 1.2
Creation Time : Sat Apr 1 20:30:05 2017
Raid Level : raid1
Array Size : 7754802503 (7395.56 GiB 7940.92 GB)
Used Dev Size : 7754802503 (7395.56 GiB 7940.92 GB)
Raid Devices : 2
Total Devices : 2
Persistence : Superblock is persistent
Intent Bitmap : Internal
Update Time : Wed Apr 12 16:57:07 2023
State : clean, checking
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0
Consistency Policy : bitmap
Check Status : 66% complete
Events : 235789
Number Major Minor RaidDevice State
4 8 20 0 active sync /dev/sdb4
3 8 4 1 active sync /dev/sda4
LUKS INFO:
LUKS header information for /dev/md2
Version: 1
Cipher name: aes
Cipher mode: xts-plain64
Hash spec: sha1
Payload offset: 4096
MK bits: 512
fdisk -l /dev/sda
Disk /dev/sda: 9,1 TiB, 10000831348736 bytes, 19532873728 sectors
Disk model: MG06ACA10TE
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Device Start End Sectors Size Type
/dev/sda1 2048 22527 20480 10M BIOS boot
/dev/sda2 22528 999423 976896 477M Linux RAID
/dev/sda3 999424 118185983 117186560 55,9G Linux RAID
/dev/sda4 118185984 15628053134 15509867151 7,2T Linux RAID
parted /dev/sda print free output:
Warning: Not all of the space available to /dev/sda appears to be used, you can fix the GPT to use
all of the space (an extra 3904820560 blocks) or continue with the current setting?
Fix/Ignore? ^C
Model: ATA MG06ACA10TE (scsi)
Disk /dev/sda: 10,0TB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
17,4kB 1049kB 1031kB Free Space
1 1049kB 11,5MB 10,5MB bios_grub
2 11,5MB 512MB 500MB raid
3 512MB 60,5GB 60,0GB raid
4 60,5GB 8002GB 7941GB raid
8002GB 10,0TB 1999GB Free Space
|
Way too many steps. You don't want to fail drives unless absolutely necessary. (※)
Assuming there is free, unpartitioned space available and no other partition in the way, you can just grow everything directly, in order. With online resize like this, there is no need to umount anything.
# Partition (repeat it for all disks)
parted /dev/sdx print free
parted /dev/sdx resizepart 4 100%
# RAID
mdadm --grow /dev/md2 --size=max
mdadm --wait /dev/md2
# LUKS
cryptsetup resize md2_crypt
# EXT4
resize2fs /dev/mapper/md2_crypt
You should check after each step that it actually worked, e.g. lsblk shows the new, larger size for the partition / md / crypt device after resizing it. Ideally, it should just work, but sometimes, the kernel refuses to re-read partition tables. In such a case, you might have to reboot after all.
(※) Although it could make sense in a different context — to keep an untouched mirror around while performing dangerous changes. But from your description, it does not seem like this was your intention. You would not be re-adding the drive at all, until everything else is done and verified to be working.
| How to extend madam RAID1 with LUKS and ext4 filesystem on Debian 10 |
1,673,544,383,000 |
I have a luks device and it is opened on boot by /etc/crypttab. lsblk looks like this:
sdc 8:32 1 114,6G 0 disk
└─luks-672dcc74-d002-47dc-b61b-525baf91dc7c 253:2 0 114,6G 0 crypt
I pmount the device like this:
pmount /dev/mapper/luks-672dcc74-d002-47dc-b61b-525baf91dc7c
I unmount it like this (both work):
pumount /dev/mapper/luks-672dcc74-d002-47dc-b61b-525baf91dc7c
pumount /media/mapper_luks-672dcc74-d002-47dc-b61b-525baf91dc7c
But after pumount lsblk looks like this:
sdc 8:32 1 114,6G 0 disk
Why did pumount close the luks device? From the man page of pumount it says:
Normally, pumount will not luksClose (see cryptsetup(1)) a device pmount did not open.
The luks device was opened by /etc/crypttab on boot and not by pmount! Why does pumount close the luks device? Is this a bug?
I am on debian bullseye.
|
Note: I'm completely unfamiliar with pumount, and I don't even have a Debian install available for testing, so I just grabbed the source code from Debian and making wild assumptions based on what I found in there…
pumount has an option, --luks-force to close LUKS devices it did not open (as you already quoted from the manpage).
However from the source code, there seems to be a mistake in the implementation.
So in pumount.c there is this bit of option parsing:
int luks_force = 0;
[...]
{ "luks-force", 0, NULL, 'L'},
[...]
case 'L': luks_force = 1; break;
...and that's it! The option sets the luks_force = 1 variable. Otherwise it's initialized as 0.
But it doesn't matter one bit at all since... that variable isn't used anywhere.
In luks.c there is this bit of code:
void
luks_release( const char* device, int force )
{
if(force || luks_has_lockfile(device)) {
spawnl( CRYPTSETUP_SPAWN_OPTIONS,
CRYPTSETUP, CRYPTSETUP, "luksClose", device, NULL );
luks_remove_lockfile(device);
[...]
So it will luksClose if either a lockfile is present, or if force is true.
And this function is called by pumount.c like this:
/* release LUKS device, if appropriate */
luks_release( device, 1 );
So there you go, no matter what you do, force is always set to 1, and so it closes the LUKS device.
That last line is probably where it should be using the luks_force variable instead of 1.
| Why does pumount close a luks device it did not open? |
1,673,544,383,000 |
I have a device I've encrypted with luks1 and I decrypt it with a script in init.d. (Centos 6, no keyscript in crypttab). Its a raid disk, with the encryption under the raid, but I don't think that matters.
The lsblk looks like:
sda 8:0 0 238.5G 0 disk
└─md127 9:127 0 476.7G 0 raid0
└─luksmap1 (dm-15) 253:15 0 476.7G 0 crypt /data11
sdb 8:16 0 238.5G 0 disk
└─md127 9:127 0 476.7G 0 raid0
└─luksmap1 (dm-15) 253:15 0 476.7G 0 crypt /data1
The problem is that dracut finds it during boot and asks for a password. I need to be able reboot this without being physically present.
It's set to noauto in fstab. I've told dracut not to load /etc/mdadm.conf. cryptab is empty.
How do I tell dracut not to look for ask for the password? Or timeout after waiting a bit? Or just keep going if there's no keyboard present?
|
To completely prevent dracut from scanning for LUKS devices, add the following to your kernel command line:
rd.luks=0
If you want to only decrypt specific disks (e.g. I wanted it to decrypt the root partition, but not other encrypted disks), you should instead add
rd.luks.uuid=<DISK_UUID_HERE>
once per encrypted disk and not add rd.luks=0. You can find the UUIDs for disks with lsblk -o +uuid.
More on the options can be found in the manpage dracut.cmdline(7).
| Stop Dracut from asking for a password |
1,673,544,383,000 |
I've successfully created a LUKS drive from a 32Mb USB flash drive. However when I write an ext4 filesystem to it I am unable to mount the result, or even run fsck or dumpe2fs etc.
The drive shows up under lsblk as
sda 8:0 1 31M 0 disk
└─luks 253:0 0 15M 0 crypt
I'm then writing the filesystem with sudo mkfs.ext4 -v /dev/mapper/luks, which produces
mke2fs 1.45.5 (07-Jan-2020)
fs_types for mke2fs.conf resolution: 'ext4', 'small'
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
3840 inodes, 3840 blocks
192 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4194304
1 block group
32768 blocks per group, 32768 fragments per group
3840 inodes per group
Allocating group tables: done
Writing inode tables: done
Creating journal (1024 blocks): done
Writing superblocks and filesystem accounting information: done
Output from various commands
$ sudo cryptsetup luksDump /dev/sda
LUKS header information
Version: 2
Epoch: 3
Metadata area: 16384 [bytes]
Keyslots area: 16744448 [bytes]
UUID: 1f30e940-4144-4980-a32a-4f1b78a46fc5
Label: (no label)
Subsystem: (no subsystem)
Flags: (no flags)
Data segments:
0: crypt
offset: 16777216 [bytes]
length: (whole device)
cipher: aes-xts-plain64
sector: 512 [bytes]
Keyslots:
0: luks2
Key: 512 bits
Priority: normal
Cipher: aes-xts-plain64
Cipher key: 512 bits
PBKDF: argon2i
Time cost: 4
Memory: 187471
Threads: 4
Salt: 5c c4 28 e0 bc f6 7f df b2 1c 77 b6 fa f3 f1 bc
48 66 fc 56 e3 5c e5 13 cc af 1d 52 ec df fc 93
AF stripes: 4000
AF hash: sha256
Area offset:32768 [bytes]
Area length:258048 [bytes]
Digest ID: 0
Tokens:
Digests:
0: pbkdf2
Hash: sha256
Iterations: 18853
Salt: 62 8a b7 2c 4d 74 d3 6b 46 c2 9b 34 e2 d6 5c 3d
06 12 ee a7 5b b0 81 1f d0 99 19 b6 4f de 5c 77
Digest: c2 71 c1 d5 de 16 d9 cc 8c 15 f2 34 21 42 3a a3
24 d1 82 26 cd ab f9 98 0c 0a 68 7a 35 e2 3d a9
^The Subsystem: (no subsystem) line is worrying
$ sudo mount -v /dev/mapper/luks /media/luks
mount: /media/luks: wrong fs type, bad option, bad superblock on /dev/mapper/luks, missing codepage or helper program, or other error.
$ sudo fsck /dev/mapper/luks
fsck from util-linux 2.34
e2fsck 1.45.5 (07-Jan-2020)
ext2fs_open2: Bad magic number in super-block
fsck.ext2: Superblock invalid, trying backup blocks...
fsck.ext2: Bad magic number in super-block while trying to open /dev/mapper/luks
...
^fsck.ext2 suggests to me that it can't tell the filesystem
$ sudo dumpe2fs /dev/mapper/luks
dumpe2fs 1.45.5 (07-Jan-2020)
dumpe2fs: Bad magic number in super-block while trying to open /dev/mapper/luks
Couldn't find valid filesystem superblock.
All of these suggest to me that the filesystem hasn't been created correctly, however from what I can tell even a measly 15Mb should be enough space and I'm not sure what else could be the problem
|
Sounds like a hardware problem. You should run badblocks in write mode on the device.
Another option would be
to create a small image file (a few 100 MiB)
put a loop device upon it
create the filesystem in it
copy the image file to the (first part of the) device
compare the image file to the respective part of the device
dd if=/dev/zero of=/path/to/imagefile bs=1M count=100
losetup /dev/loop0 /path/to/imagefile
mkfs.ext4 /dev/loop0
blockdev --getsz /dev/loop0
204800
dd if=imagefile of=/dev/mapper/luks
sha1sum imagefile
aaafc117548aaebef3dbb5f4a609022e386192b6 imagefile
dd if=/dev/mapper/luks count=204800 | sha1sum
204800+0 Datensätze ein
204800+0 Datensätze aus
aaafc117548aaebef3dbb5f4a609022e386192b6 -
| Unable create ext4 filesystem under LUKS |
1,673,544,383,000 |
I have an almost fresh Kali linux installation in an Hyper-V virtual machine. It is configured with hard disk encryption during installation.
After some working days, I reduced the amount of RAM memory reserved for the VM, but when I boot up the reconfigured machine, the password used to decrypt the hard drive is reported as invalid.
The reported error is:
cryptsetup: ERROR: sdaX_crypt: cryptsetup failed, bad password or options?
If I undo the configuration change the password is valid again...
Does exist a relation between the LUKS decryption algorithm and the machine memory size? It doesn't have sense, in my opinion.
Which can be the reason?
Thanks in advance.
|
LUKS2 by default uses the argon2 key derivation function which is so called memory hard -- it intentionally uses a lot of RAM (up to 1 GiB with cryptsetup) when unlocking the device to prevent brute force attacks on GPUs. Exact amount of RAM it requires depends on the amount of RAM you have when creating the LUKS device so if you reduce the amount of RAM later you won't be able to unlock it.
You can change it using cryptsetup luksChangeKey <device> (which is usually used to change the password but it also allows changing the key derivation function) either with --pbkdf-memory <RAM in kilobytes> to lower the argon2 required memory or with --pbkdf pbkdf2 to use the older PBKDF2 key derivation function that doesn't use memory at all.
| Linux Hard drive encryption password invalid after memory size change |
1,673,544,383,000 |
I have installed Ubuntu 20.04 on LUKS/LVM but unfortunately on booting I am only getting a grub> prompt.
# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 465.8G 0 disk
├─sda1 8:1 0 731M 0 part /boot
└─sda5 8:5 0 465G 0 part
└─sda5_crypt 253:0 0 465G 0 crypt
├─ubuntu--vg-home 253:1 0 356G 0 lvm /home
└─ubuntu--vg-root 253:2 0 109G 0 lvm /
Install grub to MBR and generate grub.cfg (see 1, 2)
# grub-install /dev/sda
# grub-mkconfig -o /boot/grub/grub.cfg
Grub.cfg seems to have correct LVM root volume UUID:
# cat /boot/grub/grub.cfg
....
set root='lvmid/MGzfKv-uhLG-wmry-Yqb2-D09r-OfKh-SDs3eb/lZDSre-QLBU-9OvM-aVrN-kR6V-DFXg-lBhRn7'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint='lvmid/MGzfKv-uhLG-wmry-Yqb2-D09r-OfKh-SDs3eb/lZDSre-QLBU-9OvM-aVrN-kR6V-DFXg-lBhRn7' 617f84d9-1433-4620-a0c0-833fb8ce1e2f
else
search --no-floppy --fs-uuid --set=root 617f84d9-1433-4620-a0c0-833fb8ce1e2f
fi
....
# blkid
/dev/sda5: UUID="3fbd1007-9f85-4b85-bdf2-ae55e0244bb6" TYPE="crypto_LUKS" PARTUUID="005a4774-05"
/dev/sda1: UUID="27ca1bd4-7811-4c3a-b319-2b8dd1ce57cd" TYPE="ext4" PARTUUID="005a4774-01"
/dev/mapper/sda5_crypt: UUID="UoR32h-GB2N-GYf4-XBEP-P0rd-RrZ6-f6PK6d" TYPE="LVM2_member"
/dev/mapper/ubuntu--vg-home: UUID="0d81e74f-fe7b-4ef4-ba61-6d664d54d77c" TYPE="ext4"
/dev/mapper/ubuntu--vg-root: UUID="617f84d9-1433-4620-a0c0-833fb8ce1e2f" TYPE="ext4"
# ls -l /dev/disk/by-id
rwxrwxrwx 1 root root 10 Oct 19 21:45 dm-name-sda5_crypt -> ../../dm-0
lrwxrwxrwx 1 root root 10 Oct 19 21:45 dm-name-ubuntu--vg-home -> ../../dm-1
lrwxrwxrwx 1 root root 10 Oct 19 21:45 dm-name-ubuntu--vg-root -> ../../dm-2
lrwxrwxrwx 1 root root 10 Oct 19 21:45 dm-uuid-CRYPT-LUKS2-3fbd10079f854b85bdf2ae55e0244bb6-sda5_crypt -> ../../dm-0
lrwxrwxrwx 1 root root 10 Oct 19 21:45 dm-uuid-LVM-MGzfKvuhLGwmryYqb2D09rOfKhSDs3ebHvMqdeqlhxMFcNl0XqdTRiC9sdWUmnVU -> ../../dm-1
lrwxrwxrwx 1 root root 10 Oct 19 21:45 dm-uuid-LVM-MGzfKvuhLGwmryYqb2D09rOfKhSDs3eblZDSreQLBU9OvMaVrNkR6VDFXglBhRn7 -> ../../dm-2
lrwxrwxrwx 1 root root 10 Oct 19 21:45 lvm-pv-uuid-UoR32h-GB2N-GYf4-XBEP-P0rd-RrZ6-f6PK6d -> ../../dm-0
Add sda5 UUID & volume UUID to crypttab and fstab (see 1):
# cat /etc/crypttab
sda5_crypt UUID=3fbd1007-9f85-4b85-bdf2-ae55e0244bb6 none luks
# cat /etc/fstab:
UUID=27ca1bd4-7811-4c3a-b319-2b8dd1ce57cd /boot ext4 defaults 0 2
UUID=617f84d9-1433-4620-a0c0-833fb8ce1e2f / ext4 defaults,errors=remount-ro 0 1
/swapfile none swap sw 0 0
Generate initramfs (see 1):
# update-initramfs -c -k all
# ls -lah /boot
drwxr-xr-x 4 root root 4.0K Oct 19 21:31 grub
-rw-r--r-- 1 root root 81M Oct 19 20:55 initrd.img-5.4.0-42-generic
|
Since your LVM is on a LUKS-encrypted partition, the LVM root volume UUID will not be visible until the encryption is unlocked.
By default, Debian/Ubuntu GRUB configuration may refer to several things located on the root filesystem, including:
font file /usr/share/grub/unicode.pf2
GRUB background image, e.g. /usr/share/desktop-base/futureprototype-them/grub/grub-16x9.png on Debian 10
If you don't want to enter your LUKS passphrase twice (once for GRUB, then again for initramfs), you'll need to make sure these are copied to /boot (or any other unencrypted filesystem GRUB will be able to access) and that GRUB will look for them from there.
For the font file, you can set the GRUB_FONT=/boot/grub/unicode.pf2 in /etc/default/grub and copy the font file to /boot/grub before running grub-mkconfig.
At least on Debian 10, the /etc/grub.d/05_debian_theme script seems to have built-in functionality to copy the background image to e.g. /boot/grub/.background_cache.png if the root filesystem will not be directly readable by GRUB (as in your case, as it will be encrypted). You'll need to verify that this functionality (or its equivalent in a corresponding Ubuntu script) gets properly triggered, and if not, use the GRUB_BACKGROUND=/boot/grub/<filename> in /etc/default/grub to override the background image path and copy the appropriate image file to /boot/grub/ manually.
Note: whenever grub.cfg has a set root=<something> or search ... --set=root command, it is only to specify the filesystem from which any subsequent GRUB commands will load any files. It does not have to refer to the root filesystem of your Ubuntu installation: that will be specified exclusively by the root=... kernel boot option on the linux /boot/vmlinuz-... line.
In your case, unlocking the LUKS encryption and finding the root filesystem within it will be initramfs's job, not GRUB's.
| Grub is not booting Ubuntu with LUKS/LVM |
1,673,544,383,000 |
I have an internal SSD (NVMe) on which I've installed Ubuntu 18.04 with Full Encryption using LUKS. Recently, I replaced the motherboard of my laptop which caused the signature verification of the kernel to get failed during boot.
error: /boot/vmlinuz-****-generic has invalid signature
error: you need to load the kernel first
If I tried to boot without secure boot then it gets past the signature verification, but later during boot process, I get an error that says "cryptsetup: lvm is not available".
So, in order to fix the signature verification issue that occurs with secure boot, I read that I need to add a newly signed kernel into the boot partition using a live USB. However, after booting into the Live OS (Ubuntu) I couldn't find the NVMe drive at all. I checked the /dev location and used several tools such as gparted, fdisk, lsblk. I just couldn't get the drive listed with any of these tools.
May I know why the drive is not getting detected? And how to get this drive mounted? I am also not sure why the "cryptsetup: lvm is not available" issue occurs.
PS: I tried booting up WindowsToGo (Windows 10) and from it, I was able to find the SSD drive being listed under "Disk Management" utility. So, I don't think it is an issue with the SSD. It is functional. I am just not able to get this drive listed with Live Linux.
|
I finally fixed the issue.
The issue occurred since the BIOS settings of SATA Operation was defaulted to RAID On mode instead of AHCI mode, with the newly replaced motherboard.
So, basically changing the SATA Operation to AHCI and then disabling Secure Boot(to get rid of Invalid Kernel Signature) fixed the issue.
| LUKS encrypted drive is missing. "cryptsetup: lvm is not available" |
1,593,865,025,000 |
I plan to provide a Linux appliance to several users. These users are tech savvy and can easily reset the root password on a standard linux system.
How can I create a running Linux system that keeps even the root user out of the filesystem once protected? (I looked at disk encryption like LUKS but in all cases the root user can gain access to an automounted partition).
How do I solve this problem? Stack exchange questions like this assume the attacker does NOT have root access, but it seems simple to reset root password by booting into single user/recovery mode.
I've read about LUKS but FDE requires rolling the keyfile into the initramfs (as shown here) but I think you can easily unroll the initramfs and extract the key. So I don't think this solves the problem
|
I found the answer: encrypt the full disk with LUKS, then store the keys in the system TPM. That way the entire disk is encrypted and an end user can't extract the keys from the TPM...very secure:
LUKS with TPM
| Protecting (encrypting) system from even root access |
1,593,865,025,000 |
I have my primary Ubuntu install on one disk, and a secondary install (for offline backups of the primary) on another disk. For convenience, I would like the root volume of the second install mounted within the primary install.
I have a crypttab entry: sda3_ubuntu UUID=XXX keyfile luks,nofail,
and an fstab entry: /dev/mapper/vgubuntu-root /home/XXX/sda3_ubuntu ext4 nofail,errors=remount-ro 0 1
Using cryptdisks_start and at boot, the volume is unlocked as expected. However, the root volume is never mounted because the LVM volume is inactive after it's unlocked (and thus there are no dm devices for it). If I activate it, mount -a successfully mounts it.
This is all very scriptable, but I feel as though I'm missing something that would automagically activate the LVM volume in between, as would happen for a boot volume. Does such a thing exist and my Google-foo is failing me?
|
LVM should be able to autoactivate the underlying VG (and LVs) after decrypting the LUKS device. The important things to check would be the LVM configuration file(s) and if the proper services are enabled and running.
/etc/lvm/lvm.conf
event_activation = 1
auto_activation_volume_list should not be set (the default is to activate all of the LVs).
Enabling lvmpolld (use_lvmpolld = 1) could also be worth a try.
The services that should be running are:
lvm2-monitor
dm-event
You can check your systemd execution chain with a command:
systemd-analyze plot > plot.svg
Look at what services start when. Maybe some service is not active or is not starting at the right time.
| How to have a luks-protected LVM volume mounted at boot |
1,593,865,025,000 |
I have a btrfs raid1 composed of two entire, large harddisks of the same size. Now I would like to migrate the data to a btrfs raid1 composed of two encrypted luks-devices on the same harddisks. I have separate copies of the data on other boxes as a backup. My plan is to remove one device from the raid1, create a luks volume on the removed device, create a btrfs filesystem on the luks device, copy the data onto the new device, create a luks volume on the second device and add the second device to the encrypted btrfs system.
Does this sound reasonable and does anyone have a recipe for that? Or should I better buy a third harddisk for the migration?
|
To answer my own question I have made the following experiment on a spare hard disk. Be sure to have a valid and restorable backup. These commands can irretrievably destroy valuable data if e.g. applied to the wrong device.
Creating the test system
First we need two partitions to work with, I created them with fdisk to get:
Device Boot Start End Sectors Size Id Type
/dev/sda1 2048 20973567 20971520 10G 83 Linux
/dev/sda2 20973568 41945087 20971520 10G 83 Linux
Then I created an unencrypted btrfs raid1 (you need to force with -f if the partitions are used, but be sure you know what you are doing):
> mkfs.btrfs -m raid1 -d raid1 /dev/sda1 /dev/sda2
...
Devices:
ID SIZE PATH
1 10.00GiB /dev/sda1
2 10.00GiB /dev/sda2
Then I mounted the filesystem to have a live system to work with, and created a test file:
> mount /dev/sda1 /mnt/tmp
> echo "Hello World" > /mnt/tmp/hello.txt
Doing the migration
First resize the filesystem so we can later replace the devices with the smaller encrypted versions.
> btrfs fi resize 1:9G /mnt/tmp
> btrfs fi resize 2:9G /mnt/tmp
Then we remove the duplication in the system (needs to be forced because it increases the risk of data loss). This takes a long time on a large file system, as it rewrites all the data. We can check the progress with btrfs balance status /mnt/tmp.
> btrfs balance start -mconvert=single -dconvert=single /mnt/tmp --force
Done, had to relocate 3 out of 3 chunks
Then we can remove one of the devices. If this takes long, we can check the status using btrfs device usage /mnt/tmp.
> btrfs device remove 1 /mnt/tmp
> btrfs device usage /mnt/tmp
/dev/sda2, ID: 2
Device size: 10.00GiB
Device slack: 1.00GiB
Data,single: 1.00GiB
Metadata,single: 256.00MiB
System,single: 32.00MiB
Unallocated: 7.72GiB
Then we convert it to a LUKS device
> cryptsetup luksFormat /dev/sda1
> cryptsetup luksOpen /dev/sda1 crypt_1
We add the encrypted device to the filesystem and remove the other one
> btrfs device add /dev/mapper/crypt_1 /mnt/tmp
> btrfs device remove /dev/sda2 /mnt/tmp
This will again take a long time for a filesystem with a lot of data, as all data have to be moved.
We then convert the other device to LUKS, add it back to the filesystem and rebalance as Raid1:
> cryptsetup luksFormat /dev/sda2
> cryptsetup luksOpen /dev/sda2 crypt_2
> btrfs device add /dev/mapper/crypt_2 /mnt/tmp
> btrfs balance start -dconvert=raid1 -mconvert=raid1 /mnt/tmp
Done, had to relocate 3 out of 3 chunks
Of course the last command will again take a long time if we have a lot of data. Let's check the result:
> btrfs filesystem show /mnt/tmp
Label: none uuid: e894df1a-b62f-49cb-bcdc-8e6eb25945a4
Total devices 2 FS bytes used 448.00KiB
devid 3 size 9.98GiB used 1.28GiB path /dev/mapper/crypt_1
devid 4 size 9.98GiB used 1.28GiB path /dev/mapper/crypt_2
> btrfs filesystem df /mnt/tmp
Data, RAID1: total=1.00GiB, used=320.00KiB
System, RAID1: total=32.00MiB, used=16.00KiB
Metadata, RAID1: total=256.00MiB, used=112.00KiB
GlobalReserve, single: total=16.00MiB, used=0.00B
Voilá, we have a RAID 1 on two encrypted devices, still containing our data!
> cat /mnt/tmp/hello.txt
Hello World
| Converting btrfs raid1 on two disks to btrfs raid1 on two luks-encrypted disks |
1,593,865,025,000 |
For some reason, I can't add a key to my encrypted swap.
My /etc/crypttab:
swap_crypt /dev/disk/by-partuuid/c4f049d5-ae21-44d6-b753-6e72b7e21770 none luks,swap,discard,keyscript=decrypt_keyctl
root_crypt UUID=26f3c181-e041-47f2-929b-de631a2f1d3f none luks,discard,keyscript=decrypt_keyctl
So to identify those disks:
# ls -l /dev/disk/by-partuuid/c4f049d5-ae21-44d6-b753-6e72b7e21770
lrwxrwxrwx 1 root root 15 Mar 5 22:34 /dev/disk/by-partuuid/c4f049d5-ae21-44d6-b753-6e72b7e21770 -> ../../nvme0n1p7
# blkid |grep 26f3c181-e041-47f2-929b-de631a2f1d3f
/dev/nvme0n1p8: UUID="26f3c181-e041-47f2-929b-de631a2f1d3f" TYPE="crypto_LUKS" PARTUUID="b178ae44-cf49-4dce-b7b5-293c9c0bb9c7"
So I know my swap is on /dev/nvme0n1p7 and my root is /dev/nvme0n1p8.
Now, when I try to add a key for root:
# cryptsetup luksAddKey /dev/nvme0n1p8
Enter any existing passphrase:
Everything works fine, however, for swap:
# cryptsetup luksAddKey /dev/nvme0n1p7
It just exits. A little more info:
# cryptsetup luksAddKey -v --debug /dev/nvme0n1p7
# cryptsetup 2.0.2 processing "cryptsetup luksAddKey -v --debug /dev/nvme0n1p7"
# Running command luksAddKey.
# Locking memory.
# Installing SIGINT/SIGTERM handler.
# Unblocking interruption on signal.
# Allocating context for crypt device /dev/nvme0n1p7.
# Trying to open and read device /dev/nvme0n1p7 with direct-io.
# Initialising device-mapper backend library.
# Trying to load any crypt type from device /dev/nvme0n1p7.
# Crypto backend (gcrypt 1.8.1) initialized in cryptsetup library version 2.0.2.
# Detected kernel Linux 5.0.0-050000-generic x86_64.
# Loading LUKS2 header.
# Opening lock resource file /run/cryptsetup/L_259:7
# Acquiring read lock for device /dev/nvme0n1p7.
# Verifying read lock handle for device /dev/nvme0n1p7.
# Device /dev/nvme0n1p7 READ lock taken.
# Trying to read primary LUKS2 header at offset 0.
# Opening locked device /dev/nvme0n1p7
# Veryfing locked device handle (bdev)
# Trying to read secondary LUKS2 header at offset 8192.
# Opening locked device /dev/nvme0n1p7
# Veryfing locked device handle (bdev)
# Trying to read secondary LUKS2 header at offset 16384.
# Opening locked device /dev/nvme0n1p7
# Veryfing locked device handle (bdev)
# Trying to read secondary LUKS2 header at offset 32768.
# Opening locked device /dev/nvme0n1p7
# Veryfing locked device handle (bdev)
# Trying to read secondary LUKS2 header at offset 65536.
# Opening locked device /dev/nvme0n1p7
# Veryfing locked device handle (bdev)
# Trying to read secondary LUKS2 header at offset 131072.
# Opening locked device /dev/nvme0n1p7
# Veryfing locked device handle (bdev)
# Trying to read secondary LUKS2 header at offset 262144.
# Opening locked device /dev/nvme0n1p7
# Veryfing locked device handle (bdev)
# Trying to read secondary LUKS2 header at offset 524288.
# Opening locked device /dev/nvme0n1p7
# Veryfing locked device handle (bdev)
# Trying to read secondary LUKS2 header at offset 1048576.
# Opening locked device /dev/nvme0n1p7
# Veryfing locked device handle (bdev)
# Trying to read secondary LUKS2 header at offset 2097152.
# Opening locked device /dev/nvme0n1p7
# Veryfing locked device handle (bdev)
# Trying to read secondary LUKS2 header at offset 4194304.
# Opening locked device /dev/nvme0n1p7
# Veryfing locked device handle (bdev)
# LUKS2 header read failed (-22).
# Device /dev/nvme0n1p7 READ lock released.
# Releasing crypt device /dev/nvme0n1p7 context.
# Releasing device-mapper backend.
# Unlocking memory.
Command failed with code -1 (wrong or missing parameters).
Any idea what the problem is?
|
So I figured this out on my own eventually. For anyone who runs into this, make sure that when running cryptsetup status /dev/mapper/<device> that the type is LUKS1 and not PLAIN. It appears the Ubuntu installer defaulted improperly, so standard LUKS commands did not work on the device. Since it was swap I was able to recreate the encryption properly, and now all works smoothly.
| Can't add LUKS key to encrypted swap |
1,593,865,025,000 |
I have a LUKS encrypted SSD and I would like to clear it and install a different Linux distro (Debian -> Ubuntu). I want to decrypt my drive and I tried to use:
cryptsetup luksRemoveKey /dev/DRIVE
It returned:
This is the last keyslot. Device will become unusable after purging this key.
It got me worried so I'm here asking this question. Does this mean that the drive will be completely unusable or will the data simply be erased? If it will become completely unusable, how do I decrypt my drive?
|
The device will still be usable, but the data not accessible (without a header/master key backup)
You will be able to overwrite the data afterwards.
| How to decrypt LUKS encrypted drive |
1,593,865,025,000 |
I use Arch Linux kernel 4.18.12-arch1-1-ARCH (november 2018).
I use a SATA caddy (for a Thinkpad T400) which holds a hard drive from an old laptop. I'd like to decide on combining the contents and extending the logical volumes rootvol and lvhome or keeping the current setup (see below). I only use the ext4 filesystem and both volumes contain data. Although this question seems to be answered here, I'm not sure what to do to prevent data loss.
So currently I boot from a luks encrypted SSD and I have a few symbolic links in $HOME pointing to directories on the lazy mounted hard drive to extend storage and which allows me to use my old $HOME on the hard drive.
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT UUID
sda 8:0 0 223.6G 0 disk
└─sda1 8:1 0 223.6G 0 part 3d17c5b4-a603-4600-9f36-c598a7da783e
└─root 254:0 0 223.6G 0 crypt PRGLfW-Q18M-pPu8-nr6a-tloV-SS4W-kK1ROX
├─matrix-swapvol 254:1 0 2G 0 lvm [SWAP] 38e862ef-e919-4388-810f-63ce187b342c
└─matrix-rootvol 254:2 0 221.6G 0 lvm / c71a8292-c678-4a53-90da-3e4bf78cedbb
sdb 8:16 0 232.9G 0 disk
├─sdb1 8:17 0 512M 0 part 14c635fb-6ee7-45c0-aefd-d3d7440116c0
└─sdb2 8:18 0 232.4G 0 part c36535d9-4098-4939-9ebe-6a2be950f3ea
└─caddy 254:3 0 232.4G 0 crypt kTkSk4-oemR-1fJi-4brz-OXmW-DEZk-rqF2pN
├─vgarch-lvswap 254:4 0 4G 0 lvm a1932471-209e-4d47-85dc-c4ea1ce37de8
├─vgarch-lvroot 254:5 0 15G 0 lvm 67d37f85-c2c0-40e7-88e9-afd4a6c1c561
└─vgarch-lvhome 254:6 0 211.2G 0 lvm dd89d271-776a-426a-826d-9f4d7056fc6a
As can be seen, for whatever reason I decided on using lvm on luks twice. Note that the SSD has no /boot partition: it is decrypted with the help of a libreboot ROM image. During boot, an entry in crypttab for /dev/sdb2's UUID unlocks the harddrive using a key file in /. Then, I use systemd's automount service to mount or unmount it whenever needed:
# /etc/fstab
# /dev/mapper/vgarch-lvhome
UUID=dd89d271-776a-426a-826d-9f4d7056fc6a /mnt/caddy ext4 rw,noatime,data=ordered,noauto,nofail,x-systemd.automount,x-systemd.device-timeout=20,x-systemd.idle-timeout=2min 0 0
I recursively changed the ownership of files in lvhome. As I have no need for lvroot and lvswap I'll be removing them along with /dev/sdb1 which contains /boot.
So how can these be combined? Is that advisable? (because of different uses for SSD and HDD) It is suggested to copy the contents over to the other filesystem first, but doesn't this defeat the purpose of lvm? I thought it would've been easy to grow or shrink the filesystem, but I guess I imagined features from the zfs world.
|
LVM provides logical volumes, which are logical block devices, and makes it easy to grow, shrink, relocate, snapshot, etc. those block devices. You can then use these block devices any way you like... it could be a filesystem, or something else like a virtual HDD for a VM with its own partition table and everything.
LVM does nothing on the filesystem level. So it's up to the filesystem to support handling those grown or shrunk block devices, or to the VM to resize their partition table.
Most filesystems support growing (but sometimes not online, or not past a certain limit), but a few of them don't support shrinking. So although LVM has no qualms about shrinking the block device, you'd have to shrink the filesystem first and for some filesystems, that just isn't possible.
Merging contents of two separate filesystems is usually not supported.
So yes, in some cases, you have to copy files the old-fashioned way. And then abandon/remove the LV those files were on, and use the freed space to expand the LV and grow the filesystem you copied the files to.
So how can these be combined? Is that advisable? (because of different uses for SSD and HDD)
I would not create a block device that is backed half by SSD and half by HDD. I like to keep these separate.
It might make sense in some other situations, e.g. you can do a SSD-HDD-RAID1 where the HDD is set to write-mostly, which means all reads will normally be served by SSD as it's faster. However with dropping SSD prices, that setup is less common as you can just use two SSD for regular RAID1 instead.
| Can one combine logical volumes from different groups without copying the contents over? |
1,593,865,025,000 |
I set for testing a virtual machine with debian
machine is so configured
4 disk in raid10 software
the md0(raid10) in encrypted with luks
on the luks(luksmd0) I have create the vg (debian2-vg)
wich finally has 2 volumes,root and swap.
I configured boot in /(the latest grub2 can boot from raid,lvm and with boot in encrypted /).
So I configured /etc/default/grub like this
GRUB_ENABLE_CRYPTODISK=y
GRUB_CMDLINE_LINUX_DEFAULT="quiet"
GRUB_CMDLINE_LINUX="root=/dev/mapper/debian2--vg-root rd.luks.uuid=21d33599-a220-zddg-1b1f-b2ae82fc0856 rd.luks.name=21d33599-a220-zddg-1b1f-b2ae82fc0856=luksmd0 rd.luks.crypttab=no rd.lvm.lv=debian2-vg/root rd.luks=1 rd.md=1"
the system boot,ask for password of /,I insert the pass and the system boot and finally...initramfs without lvm :(
(the md0 exist,luksmd0 no)
What I miss?
|
Solution found.
I have missed the initramfs part.
When we change from a clear to encrypt environment, we must configure the initramfs.
a)After booting from a usbkey with iso image(slackware iso is ok, debian is ok too)
b)Open the encrypted md
cryptsetup luksOpen /dev/md0 luksmd0
c)Mount the eventual lvm
vgchange -ay
mount /dev/yourvgname/rootlv /mnt
d)mount those dirs as bind from "fakeroot"
for i in dev proc sys
do mount -o bind /$i/ /mnt/$i
done
e)usually boot is separate partition
chroot /mnt /bin/bash
mount /boot
f)Important..we edit the /etc/crypttab,the uuid must be the uuid of encrypted dev in my case is /dev/md0, the uuid is taken from blkid NOT mdadm, another way is to use cryptsetup luksUUID /dev/md0
luksmd0 UUID=21d33599-a220-zddg-1b1f-b2ae82fc0856 none luks
g)We have to edit those two files,in this one we insert the kernel modules(ext4,md,raid10,raid0,etc..)
/etc/initramfs-tools/modules
in this other we simply enable cryptsetup
/etc/cryptsetup-initramfs/conf-hook
h)now edit /etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT="quiet"
GRUB_CMDLINE_LINUX="root=/dev/mapper/debian2--vg-root rd.luks.uuid=21d33599-a220-zddg-1b1f-b2ae82fc0856 rd.luks.name=21d33599-a220-zddg-1b1f-b2ae82fc0856=luksmd0 rd.luks.crypttab=no rd.lvm.lv=debian2-vg/root rd.luks=1 rd.md=1"
i)if needed edit fstab and make changes
vim /etc/fstab
m)now mkinit
update-initramfs -cuv -k all
n)and finally grub
grub-install --recheck /dev/sda
grub-mkconfig -o /boot/grub/grub.cfg
if use efi
mount /boot/efi
grub-install --target=x86_64-efi --efi-directory=/boot/efi --recheck
grub-mkconfig -o /boot/grub/grub.cfg
If all is ok and no error given
umount -a
exit
reboot
| debian and grub with raid10+lvm+luks |
1,593,865,025,000 |
I was installing windows and I accidentally deleted the 2TB LUKS encrypted hard drive where I store my important things.
So after realizing my mistake I immediately rebooted into a live Ubuntu disk and installed Ubuntu on my SEPARATE hard drive just to have a system to work on. I searched around and found out about testdisk. I managed to retrieve the Linux header (I believe its still intact).
Here's what my partition table looks like:
I do not know what to do from here. All the other forums I read about similar problems on were too specific to the person including things I didn't have problems with.
Any hints?
|
Based on the screenshot and our discussion, it looks like testdisk discovered your LUKS header and put it in it's own partition, leaving the rest of the LUKS container in the unallocated space. The LUKS header is stored at the beginning of the partition (or disk when not using partitions); unless you use a detached header.
LUKS format uses a metadata header and 8 key-slot areas that are
being placed at the beginning of the disk. https://gitlab.com/cryptsetup/cryptsetup/wikis/FrequentlyAskedQuestions
So based on this, the solution is to resize sdb1 so that it encompasses the entire disk. There are a few things to keep in mind while resizing:
The starting offset of the sdb1 partition must remain intact. In other words, you must not perform a move operation.
Only resize the partition, not the filesystem.
In reality, you're not resizing the partition, you're instead recreating it in the MBR. It's just that the GParted resizing operation makes it easier because it fills in the partition starting offset for you.
The instructions for resizing a partition with Gparted are here: https://gparted.sourceforge.io/display-doc.php?name=help-manual#gparted-resize-partition
There are a couple of things worth noting about the instructions. First as I mentioned earlier, the partition starting offset must remain intact. Here's the TIP from the instructions:
If you do not want the start of an existing partition to move, then do
not change the free space preceding value.
And there's a TIP about LUKS which doesn't apply because you're not really resizing, instead your recreating the partition as it once was:
A LUKS encrypted partition and the file system within can only be
resized when the encryption mapping is open.
After all this is set and done and your NTFS mounts OK, I recommend running a filesystem check to ensure your content is alright.
| How to recover LUKS encrypted hard drive? |
1,593,865,025,000 |
I'm trying to setup a partition and I'm trying to put the luks header on a USB device so I use the argument --header /path/to/usb-device, however I am still able to decrypt the device without the usb-device being mounted. How to stop cryptsetup from creating the luks header on the encrypted device ?
|
You must have used a wrong command somewhere... cryptsetup does not wantonly create LUKS headers all over the place... it only does what you tell it to and it usually asks for confirmation before doing so.
Example:
# truncate -s 8M luksheader luksdevice
# cryptsetup luksFormat --header luksheader luksdevice
WARNING!
========
This will overwrite data on luksheader irrevocably.
Are you sure? (Type uppercase yes): YES
Enter passphrase:
Verify passphrase:
# file -s luks*
luksdevice: data
luksheader: LUKS encrypted file, ver 1 [aes, xts-plain64, sha256] UUID: …
As you can see, there is no LUKS header on the luksdevice afterwards. If there is one then it was already there before.
You can also just luksFormat the external device/file directly without ever specifying the "encrypted device" (that only really matters on luksOpen).
Simplified example:
# cryptsetup luksFormat luksheader
This is almost equivalent to the more complicated command above, the only difference is in the Payload offset you can see in luksDump. If the header was created as external header in the first place this offset should be 0, otherwise it's something like 4096 (2 MiB) thereabouts.
Any LUKS header works as external header if you so desire, and leaving the Payload offset intact has its advantages. If you ever decide to change your setup you could just put the external header back onto the original device (or vice versa, switch to external header for an existing device).
| How to stop cryptsetup luksFormat from creating the luks header on the encrypted device? |
1,593,865,025,000 |
I'm working on booting a headless server (Fedora 16), entering the passphrase to decrypt the root disk (LUKS) over SSH using dropbear. I've got dropbear all working: I can SSH to the server while it's sitting and waiting for the password. But I can't figure out how to actually pass the password to use.
The crypt script that asks for the password and decrypts the volume uses the plymouth ask-for-password command; is there a way to pass the password into this command from the command line? I've tried writing to the process's stdin, but that didn't work. Is there some other way I can do it?
|
I ended up creating a kind of hacky work around, but it is working for me, and I've been using it for several months now. It basically just replaces the cryptroot-ask shell script with a custom one that waits for you to SSH in, unlock the disk yourself, and then delete a file to indicate that it's gone. Replacement of the cryptroot-ask script is done based on a option passed to the kernel, so you can easily disable it from your GRUB, or your bootloader of choice.
It's all available from: https://bitbucket.org/bmearns/dracut-crypt-wait
| Provide passphrase to plymouth ask-for-password from command line |
1,593,865,025,000 |
I've got a luks volume setup and mounted, and when not in use I suspend it with cryptsetup luksSuspend so it cannot be accessed. But if I forget it's suspended and try to do any kind of file access in the mounted directory, the process just hangs, instead of failing immediately. CTRl-C doesn't work to kill it, and CTRL-Z doesn't work to put it in the background. Even sudo kill -9 doesn't help.
Is there a way to make these commands fail fast when the volume is suspended?
If it's relevant, the volume is setup on a loop device backed by a file.
|
Suspending all accesses until the passphrase is entered again is the whole point of luksSuspend. If you want to ensure that the encrypted device is not in use, call luksClose.
| Prevent file access from hanging when luks volume is suspended |
1,593,865,025,000 |
I had an encrypted ext4 partition on a Samsung T7 1TB USB drive. It was LUKS (I believe this may be called a LUKS container?) The partition was 850GB. It had about 130GB in use. I also had an unencrypted 100GB NTFS partition and a very small amount of unallocated space.
I tried to use KDE Partition Manager to shrink the encrypted partition to 550GB so that I could expand my 100GB NTFS partition by 300GB. I set up both operations and then clicked Apply. The operation began and was in progress for a couple of minutes (but the percentage did not progress). Then it reported that the operation had failed with an error. Stupidly, I did not save the log of the error, my reason being that as far as I could see, no details of, or reason for the error were provided and I made the assumption that no changes had been made. However, I can now no longer mount this encrypted 850GB ext4 partition, although it is visible in Dolphin and in KDE Partition Manager. When plugging the drive in, it correctly identifies it and gives me the password prompt, which is pre-filled with the password I have asked it to remember, so the system recognises the drive (I've tried re-entering this password, in case there is a problem there). The NTFS partition does not seem to be visible at all.
In the log that I did not save from KDE Partition Manager, I believe it also showed progress as the operations were happening, and I believe the first operation was for it to initially shrink the ext4 partition by a small amount - by 0.04 GB, if I remember correctly. So let's say the size was initially 830.08 GB; I believe the first operation was to shrink it to 830.04 GB, which I believe it succeeded in doing. Please do not take these sizes or the 0.04 size to be the truth - it is only what I seem to remember.
The error message in Dolphin is:
An error occurred while accessing '830.0 GiB Encrypted Drive', the
system responded: The requested operation has failed: Error mounting
/dev/dm-1 at /media/wesley/WG-T7-E: wrong fs type, bad option, bad
superblock on /dev/mapper/luks-5c9cfaa5-0576-4b47-8e65-05f7d8b52d39,
missing codepage or helper program, or other error.
In KDE Partition Manager I can see the two partitions and the unallocated space, with sizes and used space correctly reported (or near enough, based on what I know they were. I.e. They are not listed using the new sizes I had chosen).
Properties of the encrypted partition (/dev/sdb1) in KDE Partition Manager show:
Label: WG-T7-E (which is correct)
Mount point: (none found)
Partition type: primary
Status: idle
UUID: 9ffc3bef-5df8-4dd5-b4de-d2ff45aa6322
Partition Label: (none)
Partition UUID: 75E6E7E1-FA4F-0F40-BAB4-85F5F4A5BD30
Size: 830.04 GiB
Available: 84% - 699.21 GiB
Used: 16% - 130.83 GiB
First sector: 2,048
Last sector: 1,740,728,319
Number of sectors: 1,740,726,272
Flags: bios-grub and boot checkboxes shown, but neither checked.
Properties of the unallocated space in KDE Partition Manager show:
Label:
Mount point: (none found)
Partition type: unallocated
Status: idle
Partition Label: (none)
Partition UUID: (none)
Size: 36.00MiB
First sector: 1,740,728,320
Last sector: 1,740,802,047
Number of sectors: 73,728
Properties of the unencrypted partition (/dev/sdb2) in KDE Partition Manager show:
File system: ntfs
Label: WG-T7-U (which is correct)
Mount point: /media/wesley/WG-T7-U
Partition type: primary
Status: idle
UUID: 05DBF9124869C198
Partition Label: (none)
Partition UUID: 8CC612F8-30FA-6449-8FA2-754C82E8B0C3
Size: 101.43 GiB
Available: 99% - 101.37 GiB
Used: 1% - 67.61 MiB
First sector: 1,740,802,048
Last sector: 1,953,523,711
Number of sectors: 212,721,664
Flags: bios-grub and boot checkboxes shown, but neither checked.
dmesg after plugging in USB drive and entering password:
[ 6049.158336] usb 2-4: new SuperSpeed USB device number 8 using xhci_hcd
[ 6049.171380] usb 2-4: New USB device found, idVendor=04e8, idProduct=61fb, bcdDevice= 1.00
[ 6049.171394] usb 2-4: New USB device strings: Mfr=2, Product=3, SerialNumber=1
[ 6049.171400] usb 2-4: Product: PSSD T7 Shield
[ 6049.171405] usb 2-4: Manufacturer: Samsung
[ 6049.171409] usb 2-4: SerialNumber: S6YJNS0TA00012H
[ 6049.180592] scsi host2: uas
[ 6049.181476] scsi 2:0:0:0: Direct-Access Samsung PSSD T7 Shield 0 PQ: 0 ANSI: 6
[ 6049.182964] sd 2:0:0:0: Attached scsi generic sg2 type 0
[ 6049.183565] sd 2:0:0:0: [sdb] 1953525168 512-byte logical blocks: (1.00 TB/932 GiB)
[ 6049.183710] sd 2:0:0:0: [sdb] Write Protect is off
[ 6049.183717] sd 2:0:0:0: [sdb] Mode Sense: 43 00 00 00
[ 6049.183951] sd 2:0:0:0: [sdb] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[ 6049.184282] sd 2:0:0:0: [sdb] Optimal transfer size 33553920 bytes
[ 6049.207124] sdb: sdb1 sdb2
[ 6049.208449] sd 2:0:0:0: [sdb] Attached SCSI disk
[ 6049.430150] audit: type=1107 audit(1708641903.652:169): pid=1274 uid=102 auid=4294967295 ses=4294967295 subj=unconfined msg='apparmor="DENIED" operation="dbus_signal" bus="system" path="/org/freedesktop/login1" interface="org.freedesktop.DBus.Properties" member="PropertiesChanged" name=":1.2" mask="receive" pid=2912 label="snap.firefox.firefox" peer_pid=1318 peer_label="unconfined"
exe="/usr/bin/dbus-daemon" sauid=102 hostname=? addr=? terminal=?'
[ 6049.430683] ntfs3: Unknown parameter 'windows_names'
[ 6049.494120] audit: type=1107 audit(1708641903.716:170): pid=1274 uid=102 auid=4294967295 ses=4294967295 subj=unconfined msg='apparmor="DENIED" operation="dbus_signal" bus="system" path="/org/freedesktop/login1" interface="org.freedesktop.DBus.Properties" member="PropertiesChanged" name=":1.2" mask="receive" pid=2912 label="snap.firefox.firefox" peer_pid=1318 peer_label="unconfined"
exe="/usr/bin/dbus-daemon" sauid=102 hostname=? addr=? terminal=?'
[ 6052.079215] audit: type=1107 audit(1708641906.301:171): pid=1274 uid=102 auid=4294967295 ses=4294967295 subj=unconfined msg='apparmor="DENIED" operation="dbus_signal" bus="system" path="/org/freedesktop/login1" interface="org.freedesktop.DBus.Properties" member="PropertiesChanged" name=":1.2" mask="receive" pid=2912 label="snap.firefox.firefox" peer_pid=1318 peer_label="unconfined"
exe="/usr/bin/dbus-daemon" sauid=102 hostname=? addr=? terminal=?'
[ 6054.523583] audit: type=1107 audit(1708641908.745:172): pid=1274 uid=102 auid=4294967295 ses=4294967295 subj=unconfined msg='apparmor="DENIED" operation="dbus_signal" bus="system" path="/org/freedesktop/login1" interface="org.freedesktop.DBus.Properties" member="PropertiesChanged" name=":1.2" mask="receive" pid=2912 label="snap.firefox.firefox" peer_pid=1318 peer_label="unconfined"
exe="/usr/bin/dbus-daemon" sauid=102 hostname=? addr=? terminal=?'
[ 6054.598701] audit: type=1107 audit(1708641908.820:173): pid=1274 uid=102 auid=4294967295 ses=4294967295 subj=unconfined msg='apparmor="DENIED" operation="dbus_signal" bus="system" path="/org/freedesktop/login1" interface="org.freedesktop.DBus.Properties" member="PropertiesChanged" name=":1.2" mask="receive" pid=2912 label="snap.firefox.firefox" peer_pid=1318 peer_label="unconfined"
exe="/usr/bin/dbus-daemon" sauid=102 hostname=? addr=? terminal=?'
[ 6054.599943] EXT4-fs (dm-1): bad geometry: block count 217599488 exceeds size of device (217590272 blocks)
[ 6054.600795] audit: type=1107 audit(1708641908.822:174): pid=1274 uid=102 auid=4294967295 ses=4294967295 subj=unconfined msg='apparmor="DENIED" operation="dbus_signal" bus="system" path="/org/freedesktop/login1" interface="org.freedesktop.DBus.Properties" member="PropertiesChanged" name=":1.2" mask="receive" pid=2912 label="snap.firefox.firefox" peer_pid=1318 peer_label="unconfined"
exe="/usr/bin/dbus-daemon" sauid=102 hostname=? addr=? terminal=?'
[ 6054.798116] audit: type=1107 audit(1708641909.020:175): pid=1274 uid=102 auid=4294967295 ses=4294967295 subj=unconfined msg='apparmor="DENIED" operation="dbus_signal" bus="system" path="/org/freedesktop/login1" interface="org.freedesktop.DBus.Properties" member="PropertiesChanged" name=":1.2" mask="receive" pid=2912 label="snap.firefox.firefox" peer_pid=1318 peer_label="unconfined"
exe="/usr/bin/dbus-daemon" sauid=102 hostname=? addr=? terminal=?'
[ 6054.804803] EXT4-fs (dm-1): bad geometry: block count 217599488 exceeds size of device (217590272 blocks)
[ 6054.809500] audit: type=1107 audit(1708641909.031:176): pid=1274 uid=102 auid=4294967295 ses=4294967295 subj=unconfined msg='apparmor="DENIED" operation="dbus_signal" bus="system" path="/org/freedesktop/login1" interface="org.freedesktop.DBus.Properties" member="PropertiesChanged" name=":1.2" mask="receive" pid=2912 label="snap.firefox.firefox" peer_pid=1318 peer_label="unconfined"
exe="/usr/bin/dbus-daemon" sauid=102 hostname=? addr=? terminal=?'
Financial reward offered to the person, or split between the persons, who can help me successfully recover this. Thank you.
|
To recap, after resizing partitions, you got this mount error:
wrong fs type, bad option, bad superblock on /dev/mapper/luks-5c9cfaa5-0576-4b47-8e65-05f7d8b52d39, missing codepage or helper program, or other error.
Getting this far already means there is no issue with the LUKS header itself.
According to dmesg, the real error message is:
EXT4-fs (dm-1): bad geometry: block count 217599488 exceeds size of device (217590272 blocks)
This seems to be a standard case of shrinking partition without shrinking the filesystem first and the discrepancy is just a few thousand blocks of data (9216 4K-blocks = 73728 512-byte sectors).
And it seems you have exactly the necessary unallocated space in your partition table.
According to your partition manager outputs, in parted it should roughly look like this.
# parted /dev/sdb unit s print free
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
34s 2047s 2014s Free Space
1 2048s 1740728319s 1740726272s luks
1740728320s 1740802047s 73728s Free Space
2 1740802048s 1953523711s 212721664s ntfs
Partition numbers, names, flags may be different - Start End Size should match. If all assumptions are correct then the fix is to reclaim free space behind partition 1.
Make sure the LUKS container is closed first and the drive unmounted or re-reading partition table might fail (alternatively, reboot).
# cryptsetup close luks-5c9cfaa5-0576-4b47-8e65-05f7d8b52d39
# umount /dev/sdb*
Since there is unallocated space in the partition table, you can reclaim it using parted's resizepart command.
# parted /dev/sdb resizepart 1 1740802047s
This will only alter the partition table without altering any data.
With any luck, the filesystem will just work normally afterwards.
| How do I rescue an encrypted LUKS partition after failed shrink |
1,593,865,025,000 |
After a recent update (not sure if that was the first including a new kernel 6.1) my ubuntu linux laptop cannot boot anymore
the error is
Volume group “ubuntu-vg” not found
Cannot process volume group ubuntu vg
IO error while decrypting keyslot.
Keyslot open failed.
Device /dev/nvme0n1p3 does not exist or access is denied
Please unlock disk nvme0n1p3_crypt_
but then the usual decrypting code does not work
while in initram shell I noticed there were
no device /dev/nvme* nor /dev/mappe* for my internal ssd
I managed to boot the laptop with a ubuntu live usb stick
and manually decrypted and mounted my ssd partitions and my data were all there
so I rebooted then I made the grub boot menu to appear again and I selected the previous kernel 5.17, and the system managed to boot normally
Now I would like to fix the new kernel in a stable way
here are some info on my laptop:
OS: Ubuntu 22.04.3 LTS x86_64
Host: XPS 15 9560
Kernel: 5.17.0-1035-oem
my boot partition content is
$ ll /boot/ | grep -E "initrd|vmlinuz"
lrwxrwxrwx 1 root root 25 2023-10-05 20:38:05 initrd.img -> initrd.img-6.1.0-1023-oem
-rw-r--r-- 1 root root 112483877 2023-10-16 03:12:30 initrd.img-5.15.0-86-generic
-rw-r--r-- 1 root root 117815613 2023-10-16 03:12:18 initrd.img-5.17.0-1035-oem
-rw-r--r-- 1 root root 130800464 2023-10-16 03:12:06 initrd.img-6.1.0-1023-oem
lrwxrwxrwx 1 root root 28 2023-10-05 20:38:05 initrd.img.old -> initrd.img-5.15.0-86-generic
lrwxrwxrwx 1 root root 22 2023-10-05 20:38:05 vmlinuz -> vmlinuz-6.1.0-1023-oem
-rw------- 1 root root 11624584 2023-09-20 10:09:11 vmlinuz-5.15.0-86-generic
-rw------- 1 root root 11275528 2023-07-12 11:49:08 vmlinuz-5.17.0-1035-oem
-rw------- 1 root root 12521608 2023-09-15 14:50:36 vmlinuz-6.1.0-1023-oem
lrwxrwxrwx 1 root root 25 2023-10-05 20:38:05 vmlinuz.old -> vmlinuz-5.15.0-86-generic
$
the lsblk for nvme
$ lsblk | tail -n 7
nvme0n1 259:0 0 476,9G 0 disk
├─nvme0n1p1 259:1 0 512M 0 part /boot/efi
├─nvme0n1p2 259:2 0 732M 0 part /boot
└─nvme0n1p3 259:3 0 475,7G 0 part
└─nvme0n1p3_crypt 253:0 0 475,7G 0 crypt
├─ubuntu--vg-root 253:1 0 474,8G 0 lvm /
└─ubuntu--vg-swap_1 253:2 0 980M 0 lvm [SWAP]
$
the fstab
$ cat /etc/fstab | grep -E "mount point|^/"
# <file system> <mount point> <type> <options> <dump> <pass>
/dev/mapper/ubuntu--vg-root / ext4 errors=remount-ro 0 1
/dev/mapper/ubuntu--vg-swap_1 none swap sw 0 0
/swapfile swap swap defaults 0 0
$
I have read a post of similar issues on another XPS laptop - i.e.:
$ lspci | grep Unassigned
03:00.0 Unassigned class [ff00]: Realtek Semiconductor Co., Ltd. RTS525A PCI Express Card Reader (rev 01)
$
Should/could I also blacklist the drivers
blacklist rtsx_pci
blacklist rtsx_pci_sdmmc
in /etc/modprobe.d/blacklist_rtsx.conf and rebuild the initramfs?
I am asking since I am quite worried to brick the system
Apologies if I used terminology incorrectly or asked dumb questions.
|
Unfortunately adding nve and lvm to /etc/initramfs-tools/modules ,
updating initramfs and rebooting
was not effective.
Thus I reverted that change and then I tried adding
blacklist rtsx_pci
blacklist rtsx_pci_sdmmc
to (a new) file
/etc/modprobe.d/blacklist_rtsx.conf
and rebooting
and the problem was solved
(then I have read that a patch for this has been already been submitted
to the kernel maintainers, so chances are this issue
may soon become a thing of the past)
| volume group not found on linux laptop after update |
1,680,028,621,000 |
As I'm new to UNIX this might be a stupid question but here we go.
I want to install manjaro next to my win11 which I have bitlocker encrypted. I need to keep the Win11 installation as is.
I reduced the win partition to free up space for my manjaro and I now want to have my linux to be in two partitions, /root and /home. Both should be encrypted using LUKS but I don't want them to have two separate passwords so for what I understood I'd need an encrypted LVM containing the root and home partition which stay ext4 right?
So basically what I want is
- SSD
-- UEFI
-- win reserved stuff
-- bitlocker win11
-- ?LVM LUKS encrypted?
--- /root
--- /home
-- shared ntfs (which in the end I'd like to encrypt with truecrypt to be accessible from win11 and manjaro)
but I'm not sure if I'm on the right track here. Any advice?
edit: as the laptop has 16GB RAM I suppose I won't need swap
|
As I'm new to UNIX
In that case you should probably pick a distribution with a GUI installer that can do the partitioning with encryption automatically. But if you want Manjaro, go ahead, but it will be more complicated.
Edit: Actually, Calamares supports LUKS encryption so if you don't have another reason to do this manually, I would strongly recommend using the automatic partitioning with disk encryption.
in two partitions, /root and /home
The correct mount point for the root filesystem is /, /root is home directory for the root user.
Both should be encrypted using LUKS but I don't want them to have two separate passwords
If you want to use partitions you can create two separate LUKS partitions and use the same password, during the boot process you'll need to enter it only once.
so for what I understood I'd need an encrypted LVM containing the root and home partition which stay ext4 right?
LVM is a layered storage. You'll need to create single partition with fdisk or parted, create LUKS on it with cryptsetup luksFormat /dev/sdxY and cryptsetup luksOpen <luks name> (same as with normal partition), then create LVM volume group on top of the LUKS device with vgcreate <vg name> /dev/mapper/<luks name> and then create two logical volumes with lvcreate -n <name> -L <size> <vg name>. RHEL documentation is a good source for LVM and ArchWiki also has a nice page with disk encryption description.
Don't forget that with LVM, separate /boot partition is usually recommended. /boot can be encrypted but requires special setup.
shared ntfs (which in the end I'd like to encrypt with truecrypt to be accessible from win11 and manjaro)
BitLocker is also supported in Linux (you'll need cryptsetup 2.3.0 or newer and you'll need to create a password protected BitLocker volume or use recovery passphrase, TPM is not supported) so you don't need TrueCrypt if you don't want it for other reasons.
| Luks encrypted Manjaro with Bitlocker encrypted Win11 dualboot |
1,680,028,621,000 |
Before: SATA internal SSD with a LUKS encrypted ext4 partition (Debian installation) + a small unencrypted boot partition with kernel, initrd and GRUB configuration files
After: that same disk is now externally attached with a USB-to-SATA adapter
Now GRUB fails to boot it, but both GRUB and the Debian kernel recognize the disk (I see the correct size and partitions). Also after loading the kernel it asks for the LUKS password, and it recognizes it (if entered correctly)
I've tried providing the kernel and initrd files from the GRUB command line, and also loading the old grub.cfg file with the GRUB 'configfile' command.
This was the GRUB section that worked with the former setup:
menuentry 'Debian GNU/Linux' --class debian --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-8b6b854f-d92a-439d-a0e3-315d39bb0802' {
load_video
insmod gzio
if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
insmod part_msdos
insmod ext2
set root='hd0,msdos3'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos3 --hint-efi=hd0,msdos3 --hint-baremetal=ahci0,msdos3 a597f222-87d2-4e19-8965-aa0eff0bceea
else
search --no-floppy --fs-uuid --set=root a597f222-87d2-4e19-8965-aa0eff0bceea
fi
echo 'Loading Linux 4.9.0-11-amd64 ...'
linux /vmlinuz-4.9.0-11-amd64 root=UUID=8b6b854f-d92a-439d-a0e3-315d39bb0802 ro quiet
echo 'Loading initial ramdisk ...'
initrd /initrd.img-4.9.0-11-amd64
And this are the various error screens (I can't remember what screen corresponds to what I was trying)
Is it even possible to boot the Debian install with this new setup?
|
I see that it correctly sets up the encrypted volume sdb2_crypt, so I tried this and it worked:
linux /vmlinuz-4.9.0-11-amd64 root=/dev/mapper/sdb2_crypt ro
initrd /initrd.img-4.9.0-11-amd64
It booted into a recovery environment as it was not recognizing some filesystems in /etc/fstab, after commenting them out, saving and rebooting it boots into the LXDE login screen.
| Booting LUKS Linux installation from external USB disk |
1,680,028,621,000 |
I can't login anymore into my encrypted disk. After writing the password:
error: no such cryptodisk found.
error: disk ‘cryptouuid/HEXstring’ not found.
Entering rescue mode…
intuitively that string is the identifier of the disk that I'm trying to decrypt and log into.
So I live boot from USB and go into file manager, mount the encrypted disk and I can access it, since I know the correct password.
My resources are a live USB and every file I want from my encrypted disk, since I actually can enter into the partition.
History of what I've done before rebooting and finding this problem:
masked the swap unit
deleted the partition where the swap unit was
How can I fix the system not recognising my cryptodisk during boot?
|
I tried to do something alone (yes, I'm the answerer to my own question. I was panicking) and I did this in order to re-access my account:
after I ran the live USB, I mounted my linux partition so that I could access to its files. I personally did it from the file manager but you can use the mount function.
with the sudo command I opened /etc/default/grub with a text editor
uncommented the voice "GRUB_ENABLE_CRYPTODISK=y"
It will allow the system to boot from an encrypted disk, where the grub file configuration is located.
I'm not an expert neither in Linux systems neither in programming, so I don't know if this was a good method. Anyways I thought about this because I found, in /boot/grub/grub.cfg :
`if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root
--hint='cryptouuid/HEX_string_of_my_encrypted_disk'
else
search --no-floppy --fs-uuid --set=root HEX_string_of_the_swap_partition
So I thought it was selecting, as the bootloader disk, the swap partition of my cryptodisk instead of the actual cryptodisk and that's why I searched for the option above written and un-commented it.
Right now the system runs ok, but at the beginning a message has been sent through the screen, which was something like:
hibernation device not found
or something very similar. Which I guess it's just expected since I have no swap memory anymore.
So, this is ONE solution, again, not sure if the best.
| Can't boot from encrypted disk after deleting swap-memory partition [issue] |
1,680,028,621,000 |
The other day I tried to setup a Full disk encryption on a test system (ArchLinux) within virtualbox. (I want to use this kind of a setup on my main machine so I wanted to test it out first)
I created two harddisks (sda, sdb2)
sda has an efi, boot, root and home partition with the root and home partition encrypted.
The root partition gets decrypted from grub with a keyfile sitting on a USB drive. The home partition is decrypted by a keyfile (/root/keyfile). So far everything works perfekt
Than I created two partitions on sdb each of them also encrypted, using the same key as for the home partition.
When I try to decrypt them at boottime using crypttab with the same settings as for the home partition of course changing the UUID and name I get an error "Failed to start Cryptography Setup for ..." for the home- and both of the partitions on sdb.
However if I remove one of the two sdb partitons from the crypttab file (does not matter which) everything works fine again.
Seems having more than one partition of one device does mess things up
my crypttab looks sth like that:
#home partition
crypthome UUID=xxxxxxxxx-xxx-xx /root/keyfile luks
#sdb partition1
cryptb1 UUID=yyyyyyyyy-yyy-yy /root/keyfile luks
#sdb partition2
cryptb2 UUID=zzzzzzzzz-zzz-zz /root/keyfile luks
As said commenting out one of the sdb entries lets the system start without any error
Anyone encountered the same problem or has any idea what to do?
|
After some digging through the bootlog I found an error mentioning that the cryptprocess was out of memory. After increasing the system memory of the virtual machine now everything works as expected.
Maybe this helps someone encountering a similar problem, since I did not read anything about minimum memory requirements for de decryption process
| Encrypt multiple partitions with luks cryptsetup |
1,680,028,621,000 |
Can somebody with more LUKS LVM experience than me tell me what the correct device name is to use in this context.
I'm trying to follow some instructions about using clevis and tang in CentOS. The instructions are pretty simple, yet after installing the tang server, I run into problems right away on the clevis portion.
> clevis bind luks -d /dev/mapper/luks-cee2a805-188f-44b6-b577-879243c0eb6c tang {"url":"http://official.server.company.com"}
Device /dev/mapper/luks-cee2a805-188f-44b6-b577-879243c0eb6c is not a valid LUKS device.
This is a whole-volume LUKS volume on the main LVM partition and I would have thought the above name is right. Here's the output of lsblk
> lsblk -p
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
/dev/sda 8:0 0 50G 0 disk
├─/dev/sda1 8:1 0 1G 0 part /boot
├─/dev/sda2 8:2 0 2G 0 part [SWAP]
└─/dev/sda3 8:3 0 47G 0 part
└─/dev/mapper/vg_root-lv_root 253:0 0 47G 0 lvm
└─/dev/mapper/luks-cee2a805-188f-44b6-b577-879243c0eb6c 253:1 0 47G 0 crypt /
/dev/sr0 11:0 1 1024M 0 rom
But I can't seem to find the right device to pass to clevis bind or any other LUKS command:
> luksmeta show -d /dev/mapper/luks-cee2a805-188f-44b6-b577-879243c0eb6c
Unable to read LUKSv1 header (/dev/mapper/luks-cee2a805-188f-44b6-b577-879243c0eb6c): Invalid argument
> cryptsetup luksDump /dev/mapper/luks-cee2a805-188f-44b6-b577-879243c0eb6c
Device /dev/mapper/luks-cee2a805-188f-44b6-b577-879243c0eb6c is not a valid LUKS device.
I've also tried, for completeness not necessarily because I thought it made any sense /dev/sda, /dev/sda3.
I'm stuck, any tips greatly appreciated.
p.s. I know my reputation is a mere 101 on Unix&Linux but I'm a 2000+ on StackOverflow, so I do generall know what I'm doing.
https://rhelblog.redhat.com/2018/04/13/an-easier-way-to-manage-disk-decryption-at-boot-with-red-hat-enterprise-linux-7-5-using-nbde/
https://blog.delouw.ch/2017/10/01/leveraging-network-bound-disk-encryption-at-enterprise-scale/
|
From RedHat blog link you posted, it appears clevis wants the encrypted block device (not the decrypted one). In your lsblk output, that is /dev/mapper/vg_root-lv_root. This sort of makes sense; the decrypted one doesn't exist until after the keys are supplied.
You can confirm that's indeed the right device a few ways:
cryptsetup luksDump /dev/mapper/vg_root-lv_root ought to work
dmsetup table luks-cee2a805-188f-44b6-b577-879243c0eb6c will show the device-mapper mapping table. The second-to-last field should be the major and minor numbers separated by a colon (e.g., yours will probably show 253:0). You can use stat or even ls -l to see the major/minor numbers of devices to see what matches.
| Device name to use in luks commands for LVM LUKS |
1,680,028,621,000 |
Is it possible to encrypt a LMV partition after having installed an OS?
I just finally managed to get LVM but I couldn't figure out how to get it encrypted. The installer didn't seem to provide for that to happen.
To be more specific, I installed Lubuntu 18.10 which utilizes the Calamares installer.
I've installed Lubuntu successfully but it's not encrypted.
Is it possible to use LUKS to do something at this point or is there an alternative?
EDIT:
I am aiming for FDE. I want all partitions encrypted (/, home, swap).
|
@ThatRandomGuy,
You have already done with installation so / file encryption is not possible.
During installation you need to tick the check box "Encrypt the new Lubuntu installation for security" as shown in below figure.
In case if you need to to encrypt home it possible by following below article.
Creating Encrypted filesystem in RedHat Enterprise Linux 7 and Variants
The guide is for RHEL based operating system but steps are exactly similar and still this works for Ubuntu based operating system as well.
| How to encrypt LVM partition with LUKS after installation? |
1,535,994,138,000 |
I have the second half of my hard drive encrypted. Now I want to encrypt the first half as well. Being the second partition I can't extend the LUKS partition. Can I add the first partition to the existing LUKS or do I have to set another LUKS for this one partition?
|
You'll need to create another LUKS container.
Your LVM volume group can span both LUKS containers. You'd simply create an LVM physical volume in the LUKS container and add it to the LVM volume group. However, that means both LUKS containers would need to be unlocked before you can bring up the LVM volume group.
| Add new partition to LUKS+LVM |
1,535,994,138,000 |
I have the following (lsblk output):
And I want to increase the size of the boot partition (sdb2) but I'm not able to put unallocated space before the LVM partition (sb3), is there a way to do this? I found ways to increase the size of the LVM partition itself but nothing regarding putting that unallocated space before the partition so that it can be used to increase the size of another.
|
Nope you can't move unallocated space around because the partition table reflects the location of sectors on the disk. Each sector has an ID from 1 to {a lot} and they are allocated in continuous blocks to partitions. Once allocated you can't easily move them around.
Is you sdb4 in use or not? If not one thing you can do is to create a new partition /boot partition from sdb4 and move the files here. It will require updating the boot loader, probably grub2, but it's reasonably easy to do.
However 238MB should be enough for /boot - if you're getting out of space warnings you may want to delete old, unused kernel packages. It is usually enough to keep only the running one and the one before in case you need to roll back.
How to delete them depends on your distribution, you apparently use Fedora, so here I found a link that should help:
https://www.if-not-true-then-false.com/2012/delete-remove-old-kernels-on-fedora-centos-red-hat-rhel/
| How to increase the size of a partition that sits before an encrypted one? |
1,535,994,138,000 |
If I am shrinking a partition containing a LUKS device+, can I verify that I didn't over-shrink the partition without opening the device and verifying the data at a higher layer in the stack?
Or, in other words, is there a way to verify / check a LUKS container's size, and whether it is intact?
I'm after something like LVM's pvck, which doesn't assume anything about the container's contents.
+ A LUKS device is one where the container (header) starts at sector 0.
|
This is not possible as the LUKS / dm-crypt / cryptsetup FAQ page says:
2.15 Can I resize a dm-crypt or LUKS partition?
Yes, you can, as neither dm-crypt nor LUKS stores partition size.
If no size information is stored, then it's not possible to check if the entirety is accessible.
I've asked what gets resized if no size information is stored here.
| Check LUKS container has not been truncated |
1,535,994,138,000 |
I suspect there's a bug in Ubuntu's default whole disk encryption setup.
Here's what happens, repeatably:
I make a fresh install, Ubuntu 15.10 with whole disk encryption, overwriting the whole disk
It boots and seems to work just fine
A few reboots later, programs start crashing. "Ubuntu has experienced an internal error", Firefox will crash immediately on startup, etc.
Finally, after an additional reboot or two, it will boot to busybox. Running fsck finds and fixes tons of errors.
Go to step 2
Not cool.
Conclusions so far:
I'm quite sure it's not disk failure. I reproduced this from scratch with two different drives. In both cases, the SMART data looks healthy, and running self tests thru gnome-disks comes up clean.
Beyond that... I have no idea.
Details:
System76 Galago Ultrapro
64-bit desktop Ubuntu 15.10
Kernel 4.2.0-18-generic
Default Ubuntu whole-disk encryption setup: ext2 boot partition, dm-crypt+LUKS+ext4 main partition.
I ran into this first with a 256GB Samsung 840 EVO, then reproduced it on a 512GB Samsung 830. I got the same problems in both cases: works fine for a while, but becomes unusable after a few reboots. Installing Ubuntu without disk encryption works.
Has this happened to anyone else?
I've checked the syslog and couldn't find anything incriminating.
Does anyone know how I could figure out what's going on here?
|
There have been constant reports of corruption bugs with ext4 file systems, with varying setups. Lots of people complaining in forums. The bug seems to affect more people with RAID configurations.
However, they are supposedly fixed in 4.0.3.
"4.0.3 includes a fix for a critical ext4 bug that can result in major
data loss."
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=785672
There are other ext4 bugs, including bugs fixed as of the 30th of November [of 2015].
https://lists.ubuntu.com/archives/foundations-bugs/2015-November/259035.html
There is also here a very interesting article talking about configuration options in ext4, and possible corruption with it with power failures.
https://www.pointsoftware.ch/2014/02/05/linux-filesystems-part-4-ext4-vs-ext3-and-why-delayed-allocation-is-bad/
I would test the setup with other filesystem other than ext4.
| Massive disk corruption on Ubuntu 15.10 with dm-crypt + LUKS full disk encryption? |
1,535,994,138,000 |
I have a dual-boot(xubuntu/#!) setup LVM with dm-crypt+luks as follows
/dev/sda1 = /boot (xubuntu)
/dev/sda2 = /boot (#!)
/dev/sda3 = encrypted LVM
/dev/mapper/volgroup-xroot = / (xubuntu)
/dev/mapper/volgroup-yroot = / (#!)
/dev/mapper/volgroup-home = /home (/home/xubuntu & /home/crunchbang)
/dev/mapper/volgroup-swap = swap
I have Grub installed only from xubuntu on the MBR
I was able to set this up successfully get this working initially. Recently, upon installing Libre Office on the xubuntu OS, I unwittingly let the network manager get uninstalled. I attempted to reinstall it by booting into crunchbang and then chroot-ing into the xubuntu file system. It worked but it messed the crunchbang boot process up somehow.
First Grub dropped the crunchbang OS listing. I updated it and it found it again. Now, when I attempt to boot crunchbang it seems to process everything fine up to requesting a passphrase. After entering my passphrase, it quickly fails and reports the message "cryptsetup: lvm fs found but no lvm configured"
and reprompts for the passphrase again.
looking into it, I found this error message comes from the /usr/share/initramfs-tools/scripts/local-top/cryptroot script and occurs when
if [ "$FSTYPE" = "LVM_member" ] || [ "$FSTYPE" = "LVM2_member" ]; then
if [ -z "$cryptlvm" ]; then
message "cryptsetup: lvm fs found but no lvm configured"
return 1
$FSTYPE is just the type of the dmname, the decrypted lvm container which is set as $cryptroot and then $crypttarget - apparently successfully in order to reach this error.
It seems like the script is checking for $cryptlvm to be an empty string and if so fails with my error. I have found only one reference to $cryptlvm, setting cryptlvm="" earlier in the cryptroot script, and no reference to it otherwise.
I have been checking things against my xubuntu install and all relevant files so far are equivalent, including setting cryptlvm="" at the beginning of the script.
And this is where I'm stuck.
Can someone point me in the right direction here?
|
You make this message disappear by setting your GRUB_CMDLINE_LINUX_DEFAULT variable in /etc/default/grub with crypt_opts=<whatever#1>,lvm=<whatever#2>
The script in /usr/share you mention set the variable cryptlvm with .
For further reference, my own GRUB_CMDLINE_LINUX_DEFAULT contains:
crypt_opts=target=system,source=/dev/sda5,lvm=/dev/mapper/system
system is here my encrypted lvm partition.
| boot fails with "cryptsetup: lvm fs found but no lvm configured" [dual boot(2xlinux LVM, dm-crypt+luks)] |
1,535,994,138,000 |
I have FC18 on a LUKS/dm-crypt encrypted hard disk. I'd like to upgrade the system via a FC20 dvd.
I looked around a bit and it seems that upgrading the system via the installation procedure from the DVD would require some specific steps to ensure the correct recognition of the disk's contents.
The alternative would be, perhaps, to update yum repository and upgrade from there, but the first option seems "cleaner", and it has been so in my limited experience.
It's still not clear to me whether trying to make the DVD installer recognize the encrypted partition is an easy and reliable process.
Should I back up /home and perform a clean install?
|
Starting with Fedora upgrade process has moved from the installer to FedUp, which you run from the system to be upgraded. (You can use the RPMs on the DVD media you have, although fetching them from the network is the recommended route.) Further instructions on the FedUp page.
Make sure you check a few F18→F20 gotchas on the common bugs page — make sure you have the latest FedUp, and either disable GPG checking (not recommended although okay if you verify the RPMs on your DVD first) or make sure you have the updated keys available.
This should handle encrypted volumes transparently with no fuss (except for an obscure case where you have upgraded from Grub 1 to Grub 2 by hand — if that is you, don't miss this fix.)
(Disclaimer: I work on Fedora, but not on the installer or FedUp specifically.)
| Upgrading Linux (Fedora) with LUKS encrypted volume |
1,535,994,138,000 |
Currently I use rsnapshot to backup data from one encrypted ext4 drive to another. My system opens a LUKS container on each drive and runs rsnapshot according to an hourly schedule. I'm intrigued by btrfs's built in snapshot feature, and I'm curious if it can be used in place of my current setup (assuming of course I reformat the drives). Are there any obvious issues I'm failing to realize? Can my current setup be improved by using btrfs, is it faster for example?
|
btrfs is a copy-on-write filesystem with many features (like error detection and correction, transparent compression, snapshots, sub-volumes, etc) that make it slower than a traditional filesystem.
However, btrfs snapshots are very light-weight and take almost no time to make. And using btrfs send ... | btrfs receive (or btrfs send | ssh remote_host btrfs receive) is much faster than using rsync or rsnapshot or any other method that needs to compare the files on sender and receiver.
Those file comparisons aren't necessary when sending a snapshot because the exact differences between one snapshot and another are already known (they're inherent to the snapshot) so the changed blocks can just be sent to the receiver as a continuous binary stream - no comparisons of file timestamps or contents is needed.
In short, the overall filesystem performance will be slower, but backups will be much faster.
I use zfs instead of btrfs, which has a very similar snapshot & send/receive mechanism. When I switched from rsync to zfs send for my backups, it reduced the run-time for an incremental backup down from several hours to several minutes.
I backup all machines on my local network to a "backup" pool on my main file-server. It had gotten to the point that the rsync backups weren't completing before cron triggered the next day's backup. With multiple simultaneous backups running at all times, the performance of the server was abysmal, and it required constant manual intervention (mostly killing rsync processes) to bring it back to a usable state. The switch to zfs send was the difference between having a usable file-server and an unusable one. Now I rarely ever need to even think about it, it just works. At most every year or two I clear out ancient snapshots on the backup pool (I aggressively auto-expire snapshots on the hosts being backed up, but much less aggressively on the backup pool), which can take a long time if I've let the backup pool retain a million or two snapshots.
As for whether it can replace your current setup or not, I recommend creating a btrfs testing VM with two btrfs pools and experiment with making snapshots and sending them from one pool to the other. Or multiple testing VMs so you can experiment with btrfs sending a snapshot stream over ssh.
I would not recommend switching until you are very familiar and comfortable with how btrfs snapshots and btrfs send/receive work.
In fact, make some ZFS VMs too so you can get a feel for the differences.
VMs are great for trying out new stuff before you decide if you want to use it. Reading docs is essential, but there's nothing like getting your hands dirty if you really want to understand how something works.
BTW, transparent compression can offset much of the performance penalty between using a fs like btrfs or ZFS and a more traditional fs like ext4 or xfs, depending on your workload.
If fs performance is the only or most important thing for you, then use xfs - it's the clear winner, by far.
If you need/want snapshots, snapshot send/recv, compression, ECC, sub-volumes etc then use either ZFS or btrfs.
IMO, the only real reason to use btrfs instead of ZFS is that btrfs is in the mainline linux kernel while ZFS probably never will be due to the license conflict between CDDL and GPL. For ZFS, you have to compile and install the kernel module...which is trivially easy with a zfs-dkms module.
If you're using Ubuntu then you can use ZFS out of the box, they don't think the license issue is that big a deal - IMO they're wrong about that, but it's unlikely they'll be sued by Oracle.
Also, one thing that may be of interest to you since you use LUKS is that ZFS can optionally encrypt any dataset ("sub-volume" in btrfs terminology. Kind of like a combined LV + filesystem in LVM terminology). I've never used either LUKS or ZFS's encryption, so I can't tell you how they compare.
I don't really see much reason to use ext4 these days, except that it's pretty much the default for most distros. There's no advantage, no compelling reason to use it.
Finally, don't be tempted by de-duplication with ZFS. It sounds like a great idea in theory but what it means in practice is that the de-dupe table needs to be held in RAM so you're reducing your need for more very cheap drives and replacing it with a need for more very expensive RAM. This is, with a few exceptional use-cases (like running hundreds or thousands of the same VM image), a poor bargain - that RAM would be better used for running programs or caching disks.
| What are the advantages of using btrfs snapshots over rsnapshot in a backup scenario [closed] |
1,535,994,138,000 |
I have a USB stick encrypted with LUKS + Ext4. I have forgotten the password...
However, I know which words will be included in the password and have a list of all permutations of those words. About 10,000 permutations.
Instead of me trying each and every permutation 1 by 1 manually (which will be a long, slow, and painfully tedious process), is it possible to automate this process? I know this sounds like some sort of malicious brute force attack, but it's not. If I wanted something like that, I could have easily downloaded some dodgy software from the internet.
Instead, I want to use something which is safe on my computer, a script (or any safe solution) which is custom built for me specifically.
Is this possible?
|
Well, in the most naive case you can roughly do something like
for a in 'fo' 'foo' 'fooo'
do
for b in 'ba' 'bar' 'baar'
do
for c in 'bz' 'baz' 'bazz'
do
echo -n "$a$b$c" | cryptsetup open /dev/luks luks \
&& echo "'$a$b$c' is the winner!" \
&& break 3
done
done
done
and it goes through all the puzzle pieces ... foobarbz foobarbaz foobarbazz ... etc. in order. (If you have optional pieces, add '' empty string. If your pieces are in random order, well, think about it yourself).
To optimize performance, you can:
patch cryptsetup to keep reading passphrases from stdin (lukscrackplus on github for one such example but it's dated)
generate the complete list of words, split it into separate files, and run multiple such loops (one per core, perhaps even across multiple machines)
compile cryptsetup with a different/faster crypto backend (e.g. nettle instead of gcrypt), difference was huge last time I benchmarked it
find a different implementation meant to bruteforce LUKS
But it's probably pointless to optimize if you have either too little (can go through in a day w/o optimizing) or way too many possibilities (no amount of optimizing will be successful).
At the same time, check:
are you using the wrong keyboard layout?
is the LUKS header intact?
(with LUKS1 there is no way to know for sure, but if you hexdump -C it and there is no random data where it should be, no need to waste time then)
There's also a similar question here: https://security.stackexchange.com/q/128539
But if you're really able to narrow it down by a lot, the naive approach works too.
| Automate multiple password enties to decrypted LUKS + Ext4 USB stick |
1,535,994,138,000 |
I've got a full drive image 2022-06-11_fedora.iso that I'm trying to manipulate its partitions on another computer. (e.g. resize LVM logical volumes, move ESP, and expand /boot partition).
I cannot seem to mount the LVM volumes after decrypting the LUKS partition.
How can I mount the LVM volumes after decrypting the LUKS partition that they sit on in order to manipulate the volumes with the LVM command suite?
fdisk of image contents
3 partitions:
2022-06-11_fedora.iso1 is /boot
2022-06-11_fedora.iso2 is ESP
2022-06-11_fedora.iso3 is LVM on LUKS
$ fdisk -l 2022-06-11_fedora.iso
Disk 2022-06-11_fedora.iso: 238.47 GiB, 256060514304 bytes, 500118192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier:
Device Start End Sectors Size Type
2022-06-11_fedora.iso1 2048 514047 512000 250M Linux filesystem
2022-06-11_fedora.iso2 514048 808959 294912 144M EFI System
2022-06-11_fedora.iso3 808960 500117503 499308544 238.1G Linux filesystem
Decrypting third partition
$ sudo cryptsetup plainOpen --offset=808960 2022-06-11_fedora.iso cryptdisk
Enter passphrase for 2022-06-11_fedora.iso:
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
loop0 7:0 0 238.5G 0 loop
└─cryptdisk 253:2 0 238.1G 0 crypt
sda 8:0 0 1.8T 0 disk
└─sda1 8:1 0 1.8T 0 part
nvme0n1 259:0 0 1.8T 0 disk
├─nvme0n1p1 259:1 0 487M 0 part /boot/efi
├─nvme0n1p2 259:2 0 3.8G 0 part /recovery
└─nvme0n1p3 259:3 0 1.8T 0 part
└─cryptdata 253:0 0 1.8T 0 crypt
└─data-root 253:1 0 1.8T 0 lvm /
$ sudo fdisk -l /dev/mapper/cryptdisk
Disk /dev/mapper/cryptdisk: 238.09 GiB, 255646326784 bytes, 499309232 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Trying to mount /dev/mapper/cryptdisk
$ sudo mount /dev/mapper/cryptdisk /mnt/crypt
mount: /mnt/crypt: wrong fs type, bad option, bad superblock on /dev/mapper/cryptdisk, missing codepage or helper program, or other error.
How can I mount the LVM volumes after decrypting the LUKS partition?
|
First of all, this
sudo cryptsetup plainOpen --offset=808960 2022-06-11_fedora.iso cryptdisk
is wrong. If the third partition is really a LUKS partition you didn't open it correctly, the plain mode in cryptsetup uses hash of the provided passphrase to decrypt the data which won't work for LUKS.
Second: The /dev/mapper/cryptdisk device is the LVM physical volume (or it would be if it was decrypted correctly) it is not mountable. You need to mount the logical volume(s) on it.
To do this correctly:
Use losetup to create the loop device: sudo losetup -f 2022-06-11_fedora.iso --partscan
You should now see all three partitions in the lsblk output.
Open the third partition with sudo cryptsetup luksOpen /dev/loop0p3 cryptdisk.
If you don't see the logical volumes in the lsblk output, they were not automatically activated, use vgscan to scan for the volume group and then use sudo vgchange -ay <vg name> to activate it.
Mount the logical volume(s) in the VG. The path will be /dev/mapper/<vgname>-<lvname> (same as for your system data-root LV).
Note: VG name is a unique identifier in LVM so if the VG on the image is also called data, you won't be able to activate it and you need to rename it first by identifying the correct VG by its UUID using vgrename <uuid> <new name>. (You will notice this, LVM will complain about having two VGs in the system with the same name.)
| Cannot mount LVM volumes after manually decrypting LUKS partition |
1,535,994,138,000 |
I have a laptop with Arch on it, and I sized the root partition too small. Now I want to expand the partition by taking some from the home partition. I will put the details of the specifics below. My question(s) to you is
1) Am I just expanding the root? Or shrinking the home? Or is it both? If both then does order matter? I see several online tuts that sort of do them different ways. So it's confusing to me.
2) Should I follow the arch documentation exactly? It's not like other tuts I've seen which may not be distro specific. Also asking because it mentions things like make a new partition under expand, but never says anything about what to do with the old one. It would be great if you could explain this if the answer is yes.
3) Do I need to update my fstab afterwards?
4) If all goes well, I should still have my data on these partitions right? Obviously I'm backing up just to be sure.
Here are my specific details:
> df -h
Filesystem Size Used Avail Use% Mounted on
dev 7.7G 0 7.7G 0% /dev
run 7.7G 1.2M 7.7G 1% /run
/dev/mapper/archvg-root 9.8G 9.3G 0 100% /
tmpfs 7.7G 723M 7.0G 10% /dev/shm
tmpfs 7.7G 0 7.7G 0% /sys/fs/cgroup
tmpfs 7.7G 16K 7.7G 1% /tmp
/dev/nvme0n1p1 749M 62M 688M 9% /boot
/dev/mapper/archvg-home 456G 3.0G 430G 1% /home
tmpfs 1.6G 16K 1.6G 1% /run/user/1000
/dev/fuse 250G 78M 250G 1% /run/user/1000/keybase/kbfs
> lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
nvme0n1 259:0 0 477G 0 disk
├─nvme0n1p1 259:1 0 750M 0 part /boot
└─nvme0n1p2 259:2 0 476.2G 0 part
└─archlv 254:0 0 476.2G 0 crypt
├─archvg-swap 254:1 0 2G 0 lvm [SWAP]
├─archvg-root 254:2 0 10G 0 lvm /
└─archvg-home 254:3 0 464.2G 0 lvm /home
> sudo pvdisplay -m
--- Physical volume ---
PV Name /dev/mapper/archlv
VG Name archvg
PV Size 476.20 GiB / not usable <1.32 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 121908
Free PE 0
Allocated PE 121908
PV UUID m11dPA-mPYo-6dLS-mXPF-V1Ww-jXuO-QXfB8e
--- Physical Segments ---
Physical extent 0 to 511:
Logical volume /dev/archvg/swap
Logical extents 0 to 511
Physical extent 512 to 3071:
Logical volume /dev/archvg/root
Logical extents 0 to 2559
Physical extent 3072 to 121907:
Logical volume /dev/archvg/home
Logical extents 0 to 118835
> sudo cat /etc/crypttab
# Configuration for encrypted block devices.
# See crypttab(5) for details.
# NOTE: Do not list your root (/) partition here, it must be set up
# beforehand by the initramfs (/etc/mkinitcpio.conf).
# <name> <device> <password> <options>
# home UUID=b8ad5c18-f445-495d-9095-c9ec4f9d2f37 /etc/mypassword1
# data1 /dev/sda3 /etc/mypassword2
# data2 /dev/sda5 /etc/cryptfs.key
# swap /dev/sdx4 /dev/urandom swap,cipher=aes-cbc-essiv:sha256,size=256
# vol /dev/sdb7 none
> sudo cat /etc/fstab
# Static information about the filesystems.
# See fstab(5) for details.
# <file system> <dir> <type> <options> <dump> <pass>
# UUID=8ab13737-d7f1-4f2c-b67b-ad15f7374978
/dev/mapper/archvg-root / ext4 rw,relatime 0 1
# UUID=dc591a00-12d4-49fa-a81e-e80fa71e7aca
/dev/mapper/archvg-home /home ext4 rw,relatime 0 2
# UUID=5A10-D12E
/dev/nvme0n1p1 /boot vfat rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro 0 2
# UUID=492bf365-32de-4756-86da-7fc335dba3dd
/dev/mapper/archvg-swap none swap defaults,pri=-2 0 0
> findmnt
TARGET SOURCE FSTYPE OPTIONS
/ /dev/mapper/archvg-root
│ ext4 rw,relatime
├─/proc proc proc rw,nosuid,nodev,noexec,relatime
│ └─/proc/sys/fs/binfmt_misc systemd-1 autofs rw,relatime,fd=30,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=13001
│ └─/proc/sys/fs/binfmt_misc binfmt_misc binfmt_misc rw,relatime
├─/sys sys sysfs rw,nosuid,nodev,noexec,relatime
│ ├─/sys/firmware/efi/efivars efivarfs efivarfs rw,nosuid,nodev,noexec,relatime
│ ├─/sys/kernel/security securityfs securityfs rw,nosuid,nodev,noexec,relatime
│ ├─/sys/fs/cgroup tmpfs tmpfs ro,nosuid,nodev,noexec,mode=755
│ │ ├─/sys/fs/cgroup/unified cgroup2 cgroup2 rw,nosuid,nodev,noexec,relatime,nsdelegate
│ │ ├─/sys/fs/cgroup/systemd cgroup cgroup rw,nosuid,nodev,noexec,relatime,xattr,name=systemd
│ │ ├─/sys/fs/cgroup/cpu,cpuacct cgroup cgroup rw,nosuid,nodev,noexec,relatime,cpu,cpuacct
│ │ ├─/sys/fs/cgroup/perf_event cgroup cgroup rw,nosuid,nodev,noexec,relatime,perf_event
│ │ ├─/sys/fs/cgroup/rdma cgroup cgroup rw,nosuid,nodev,noexec,relatime,rdma
│ │ ├─/sys/fs/cgroup/devices cgroup cgroup rw,nosuid,nodev,noexec,relatime,devices
│ │ ├─/sys/fs/cgroup/net_cls,net_prio cgroup cgroup rw,nosuid,nodev,noexec,relatime,net_cls,net_prio
│ │ ├─/sys/fs/cgroup/blkio cgroup cgroup rw,nosuid,nodev,noexec,relatime,blkio
│ │ ├─/sys/fs/cgroup/pids cgroup cgroup rw,nosuid,nodev,noexec,relatime,pids
│ │ ├─/sys/fs/cgroup/memory cgroup cgroup rw,nosuid,nodev,noexec,relatime,memory
│ │ ├─/sys/fs/cgroup/cpuset cgroup cgroup rw,nosuid,nodev,noexec,relatime,cpuset
│ │ ├─/sys/fs/cgroup/hugetlb cgroup cgroup rw,nosuid,nodev,noexec,relatime,hugetlb
│ │ └─/sys/fs/cgroup/freezer cgroup cgroup rw,nosuid,nodev,noexec,relatime,freezer
│ ├─/sys/fs/pstore pstore pstore rw,nosuid,nodev,noexec,relatime
│ ├─/sys/fs/bpf bpf bpf rw,nosuid,nodev,noexec,relatime,mode=700
│ ├─/sys/kernel/debug debugfs debugfs rw,relatime
│ ├─/sys/kernel/config configfs configfs rw,relatime
│ └─/sys/fs/fuse/connections fusectl fusectl rw,relatime
├─/dev dev devtmpfs rw,nosuid,relatime,size=8054652k,nr_inodes=2013663,mode=755
│ ├─/dev/shm tmpfs tmpfs rw,nosuid,nodev
│ ├─/dev/pts devpts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000
│ ├─/dev/mqueue mqueue mqueue rw,relatime
│ └─/dev/hugepages hugetlbfs hugetlbfs rw,relatime,pagesize=2M
├─/run run tmpfs rw,nosuid,nodev,relatime,mode=755
│ ├─/run/user/1000 tmpfs tmpfs rw,nosuid,nodev,relatime,size=1613400k,mode=700,uid=1000,gid=985
│ │ └─/run/user/1000/keybase/kbfs /dev/fuse fuse rw,nosuid,nodev,relatime,user_id=1000,group_id=985
│ └─/run/docker/netns/07a9a88abf83 nsfs[net:[4026532513]]
│ nsfs rw
├─/tmp tmpfs tmpfs rw,nosuid,nodev
├─/boot /dev/nvme0n1p1 vfat rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro
├─/home /dev/mapper/archvg-home
│ ext4 rw,relatime
├─/var/lib/docker/overlay2/a375c9d741cdc4a028b45432bbf717fcab31e455020fd9a35caa33d3d091b86d/merged
│ overlay overlay rw,relatime,lowerdir=/var/lib/docker/overlay2/l/YKROXQXIMTM5ZON4Q4IHFNJPCC:/var/lib/docker/overlay2/l/KHHAHRA7VX4L6KOXOW44IYDHPS:/var/li
├─/var/lib/docker/containers/6b2b84ce263a25e24dd50b239a14947e55e70843e9b31fe53ac830f73f8584f7/mounts/shm
│ shm tmpfs rw,nosuid,nodev,noexec,relatime,size=65536k
└─/keybase keybase-redirector
fuse ro,nosuid,nodev,relatime,user_id=0,group_id=0,allow_other
Here is the steps I plan on taking
Boot from a live USB
# Step 1: Clone the current partition to a new partition
> dd if=/dev/mapper/archvg-root of=/dev/mapper/archvg2-root bs=4M
# Step 2: Extend the new partition
> cryptsetup open /dev/mapper/archvg2-root archlv
# Step 3: Enlarge the PV to use all the available remaining space of the partition
> pvresize /dev/mapper/archlv
## Review
> pvdisplay -m
# Step 4: Resize /home Logical Volume (trying to make it 100G)
> lvresize -L +90.2G /dev/CryptVolumeGroup/root
## Review
> pvdisplay -m
# Step 5: Resize encrypted volume (Trying to give it some space)
> resize2fs -p /dev/CryptVolumeGroup/root 101G
# Reboot
Here are other references of other's doing this differently which I'm still looking into if they have better methods or not.
https://serverfault.com/questions/394902/resizing-a-luks-encrypted-volume (He's unmounting, not mentioned in Arch docs. Not sure I need to)
Extend a LUKS encrypted partition to fill disk
https://blog.tinned-software.net/increase-the-size-of-a-luks-encrypted-partition/ (seems like less steps)
|
clarify terminology
Firstly, your rootfs, home, and swap are on logical volumes not partitions. I'm bringing this up because logical volumes and partitions are different animals. The instructions for one do no necessarily apply to the other. In addition, your volume group is inside a LUKS container. This is an advanced Arch configuration, but luckily the steps for what you want to accomplish are not too difficult :)
steps
Log out all users, and log in as root from a terminal (ex. CTRL+ALT+F1) NOT from within Xorg.
Switch to single-user mode to avoid the use of /home: systemctl rescue
umount /home
Shrink the /home logical volume and filesystem: lvreduce -r -L -100G archvg/home
mount /home
Enlarge the rootfs logical volume. No need to un-mount since ext4 and be enlarged while mounted: lvresize -r -L +100G archvg/home
Switch back to multi-user mode: systemctl default
Q&A
Am I just expanding the root? Or shrinking the home? Or is it both? If both then does order matter? Both, and yes the order matters because in order to enlarge root you need free space. Thus home must be shrunk first.
Should I follow the arch documentation exactly? Probably not. Advanced setups like yours demand an understanding of each component. In your case, that would be LVM2, LUKS, and ext4. This is because there's no way to write a one-size-fits all procedure; Every setup is unique. The Arch documentation can give you guide posts, but is unlikely to provide a step-by-step procedure that will Just Work (TM).
Do I need to update my fstab afterwards? No.
If all goes well, I should still have my data on these partitions right? Obviously I'm backing up just to be sure. Yes, your data should remain. However, as you stated, please, for the love of Linux, make a backup first!
| Resize LUKS Volume(s) |
1,526,978,710,000 |
There's an scenario that I'm worried about, and I'm not sure if it's possible to archieve. I got a machine with this setup:
A LUKS-ciphered main system partition.
An user with sudo access (added to sudoers list).
The sudoer canno't log in as root (since he doesn't know the password), also - canno't do "sudo su".
I got, as sysadmin, root access.
The question is: can I prevent or deny somehow the sudoer user from changing the LUKS Master Key?
I can deny him from executing dm-setup or cryptsetup, but he could always move and rename the files, or he may could download some library and program himself an application to change the MK. I don't know if there's something to prevent him from execute a linux action from kernel level, which dm-setup/cryptsetup interfaces to.
So, if I give sudoer access to an user, is there any way to keep the LUKS Master Key unchanged?
|
You are drawing a false dichotomy between "logging in as root" and "having sudo access". These shouldn't be thought of as such different things. If you don't trust your users with root access then don't let them use sudo! Blocking just the command sudo su is nonsense anyway, there is a sudo -s to get a root shell or you can sudo bash. Or there are a million other ways.
Basically you cannot create a blacklist of things sudo users cannot do. You will fail as it was not meant to work that way. Once you have access to a handful of things as PID 1 the system is yours.
What you can do is whitelist specific processes. Make sure these processes are not also writable by the user and make sure they don't accept user input or arguments in a way that would allow arbitrary command execution. Beware many common unix tools allow arbitrary commands in one way or another. A good method if they only need sudo access to do one task is to create a wrapper script that does just that one task and accepts no arguments and allow the user to execute that script as root.
| How can I prevent a sudoer to change the LUKS master key? |
1,526,978,710,000 |
Unfortunately my drive unlocks automatically. This makes the whole encryption useless. How do I turn off this annoying feature on a specified drive (e.g. /dev/x) ?
The cryptsetup command I've found is not documented. I'm afraid this could erase the whole drive!
cryptsetup luksRemoveKey /dev/x
|
LUKS doesn't “auto-unlock” a volume. The volume becomes accessible when you open it, which requires the key. The volume remains inaccessible when you close it; you can only close it when it is not in use, so you must close any open file and unmount the filesystem.
cryptsetup luksRemoveKey would remove the key from the volume, which would make it unreadable. Don't do this. The unlocking isn't happening because of LUKS, but because a program is calling cryptsetup luksOpen. You need to avoid storing your key in that program.
It looks like you have a keyring application that has recorded the key for the volume, specifically gnome-keyring. Remove the key from the keyring. You can manipulate your keyring with Seahorse.
| How to remove LUKS auto-unlock? |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.