Mount point bind issues

Hi ALL

I am unable to do mount bind to connect new storage

Once I run the below commands both file systems were empty

Code:

mount --bind /prod/OpenCSS /var/lib/test

Code:

echo "/prod/OpenCSS /var/lib/pgsql bind bind 0 0" >> /etc/fstab

Hi,

Your syntax is basically correct, as far as I can tell. Here's the results of a test on my own system, running Ubuntu 16.04 x86_64:

$ pwd
/home/unixforum/271681
$ ls
path1  path2
$ ls path1
doc1.pdf  file1.txt  image1.jpeg  sheet1.xlsx
$ ls path2
$ sudo /bin/mount --bind /home/unixforum/271681/path1 /home/unixforum/271681/path2
$ ls path1
doc1.pdf  file1.txt  image1.jpeg  sheet1.xlsx
$ ls path2
doc1.pdf  file1.txt  image1.jpeg  sheet1.xlsx
$ mount | grep unixforum
/dev/sda2 on /home/unixforum/271681/path2 type ext4 (rw,relatime,errors=remount-ro,data=ordered)
$ sudo /bin/umount /home/unixforum/271681/path2
$ ls path1
doc1.pdf  file1.txt  image1.jpeg  sheet1.xlsx
$ ls path2
$

Asf for the fstab entry, the syntax seems fine here too. Again, a test, this time doing the mounting with an fstab entry.

$ tail -1 /etc/fstab
/home/unixforum/271681/path1    /home/unixforum/271681/path2    bind    bind    0 0
$ ls path1
doc1.pdf  file1.txt  image1.jpeg  sheet1.xlsx
$ ls path2
$ sudo /bin/mount /home/unixforum/271681/path2
$ ls path1
doc1.pdf  file1.txt  image1.jpeg  sheet1.xlsx
$ ls path2
doc1.pdf  file1.txt  image1.jpeg  sheet1.xlsx
$ sudo /bin/umount /home/unixforum/271681/path2
$ ls path1
doc1.pdf  file1.txt  image1.jpeg  sheet1.xlsx
$ ls path2
$

So I'm not sure why this isn't working on your own system. Certiainly on my own local box, this syntax works fine, and I didn't really have to change anything you were doing.

1 Like

Thank you again

Yes I am able to replicate successfully on other server

this server is failing

so you think there is some issue with the existing mount point / file systems?

Hi,

Just to check something: the order in a bind mount is source first, then destination. So in my above examples, it was the content of path1 that I wanted to show up under path2 . Is it the case that you want all the content currently in /prod/OpenCSS to show up underneath /var/lib/test and/or /var/lib/pgsql , or it is the PostgreSQL content you want to appear underneath the other directory ?

Also, if you look at the content of both directories before doing the bind mount, are either of them empty to begin with ?

1 Like

got it

finally I made same mistake

mount --bind /some/where /else/where
makes /else/where a mount point under which the contents of /some/where are visible.

Hi,

Great, glad you got that sorted. One last thing that may disappoint, however. If you're doing this because you're hoping to basically add the free space of the /prod/OpenCSS filesystem to the existing /var/lib/pgsql filesystem...well, then you're out of luck.

That's not how bind mounts work, or what they're for. They're purely for providing an alternative path to access the same content in multiple places, and nothing else. The free space you'll see will be that of the original filesystem, since all the calls are being routed through to the original filesystem - the new one (in your scenario) isn't actually going to be used at all.

For example, watch what happens if I do a bind mount of my /boot filesystem to a new directory, /mnt/misc :

$ df -h /boot
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       240M  110M  114M  49% /boot
$ df -h /mnt/misc
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda2       225G  132G   82G  62% /
$ sudo /bin/mount --bind /boot /mnt/misc
$ df -h /boot
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       240M  110M  114M  49% /boot
$ df -h /mnt/misc
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       240M  110M  114M  49% /mnt/misc
$ sudo /bin/umount /mnt/misc
$ df -h /boot
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       240M  110M  114M  49% /boot
$ df -h /mnt/misc
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda2       225G  132G   82G  62% /
$

So as you can see, the disc space and all other properties of the bind mount destination are the same as the source, since in reality all you're doing is providing an additional path for accessing the source, and nothing more.

Hope this helps.

1 Like

Thank you Drysdalk

I did moved data to new point and then implemented bind mount to make use of the space ...

---------- Post updated at 04:58 PM ---------- Previous update was at 04:57 PM ----------

:b:

Hi,

OK, I see. That will work I suppose, though may I ask: why don't you just re-mount the new filesystem directly as the PostgreSQL filesystem ? Or is the new space not a whole filesystem of its own, and only part of another (in which case, this makes a kind of sense as a temporary stopgap) ?

1 Like

Hi Drysdalk

I think this process is to maintain default locations and use additional storage for growing data :slight_smile:

Thank you again , appreciate your help

Have you considered rather using symlinks to achieve desired result ?

You can also manipulate your database location from inside database itself using TABLESPACE.

It's much easier to maintain a database defined location, then symlink/bind stuff around.
That way you can manipulate underlying storage via LVM and have unified configuration for all your hosts regardless of size.