Unmount files via script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Unmount files via script
# 1  
Old 08-07-2014
Unmount files via script

Hi all,

I have a requirement to do an upgrade. As part of that upgrade I have to unmounts files in the fstab (there could be 100's), is there a way I can do this via script? The problem is, is that the mount points on every server will be different....
For example:
Code:
/u001/oradata/T865   
/u003/oradata/T865    
/u004/oradata/T865    
/a001/oradata/T865    
/a002/oradata/T865    
/u005/oradata/T865    
/u006/oradata/T865    
/u007/oradata/T865    
/u008/oradata/T865    
/w001/oradata/T865    
 


On the next server they will be totally different..

thanks in advance




Moderator's Comments:
Mod Comment Please use code tags next time for your code and data. Thanks

Last edited by vbe; 08-07-2014 at 12:41 PM..
# 2  
Old 08-07-2014
Will these partitions be in use?
# 3  
Old 08-07-2014
Would following work?
Code:
# umount -a

But there might be a problem though, see Corona688's input.
One could probably force the unmount, don't know if this is a good idea.

HTH
# 4  
Old 08-07-2014
If they're not in use, you could try the shotgun approach: umount /u001/oradata/T* It won't hurt things which aren't mounted or were never mounted, though it may complain a bunch.
# 5  
Old 08-11-2014
I suppose you could use df to generate a listing, grab the records you are interested in and then un-mount the ones found. You might have to adjust for the number of columns you get from df in the cut -f7 column, but consider the following:-
Code:
df | tr -s " " |cut -f7 -d " " | grep "^/u001/oradata" | sort -r | while read fs
do
   umount $fs
done

What I've suggested strips out multiple spaces and then get's the seventh column (according to my df format) and sorts them in reverse so any sub-mounted filesystems are removed first.


I hope that this helps.

Robin
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

Filesystem unable unmount

Hi all , I have issue oracle filesystem name /oracle/SID unable to unmount even though no any process are running mentioned fs .would appreciate anyone assist further high level .my system running aix 6.1 (7 Replies)
Discussion started by: Arulji
7 Replies

2. Shell Programming and Scripting

Script to unmount and mount by UUID

Hi, Need a bit of help on this one as I am a scripting noob. I have a linux based NAS that mounts USB hard drives in an inconsistent location and to make matters worse, seems to lose the mount for an unknown reason and doesn't remount automatically unless the drive is removed and re-inserted.... (4 Replies)
Discussion started by: gtr33m
4 Replies

3. Shell Programming and Scripting

Cygwin bash script to unmount and mount an XP partition

As stated, I am looking into keeping my backup drive unmounted in normal windows use. Partly this is to address threats like cryptolocker. Since one of my backup drives is an internal drive, it will not likely afford any protection from such a threat. I am thinking of adding code to my rsync script... (5 Replies)
Discussion started by: LMHmedchem
5 Replies

4. Solaris

zfs cannot unmount (cannot unshare)

I have installed Solaris 11 Express on my machine, created a raidz2 zpool named shares and set up sharing (zfs set sharesmb=on shares). I also created a script for automatic backuping using snapshots. Everything worked fine. But yesterday I tried recovering from one of those backuped snapshots:... (1 Reply)
Discussion started by: RychnD
1 Replies

5. UNIX for Dummies Questions & Answers

unmount the partition

Dear all, I have a two hard drive.On the second (/dev/sdb1 and /dev/sdb2) hard drive i have two partitions. The /dev/sdb2 has been mounted on the /home2 directory.I want to unmount that /dev/sdb2.I have no idea to how to do it.Can anybody give me the details about that?. Regards, Prakashkumar.S (2 Replies)
Discussion started by: prakashkumar41
2 Replies

6. Filesystems, Disks and Memory

Can we unmount device?

Hi, I know that if we need to unmount a device, we use the command umount mount-point, example 'umount /tmp/mount1' But We can also unmount the device with device name example 'umount /dev/hda6'. NOTE: I think in RHEL3 we cannot unmount with device name. Correct me if I am wrong. What... (1 Reply)
Discussion started by: praveen_b744
1 Replies

7. AIX

Unmount strongly command

Dear Guy's I'm making script to easier my work to mount and unmount some file systems I'm executing this command umount -f /file_system To unmount the file system but some times is not allow the un mounting it's giving me device is busy ... I want to know is there any another... (2 Replies)
Discussion started by: ITHelper
2 Replies

8. HP-UX

/opt will not unmount to extendfs

The /opt file system needs to be extended. I know the basic commands, but /opt will not unmount. fuser shows nothing and I see no jobs running from /opt. If I need to take it down to single user mode to do this, then what is the best command? Any help is appreciated. Is there a way to stop all... (3 Replies)
Discussion started by: joettacm
3 Replies

9. AIX

how do i unmount ?

hi all, I am new to AIX as well as UNIX also ,i have a question One of my program has created a new filesystem on the system..... df shows : /dev/fslv04 2031616 2030648 1% 3 1% /replicas/source when i tried to umount the above filesystem by umount... (3 Replies)
Discussion started by: vamshi_k
3 Replies

10. Filesystems, Disks and Memory

[FreeBSD] Unable to unmount

I have mounted an ISO-file to do a network install of Red Hat. Afterwards, I removed the ISO and forgot about the mount. Now, I am unable to unmount this mount, because the target no longer exists... Here's the error I get when I try to unmount: Even if I put all the files back and... (6 Replies)
Discussion started by: indo1144
6 Replies
Login or Register to Ask a Question