2

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.

Jorge Castro
  • 71,754
Oxwivi
  • 17,849
  • 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 - https://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 08:07

2 Answers2

1

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.

Oli
  • 293,335
  • 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
1

Can you try this:

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

sudo mount /dev/sdaX /home/user

desgua
  • 32,917