0

The commands I invoke are the following

  1. Create image file
dd if=/dev/zero of=benj.luks bs=1k count=666000
  1. Set up LUKS container
cryptsetup luksFormat benj.luks
  1. Set up loop device and open the LUKS container
cryptsetup luksOpen benj.luks benjImage
  1. Check that the loop device has been set up and mapped
lsblk

Output

NAME        MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINTS
loop0         7:0    0 650.4M  0 loop  
└─benjImage 254:1    0 634.4M  0 crypt 
  1. Create file system ext4 on benjImage
sudo mkfs.ext4 -b 2048 -F -F /dev/mapper/benjImage

Command fails

mke2fs 1.46.5 (30-Dec-2021)
mkfs.ext4: Invalid argument while setting blocksize; too small for device

1 Answer 1

1
cat /sys/block/loop0/queue/physical_block_size
cat /sys/block/loop0/queue/logical_block_size

revealed, that the loop device was mounted as a 4094 bytes block device on which no 2048 byte file system can be created.

hence the solution is to set up the loop device manually and define the sector size at 2048 by utilising the -b option as in

sudo losetup -b 2048 -f benj.luks

before step 2 and then applying consecutive commands on /dev/loop0 (or whichever loop device is assigned) instead of the image file, ie

cryptsetup luksFormat /dev/loop0
cryptsetup luksOpen /dev/loop0 benjImage
sudo mkfs.ext4 -b 2048 /dev/mapper/benjImage

voila

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.