# kldload geom_bdeor for automatic loading we register in / boot / loader.conf
geom_bde_load = "YES"Create the file itself (in my case, one megabyte):
# dd bs = 1024 count = 1024 if = / dev / zero of = / mnt / nokia / virt-fsCreate a device that looks into this file:
# mdconfig -a -t vnode -f / mnt / nokia / virt-fs -u 0Now we have a device / dev / md0.
# gbde init / dev / md0Here you will be asked to enter the password twice.
Attention, this is the easiest way. gbde allows more sophisticated security with lock and key files. If you're interested, see man.Now the encrypted device must be connected:
# gbde attach / dev / md0Enter the password again. If the password is not correct, nothing will happen. If the correct one is, the device /dev/md0.bde appears.
# newfs -U -O2 /dev/md0.bdeThat's all, you can disassemble the whole structure, if you no longer need it (for more details, see below):
# gbde detach / dev / md0; mdconfig -d -u 0
# mdconfig -a -t vnode -f / mnt / nokia / virt-fs -u 0 # gbde attach / dev / md0 # mount /dev/md0.bde / mnt-privateNow an encrypted file system is mounted in / mnt-private, located in the / mnt / nokia / virt-fs file and any program can use it (by the way, they are driving simlinks!).
# umount / mnt-private # gbde detach / dev / md0 # mdconfig -d -u 0Please note that if one of these commands does not work (for example, the file system is busy and not unmounted), then the rest will not work either. This must be taken into account when writing a connection / disconnection script.
Source: https://habr.com/ru/post/76643/
All Articles