Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Is there a way to bind folders located in an .img file to folders outside it?

To be more specific, supposing there's Ubuntu installed in img file, I want the image's fstab to bind a few folders outside the img file.

That is to say the binding must be done from within the image. So if I save anything in one of the binded folders, it will save outside the image without taking up the space assigned to the img.

share|improve this question
    
How is Ubuntu running from the img? –  Oli Aug 13 '11 at 15:06
    
I can make it run using KVM, but my goal is to use GRUB and boot into it. –  Oxwivi Aug 13 '11 at 16:02
    
Is this a standard ubuntu install or some-sort of customised install? If its a customised image, you probably want to do some-sort of nfs-sharing/mounting in the img (or iso) customised image ... this is beyond my knowledge though on how to produce a customised image, hence this comment - help.ubuntu.com/community/SettingUpNFSHowTo –  fossfreedom Aug 15 '11 at 20:45
    
@fossfreedom, that isn't an option, as I plan to be able to boot into the img as well. –  Oxwivi Aug 16 '11 at 8:07

2 Answers 2

Can you try this:

edit /etc/rc.local and make an entry like:

sudo mount /dev/sdaX /home/user

share|improve this answer
    
If I boot into the img, there isn't going to be any other operating system to manage the share. –  Oxwivi Aug 17 '11 at 13:28
    
Now I got it. I will think in a solution. –  desgua Aug 17 '11 at 13:32
    
Maybe mounting with script that runs at startup? –  desgua Aug 17 '11 at 13:53
    
Yes but, how can I get it to detect the filesystem outside in the first place? –  Oxwivi Aug 18 '11 at 11:16
    
After the boot, what is the output of sudo fdisk -l? –  desgua Aug 18 '11 at 12:27

I don't see why not. The Linux is just a series of files. Devices are files and your img is just a file on a device. Mount the device, then the image on the device and then bind-mount the locations inside the mounted img. Simples.

UUID=your_device_UUID    /media/disk    ext4    errors=remount-ro    0    1
/media/disk/image.img    /mnt/img       auto    defaults             0    0
/mnt/img/deep-location   /mnt/deep      none    bind

The targets (second column) need to exist so you will have to do some sudo mkdir (drop the sudo if you're mounting inside your home). The locations are completely up to you. Use /mnt/ for mounting things you don't want to show up as devices in naultilus and use /media/ for things that you do want to show up.

Oh and on the second mount, you might have to switch auto for the actual filesystem of the image.

share|improve this answer
    
No, I mean bind from within the Ubuntu in the img. The binding I'm looking for should be done by the Ubuntu inside. –  Oxwivi Aug 13 '11 at 11:09
    
No, I still don't understand what you're trying to do. Perhaps you could edit the question to give an example of what should be where. –  Oli Aug 13 '11 at 11:14
    
Updated question. –  Oxwivi Aug 13 '11 at 11:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.