cryptsetup and umount fail with "target is busy." error

264 views Asked by At

I'm experimenting with cryptsetup. My target is to be able to store data into and encrypted file into a non-encrypted hard drive.

I'm doing the following

mkdir /data/test && /data/test

# Create a key
openssl genrsa -out luks_key 4096

# Create file container
dd if=/dev/zero of=device bs=1G count=50 status=progress

# Create and open luks device
cryptsetup -v -y --batch-mode luksFormat device luks_key
sudo cryptsetup -v --batch-mode --key-file=luks_key --type luks open device device_name

# Format the device
sudo mkfs.ext4 -j /dev/mapper/device_name

# Create mount point
mkdir mount_point

# Mount the device
sudo mount -t ext4 /dev/mapper/device_name mount_point

cd mount_point

sudo dd if=/dev/zero of=random_data.bin bs=1G count=1 status=progress

# This will fail until I close the terminal window with "target is busy." error
sudo umount /data/test/mount_point
cryptsetup -v close device_name

All works well up to the point were I try to unmount. The error is:

umount: /data/test/mount_point: target is busy.

The only way to be able to unmount is to close the terminal window. Opening a second one isn't enough. I'm little bit puzzled :)

I run on LinuxMint 18.04 with Linux kernel 5.15.30-25.

Anyone seeing the same thing?

Thanks,

0

There are 0 answers