- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: need script to umount filesystems from an arra...
Operating System - Linux
1752579
Members
2935
Online
108788
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-12-2006 02:44 AM
тАО10-12-2006 02:44 AM
Environment and situation: Disaster Recovery server is a clone of Production server. Certain logical volumes can not be mounted on the DR server while production server is up (or it will interfere with the databases). In a DR situation, the volumes will be mounted. I am creating a script to unmount the file systems at the end of a DR situation (when the original production box would be brought back online).
The script: I have created a text file with the file systems which will need unmounted. I've started a script which will put the text file in an array.
FS_CONF="/opt/sysadmin/etc/umountlist.conf"
# build array from conf file
FS[@]=`cat $FS_CONF`
I'm having trouble figuring out how to process each array variable in a umount command and moving to the next one and ending at the eof. Any ideas on how to write this part of the script?
~T
The script: I have created a text file with the file systems which will need unmounted. I've started a script which will put the text file in an array.
FS_CONF="/opt/sysadmin/etc/umountlist.conf"
# build array from conf file
FS[@]=`cat $FS_CONF`
I'm having trouble figuring out how to process each array variable in a umount command and moving to the next one and ending at the eof. Any ideas on how to write this part of the script?
~T
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-12-2006 02:49 AM
тАО10-12-2006 02:49 AM
Solution
Assuming that the config file is just a list of mountpoints (or source devicefiles):
FS_CONF="/opt/sysadmin/etc/umountlist.conf"
# build array from conf file
cat $FS_CONF | while read MNT EXTRA
do
umount $MNT
if [ $? -ne 0 ]
then
echo "\numount failed for $MNT"
fi
done
The error message is printed when umount fails. The EXTRA variable is to take care of anything trailing the first item in the line. Otherwise, everything on the line goes into $MNT
Bill Hassell, sysadmin
FS_CONF="/opt/sysadmin/etc/umountlist.conf"
# build array from conf file
cat $FS_CONF | while read MNT EXTRA
do
umount $MNT
if [ $? -ne 0 ]
then
echo "\numount failed for $MNT"
fi
done
The error message is printed when umount fails. The EXTRA variable is to take care of anything trailing the first item in the line. Otherwise, everything on the line goes into $MNT
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-12-2006 02:51 AM
тАО10-12-2006 02:51 AM
Re: need script to umount filesystems from an array
Hi:
If your file simply contains the mountpoint names, why not simply read it and perform your unmount? For example:
#!/usr/bin/sh
while read X MNTPT X
do
echo ${MNTPT}
done < /etc/fstab
...change the 'echo' appropriately.
Regards!
...JRF...
If your file simply contains the mountpoint names, why not simply read it and perform your unmount? For example:
#!/usr/bin/sh
while read X MNTPT X
do
echo ${MNTPT}
done < /etc/fstab
...change the 'echo' appropriately.
Regards!
...JRF...
- Tags:
- while loop
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-12-2006 03:04 AM
тАО10-12-2006 03:04 AM
Re: need script to umount filesystems from an array
no array needed. thanks for the quick and accurate responses.
~TZ
~TZ
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP