LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Blogs > binary_pearl
User Name
Password

Notices


Rate this Entry

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
Posted in Uncategorized
Views 3788 Comments 3
« Prev     Main     Next »
Total Comments 3

Comments

  1. Old Comment
    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 Aquarius_Girl is offline
  2. Old Comment
    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 lumak is offline
  3. Old Comment
    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.

    --Shaun
    Posted 02-07-2011 at 08:30 PM by binary_pearl binary_pearl is offline
 

  



All times are GMT -5. The time now is 07:57 PM.

Main Menu
Advertisement
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration