Hi: I would appreciate comments on this problem. I want to learn, not just solve the problem.
I would like to backup a directory structure greater than 4GB in an encrypted usb device, under the following restrictions: keep the usb device formatted as FAT32, with a single partition; leave some unencrypted space for ordinary use.
Since FAT32 is limited to 4GB files, I thought I could create two or more files and mount a logical volume with them. It worked for the first time, but not anymore. I am failing somewhere, but I cannot figure out how to improve. It follows what I have done:
Create three files, two limited to 4Gb and another one (it could have been the three same size):
Code:
dd if=dev/urandom of=/media/usbdevice/0 bs=1M count=2000
dd if=dev/urandom of=/media/usbdevice/1 bs=1M count=4000
dd if=dev/urandom of=/media/usbdevice/2 bs=1M count=4000
Associate the files with a loop device:
Code:
su
for i in `seq 0 1 2`;do losetup /dev/loop$i /media/usbdevice/$i;done
Open them:
Code:
for i in `seq 0 1 2`;do cryptsetup --key-file="/home/fooname/passwordfile" luksOpen /dev/loop$i cryptfun$i ;done
Create the logical volumes, leaving some unused room:
Code:
pvcreate /dev/mapper/cryptfun0 /dev/mapper/cryptfun1 /dev/mapper/cryptfun2
vgcreate vgpendrive_fooname /dev/mapper/cryptfun0 /dev/mapper/cryptfun1 /dev/mapper/cryptfun2
lvcreate -L 9700M vgpendrive_fooname
vgchange -a y vgpendrive_fooname
Make a file system compatible with files greater than 4GB. I like ext2
Code:
mkfs -t ext2 /dev/vgpendrive_fooname/lvol0
Mount it:
Code:
mount /dev/vgpendrive_fooname/lvol0 /mnt/lvm
For some reason, I was not able to mount with my uid: mount -t ext2 -o rw,uid=1000 dev/vgpendrive_fooname/lvol0 /mnt/lvm, but this is another question for another time. So, I simply changed permissions:
Code:
chown root:fooname /mnt/lvm
chmod g+rwx /mnt/lvm/
As normal user, check whether it works or not: just copy some stuff into the mounted volume
Code:
su fooname
cp morethan4GBfile /mnt/lvm
Great. It works!
Now, I want undo each step:
Code:
su
umount /mnt/lvm/
vgchange -a n vgpendrive_fooname
vgremove vgpendrive_fooname
pvremove /dev/mapper/cryptfun0 /dev/mapper/cryptfun1 /dev/mapper/cryptfun2
for i in `seq 0 1 2`;do cryptsetup luksClose cryptfun$i ;done
for i in `seq 0 1 2`;do losetup -d /dev/loop$i ;done
Great again. It works fine. Now, I want repeat almost the same steps another day; I tried:
Code:
for i in `seq 0 1 2`;do losetup /dev/loop$i /media/usbdevice/$i;done
for i in `seq 0 1 2`;do cryptsetup --key-file="/home/fooname/passwordfile" luksOpen /dev/loop$i cryptfun$i ;done
pvcreate /dev/mapper/cryptfun0 /dev/mapper/cryptfun1 /dev/mapper/cryptfun2
vgcreate vgpendrive_fooname /dev/mapper/cryptfun0 /dev/mapper/cryptfun1 /dev/mapper/cryptfun2
lvcreate -L 9700M vgpendrive_fooname
vgchange -a y vgpendrive_fooname
mount /dev/vgpendrive_fooname/lvol0 /mnt/lvm
Here I cannot go further because of an error message:
Quote:
mount: you must specify the filesystem type
|
If I try:
Code:
mount -t ext2 /dev/vgpendrive_fooname/lvol0 /mnt/lvm
I get:
Quote:
mount: wrong fs type, bad option, bad superblock on /dev/mapper/vgpendrive_fooname-lvol0,
missing codepage or helper program, or other error
In some cases useful info is found in syslog - try
dmesg | tail or so
|
This shows I am thinking wrong, but I do not know why. What should I have done?
Aditional information:
Quote:
Linux hostname 2.6.32-5-686 #1 SMP Fri Feb 15 15:48:27 UTC 2013 i686 GNU/Linux
|
Quote:
LVM version: 2.02.66(2) (2010-05-20)
Library version: 1.02.48 (2010-05-20)
Driver version: 4.15.
|
USB device: 16GB
Greetings.