You are not logged in.

#1 2020-05-27 00:34:21

saurabh000345
Member
From: West Bengal, India
Registered: 2018-12-20
Posts: 17
Website

cryptsetup luksFormat taking forever

I just got a new AMD Ryzen 5 3600 computer. cryptsetup luksFormat command is taking only seconds to complete encryption on my i3 laptop. I gave it 18 hours at a stretch to encrypt a 2TB partition but later I read on forums that it shouldn't take long. I created a 10 GB partition on my pen drive and it completed in around 40 seconds on my laptop. I killed the process on my computer after about 13 minutes. I've used the same command on both machines. Is this a CPU hardware issue? The partitions on my HDD and SDD are GPT. I cannot recall the type on the pen drive I tested.

The following are the commands I tried:

cryptsetup --verbose --cipher aes-xts-plain64 --key-size 512 --hash sha512 --iter-time 5000 --use-random luksFormat /dev/sdaX
cryptsetup -v -y luksFormat /dev/sdaXY

Something Rather than Nothing!

Offline

#2 2020-05-27 01:31:38

mpan
Member
Registered: 2012-08-01
Posts: 566
Website

Re: cryptsetup luksFormat taking forever

luksFormat is only writing the LUKS header: its should end quickly regardless of the block device size.

A few questions to poke around:

  • What state the cryptsetup process is in while it hangs? You can check that using e.g. extra/htop or top from core/procps-ng by looking at the “S” column.

  • Is the CPU doing much while cryptsetup hangs?

  • Anything interesting in dmesg after cryptsetup starts?


Sometimes I seem a bit harsh — don’t get offended too easily! PGP: 7C848198AE93D3BB

Offline

#3 2020-05-27 01:48:17

saurabh000345
Member
From: West Bengal, India
Registered: 2018-12-20
Posts: 17
Website

Re: cryptsetup luksFormat taking forever

mpan wrote:

luksFormat is only writing the LUKS header: its should end quickly regardless of the block device size.

A few questions to poke around:

  • What state the cryptsetup process is in while it hangs? You can check that using e.g. extra/htop or top from core/procps-ng by looking at the “S” column.

  • Is the CPU doing much while cryptsetup hangs?

  • Anything interesting in dmesg after cryptsetup starts?

  • It's R the whole time

  • The CPU usage is at a 100% constantly (has never dropped lower than 99.4%)

  • I'll have to try it again to show the dmesg logs.

And yes that was exactly what i read. I don't see a reason for it to misbehave when it got done in seconds on an underpowered laptop with the same commands.

Last edited by saurabh000345 (2020-05-27 01:49:07)


Something Rather than Nothing!

Offline

#4 2020-05-27 02:54:07

loqs
Member
Registered: 2014-03-06
Posts: 11,694

Re: cryptsetup luksFormat taking forever

If you are executing cryptsetup using the installation media without chroot what release is the installation media.  If it is after a chroot or in an installed system what is the version of the json-c package?

Offline

#5 2020-05-27 02:54:24

mpan
Member
Registered: 2012-08-01
Posts: 566
Website

Re: cryptsetup luksFormat taking forever

That eliminates my first guess: that it may be waiting for some I/O operation. If it’s in the R(unning) state and CPU is actually doing something, it’s not that. Perhaps someone else will have another idea.


Sometimes I seem a bit harsh — don’t get offended too easily! PGP: 7C848198AE93D3BB

Offline

#6 2020-05-27 08:45:32

frostschutz
Member
Registered: 2013-11-15
Posts: 978

Re: cryptsetup luksFormat taking forever

The only thing I can think of is that --use-random /dev/random may be blocking on a low entropy system w/o (trusted) hw generator or entropy helper like haveged running.

with luks2, cryptsetup uses a lot more random data than it used to. it used to be just a few random bytes for the secret key. now it wipes the entire header area with random data first so it wants 16MB+

if the problem goes away with --use-urandom then that is your issue

AMD Ryzen 5 3600

I think there were some RDRAND related issues on that platform too, I don't have a ryzen myself so I don't know if it might be triggering something for you

anything in dmesg? and run a memtest, smart test for drive, etc. just in case.

if nothing comes up, you could strace cryptsetup and see what it's doing

Last edited by frostschutz (2020-05-27 08:57:18)

Offline

#7 2020-05-27 19:54:49

loqs
Member
Registered: 2014-03-06
Posts: 11,694

Re: cryptsetup luksFormat taking forever

@frostschutz in 5.6 the random and urandom devices uses the same pool the only difference being accesses using the random device block until the pool is considered initialized.
The installation media also starts haveged as a dependency of pacman-init.service.
There is an issue with json-c package used for the May 2020 ISO with respect to RDRAND and AMD CPU's you already noted.  The kernel and systemd on the ISO are patched for the issue and the ISO does update AMD ucode,  but if there is no ucode update the issue can still trigger.

Offline

#8 2020-05-27 20:06:27

frostschutz
Member
Registered: 2013-11-15
Posts: 978

Re: cryptsetup luksFormat taking forever

oh right, we had a thread about it here https://bbs.archlinux.org/viewtopic.php?id=255283

except that was about luksOpen, but I guess it could affect luksFormat and other things just as well

Offline

Board footer

Powered by FluxBB