[dm-crypt] LUKS partition write-protected, mounting read-only

David Christensen dpchrist at holgerdanske.com
Wed Apr 27 06:18:17 CEST 2016


On 04/26/2016 03:38 PM, Serrano Pereira wrote:
> Hello,
>
> When I create a LUKS partition like so:
>
> $ cryptsetup luksFormat /root/test

I typically put a LUKS container into a partition on a HDD, SSD, USB 
flash drive, etc. -- e.g. /dev/sdb1.


Is /root/test a file (?).  How did you create it?


> $ cryptsetup open /root/test test

Note that 'test' is a user-space command and/or a shell built-in. It's 
best to avoid using that word for *anything*.


My 'man cryptsetup' doesn't show any 'open' action.  Did you cut/paste 
the above from a console session?  If not, please post exact console 
sessions with commands and output.  Entering things by hand from memory 
invites Murphy's Law.


> $ mkfs.ext4 -j /dev/mapper/test

Why the '-j' option (ext3 journal)?


> $ mount /dev/mapper/test /mnt/files

I assume /mnt/files already existed when you ran the above command?

>
> Then I can create files in /mnt/files just fine. But when I copy
> /root/test to a different computer,

Did you unmount the file system and close the LUKS container before 
copying /root/test to the other machine?


> and then do:
>
> $ cryptsetup open /root/test test
> Enter passphrase for /root/test:
> mount: /dev/mapper/test is write-protected, mounting read-only
> $ mount /dev/mapper/test /mnt/files
>
> As you can see, the device is mounted read-only. I cannot write any
> files to the LUKS partition. Why is this so? How can I write to the
> partition on another computer?

As root, please run these commands on the computer with the source LUKS 
device (file) and post the console session:

     uname -a

     umount /mnt/test

     cryptsetup --version

     cryptsetup luksClose test

     ls -l /root/test

     cryptsetup luksDump /root/test

     cryptsetup luksOpen /root/test test

     ls -l /dev/mapper/test

     fsck /dev/mapper/test

     ls -ld /mnt/files

     mount /dev/mapper/test /mnt/files

     mount | grep '/mnt/files'

     ls -ld /mnt/files

     echo 'hello, world!' > /mnt/files/hello.txt


Then repeat for the computer with the copy.


We're looking for error messages.


If you don't understand the above commands, RTFM each one.  If a command 
is broken, fix it.


Hopefully, that will provide enough clues to figure out what's going on.


David



More information about the dm-crypt mailing list