Creating a virtual disk to "hide" files
Posted 02-02-2011 at 09:32 PM by binary_pearl
One of the many neat things you can do in Linux is to create a "virtual disk" (which is really just a file), and you can add other files to it. We use this at work to store an xml file into a virtual disk that are xen virtual machines use when booting to configure themselves. But you could also use this as a way
to more-or-less hide files.
So first: Create the virtual disk (The exmaple creates a 10MB disk) :
`dd if=/dev/zero of=/root/name_of_virtual_disk bs=1M count=10`
Format the disk to ext3:
`mkfs -t ext3 /root/name_of_virtual_disk`
You will get the message below, press 'y' at the prompt:
/root/name_of_virtual_disk is not a block special device.
Proceed anyway? (y,n)
Make a directory so you can mount your new virtual disk:
mkdir /root/mount_point
Now mount your new virtual disk to your mount point:
`mount -t auto -o loop /root/name_of_virtual_disk /root/mount_point
copy whatever files you want into /root/mount_point/
Now unmount the disk:
`umount /root/name_of_virtual_disk`
The files that you just copied are no longer visible, but they are still stored within
/root/name_of_virtual_disk
If you want to see your files again do the same mount command as above:
`mount -t auto -o loop /root/name_of_virtual_disk /root/mount_point
Hopefully this concept helps someone in the future!
--Shaun
to more-or-less hide files.
So first: Create the virtual disk (The exmaple creates a 10MB disk) :
`dd if=/dev/zero of=/root/name_of_virtual_disk bs=1M count=10`
Format the disk to ext3:
`mkfs -t ext3 /root/name_of_virtual_disk`
You will get the message below, press 'y' at the prompt:
/root/name_of_virtual_disk is not a block special device.
Proceed anyway? (y,n)
Make a directory so you can mount your new virtual disk:
mkdir /root/mount_point
Now mount your new virtual disk to your mount point:
`mount -t auto -o loop /root/name_of_virtual_disk /root/mount_point
copy whatever files you want into /root/mount_point/
Now unmount the disk:
`umount /root/name_of_virtual_disk`
The files that you just copied are no longer visible, but they are still stored within
/root/name_of_virtual_disk
If you want to see your files again do the same mount command as above:
`mount -t auto -o loop /root/name_of_virtual_disk /root/mount_point
Hopefully this concept helps someone in the future!
--Shaun
Total Comments 3
Comments
-
This concept will prove to be more helpful, if you put it in the LQ tutorials section here: http://www.linuxquestions.org/linux/answers
Posted 02-03-2011 at 03:29 AM by Aquarius_Girl -
Additionally, an alternative could be encrypting the filesystem OR a separate tutorial on using an encrypted tar file. An encrypted tar file would take about as much room but would allow unprivileged users to manage their hidden files. Makes me wonder if there are other encryption options that are user based. It would be nice to hide a user's Document Downloads etc. file from even the prying eyes of root.
Posted 02-03-2011 at 11:01 AM by lumak -
Thanks, I'll look into putting this information in the LQ Tutorials section.
I like your idea of an encrypted tar file, or something like that. Your correct that only root can mount the virtual disk as a loopback. I'll see what I can come up with.
--ShaunPosted 02-07-2011 at 08:30 PM by binary_pearl