Operating System - Linux
1748142 Members
3633 Online
108758 Solutions
New Discussion

Re: how to create the softlink two mount points

 
rajesh73
Super Advisor

how to create the softlink two mount points

example

 

Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda5             19840892   2189396  16627356  12% /
/dev/sda6               980308     17652    912056   2% /swap
/dev/sda1               101086     11342     84525  12% /boot
tmpfs                   253588         0    253588   0% /dev/shm
/dev/sda3             19840924    176220  18640564   1% /data2
/dev/sda2             19840924    176204  18640580   1% /scratch
[root@testlinux ~]#

 

i want to create the softlink betweeb /stage directory to /scratch mount point

 

Requirment

when user upload the data in /stage directory that time data it will reflect to /scratch mount point.how to create the soft link.

 

 

5 REPLIES 5
rajesh73
Super Advisor

Re: how to create the softlink two mount points

one small input one folder in mount point another one is root directory
rajesh73
Super Advisor

Re: how to create the softlink two mount points

one more input in my production server /stage and /scratch  different vg.

Matti_Kurkela
Honored Contributor

Re: how to create the softlink two mount points

If the uploaded filename is not known in advance, you must softlink the entire directory. To do that, you must move away (or unmount if necessary) the current /stage directory. With soft links, it does not matter if the link and target are in different filesystems or VGs.

 

# umount /stage #(if necessary)
# mv /stage /stage.old
# ln -s /scratch /stage
MK
rajesh73
Super Advisor

Re: how to create the softlink two mount points

Hi Matti,

 

Thnaks for your reply.

 

#mv /stage /stage.oldf -what is the requirment of this command

 

#ln -s /scratch /stage - this will create the link file under the /stage or /scratch

 

one more doubt,

if i change any mount point name in fstab entry ,the same need to update /etc/mtab this is required or automatically update happen

 

 

Matti_Kurkela
Honored Contributor

Re: how to create the softlink two mount points

> #mv /stage /stage.oldf -what is the requirment of this command

 

You cannot have two things with the same name in the same directory, i.e. if there is a directory/mountpoint named /stage, there cannot be a softlink named /stage, and vice versa.

 

Filesystems can only be mounted on top of directories, so if /stage was a mountpoint, there will be a directory named /stage left after the "umount /stage" command. Before creating the softlink, this directory needs to be moved away or deleted.

 

If you run the "ln -s /scratch /stage" command while /stage already exists, one of two things happens:

  • if /stage is a file, you'll get an error, telling you that /stage already exists.
  • if /stage is a directory, the ln command assumes you meant "link /scratch into directory /stage using its original name", and so you'll get your softlink as /stage/scratch, which is not what you wanted.

The "ln" command works much like "cp", but without actually copying the data.

 

> if i change any mount point name in fstab entry ,the same need to update /etc/mtab

 

No, you should not normally edit /etc/mtab at all.

 

/etc/mtab is updated by the mount/umount commands: its purpose is to describe what is currently mounted.

 

In Linux, /proc/mounts offers much the same thing and it can even be used as a replacement of /etc/mtab, but in some situations the mount command stores some extra data in /etc/mtab which is not available through /proc/mounts (mainly when you're using the "user" mount option to allow non-root users to mount/unmount things).

 

The only times you might want to edit or replace /etc/mtab are:

  • when you've accidentally overwritten the current /etc/mtab, e.g. by restoring an old full backup of /etc that had a different configuration of mountpoints than what the system currently has, or
  • when you have manually mounted/unmounted other filesystems while the root filesystem has been in read-only mode, so the mount/umount commands failed to update /etc/mtab accordingly (e.g. because of a disk failure affecting the root filesystem), or
  • you are preparing to shut down the system that has a mounted filesystem that you know cannot be unmounted cleanly (e.g. because it is on a disk that has failed in a bad way, or on a NFS server that has been permanently shut down) and you want the system to just ignore the problem and shut down as quickly as possible.
MK