Encrypting DVD or CDROM from iso
Hi to All,
finally I've found the right (and tested) procedure in this simple script, made by sowbug: https://gist.github.com/sowbug/c7f83140581fbe3e6a9b3ddf24891e77#gistcomment-3531970
# All the code from http://billauer.co.il/blog/2010/10/encrypted-iso-dvd-luks-dm-crypt-fedora-linux/
MB_COUNT=100
VOL_NAME=MyVolName
DIR_TO_COPY=/tmp/mydir
# Make a 100MB disk image
dd if=/dev/zero of=disk.img bs=1M count=$MB_COUNT
# become root sudo su
# write to the image # ****** NOTE that you'll be prompted three times for a passphrase losetup /dev/loop1 disk.img && \ cryptsetup luksFormat /dev/loop1 && \ cryptsetup luksOpen /dev/loop1 mybackupdisk && \ genisoimage -R -J -joliet-long -graft-points -V $VOL_NAME -o /dev/mapper/mybackupdisk $DIR_TO_COPY
# close the device cryptsetup luksClose /dev/mapper/mybackupdisk && \ losetup -d /dev/loop1
# Now you have disk.img that can be burned to a CD/DVD, or just mount it in Linux. # You'll be prompted for the passphrase each time you mount it.
Thanks
Davide
Italy
Quoted 4 lines · Davide Marchi
Hi to All,
finally I've found the right (and tested) procedure in this simple script, made by sowbug:
https://gist.github.com/sowbug/c7f83140581fbe3e6a9b3ddf24891e77#gistcomment-3531970
The whole problem was that the size of device was wrongly calculated
from the debug:
Quoted 1 line
# Device size 16777216, offset 16777216.
This is apparently device size covering only LUKS2 header (default LUKS2 takes 16MB), no data at all - then the error is expected.
Quoted 9 lines
# All the code from
http://billauer.co.il/blog/2010/10/encrypted-iso-dvd-luks-dm-crypt-fedora-linux/MB_COUNT=100
VOL_NAME=MyVolName
DIR_TO_COPY=/tmp/mydir# Make a 100MB disk image
dd if=/dev/zero of=disk.img bs=1M count=$MB_COUNT
All you need to do here is just to allocate requested size for data + 16M for header. (I have no idea why the original post tries to do is such complicated way.)
Also you do not need to physically write the file, sparse file creation is much faster here (try sizes in GB), just run (dd can do this using seek=... option too)
truncate disk.img -s 100M
Quoted 7 lines
# become root sudo su# write to the image # ****** NOTE that you'll be prompted three times for a passphrase losetup /dev/loop1 disk.img && \
This losetup step is not needed, loop is allocated automatically if argument is a file (except for very old kernel where automatic loop detach option is not yet available)
just run "cryptsetup luksFormat disk.img" and "cryptsetup open disk.img mybackupdisk"
Quoted 8 lines
cryptsetup luksFormat /dev/loop1 && \ cryptsetup luksOpen /dev/loop1 mybackupdisk && \ genisoimage -R -J -joliet-long -graft-points -V $VOL_NAME -o
/dev/mapper/mybackupdisk$DIR_TO_COPY# close the device cryptsetup luksClose /dev/mapper/mybackupdisk && \ losetup -d /dev/loop1
This losetup is automatic on luksClose (so not needed) if you remove explicit loop allocation above.
Milan