- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- how to add fstab entry using script
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Forums
Discussions
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
Discussion Boards
Community
Resources
Forums
Blogs
- 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
тАО08-05-2008 10:47 PM
тАО08-05-2008 10:47 PM
how to add fstab entry using script
would like to seek your advice. ive created few file systems. but sir, how can i create script so that i can add the entry inside fstab using .ksh script. hope to hear from you. appreciate your can share any advice to perform system administration faster. many thanks in advance. Thank You.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-05-2008 11:15 PM
тАО08-05-2008 11:15 PM
Re: how to add fstab entry using script
Just copy the format of existing lines.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-06-2008 12:46 AM
тАО08-06-2008 12:46 AM
Re: how to add fstab entry using script
yest makes sence on what is said because you are not going to create filesystems regularly.
Just edit the /etc/fstab file through vi editor and place the entries required
ie :
/dev/vgname/lvol1 /mountpoint vxfs delaylog 0 3
/dev/vgname/lvol1 /mountpoint vxfs delaylog 0 2
/dev/vgclnpdb/lvol1 /mountpoint vxfs delaylog 0 1 .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-06-2008 01:23 AM
тАО08-06-2008 01:23 AM
Re: how to add fstab entry using script
Please have the attached file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-06-2008 03:47 AM
тАО08-06-2008 03:47 AM
Re: how to add fstab entry using script
Learn to use 'vi'.
If you have need to programatically add entries to '/etc/fstab' all that is needed is something like this, at a shell command line:
# echo "/dev/vg02/lvol1 /patches vxfs rw,suid,largefiles,delaylog,datainlog 0 2" >> /etc/fstab
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-06-2008 04:16 AM
тАО08-06-2008 04:16 AM
Re: how to add fstab entry using script
So go for using vi editor only.
Thanks
SKR
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-06-2008 05:43 AM
тАО08-06-2008 05:43 AM
Re: how to add fstab entry using script
Even through you can use following in script:
#cp -p /etc/fstab /etc/fstab.bak
# echo "/dev/vg02/logical volume /mount point vxfs rw,suid,largefiles,delaylog,datainlog 0 2" >> /etc/fstab
#diff /etc/fstab /etc/fstab.bak
but using VI directly is always better option.
Cheers!!
Deepak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-06-2008 10:32 AM
тАО08-06-2008 10:32 AM
Re: how to add fstab entry using script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-06-2008 01:59 PM
тАО08-06-2008 01:59 PM
Re: how to add fstab entry using script
/dev/fd0 /media/floppy auto rw,noauto,user,sync 0 0
I always prefer vi.. to make life simpler
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-18-2008 06:22 AM
тАО08-18-2008 06:22 AM
Re: how to add fstab entry using script
When I have to add several equal directories (for example nfs-mounted) to several workstations, I use a script.
My sh-script contains:
cat
mkdir
mount -a
bdf
my
You can add several lines without problems.
For an internal dir you should use:
/dev/vg01/lvol6 /archiv vxfs rw,suid,largefiles,delaylog,datainlog 0 2
HTH
Volkmar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-18-2008 08:28 AM
тАО08-18-2008 08:28 AM
Re: how to add fstab entry using script
>mkdir
>mount -a
>bdf
How do these commands help????
why would somebdy want to do this kind of thing?
Why won't you just vi /etc/fstab and type whatever you typed in
One scenario I can think where you need a script to append to /etc/fstab is:
you have a script which creates multiple filesystems. ( I wrote a script while preparing a setup with 1000+ mounted filesystems).
The script will these tasks:
1) create a LV ( append a number after each LV name and go on incrementing the number each time)
2) mkfs
3) create mount point ( with the number appended)
4) mount the newly created FS
5) add entry in /etc/fstab so that the mounts are done during a reboot.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-18-2008 08:40 AM
тАО08-18-2008 08:40 AM
Re: how to add fstab entry using script
I would add that whenever you add lines to /etc/fstab, sanitize them first by using "mount -V". You could also test their syntax by trying to mount the new entries by using the mountpoint only such as "mount /newdir".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-18-2008 11:02 AM
тАО08-18-2008 11:02 AM
Re: how to add fstab entry using script
While editing the fstab file is an option, I'm not sure we can say it's always preferable. Occasionally, I'm tasked with generating a new system that looks like an old system - migration, update, etc. Some of these source systems have hundreds of filesystems that are changed by one or two characters from their source counterparts. This is something that just begs for a script.
If, however, you're not facing something like this, you probably want to edit the fstab file. Relying on script will limit an admin's growth potential.
The scripts that I use, generally inline, all use a datafile. The datafile will look like:
${vg} ${lv} ${mp}|${owner}
For example:
vgSAP sapmnt 2048 /sapmnt/INST
vgsap oracle 4096 /oracle
vgsapdata ora_data1 8192 oraINST:dba
The logic is fairly straight forward - which is why this tends to be rewritten on the fly all the time:
cat ${table} | while read vg lv size mp
do
echo "############################"
printf "%-20s %-35s %8d %s\n" ${vg} ${lv} ${size} ${mp}
lvcreate -L ${size} -n ${lv} ${vg}
echo ${mp} | grep ":" > /dev/null 2>&1
if [ $? -ne 0 ]
then
[[ ${size} -gt 2048 ]] && args="-o largefiles" || args=""
newfs -F vxfs ${args} /dev/${vg}/r${lv}
[[ ! -d ${mp} ]] && mkdir -p -m 755 ${mp}
[[ ${size} -gt 2048 ]] && args=",largefiles" || args=""
echo "/dev/${vg}/${lv} ${mp} vxfs delaylog${args} 0 2" >> /etc/fstab
mount ${mp}
else
chown ${owner} /dev/${vg}/r${lv}
fi
done
Doing something like this makes a complete filesystem reorg take minutes vs hours if doing by hand or days if doing by sam.
On more than one occasion, scripts like this have made DR exercises succesful where they otherwise would have failed.
Doug
------
Senior UNIX Admin
O'Leary Computers Inc
linkedin: http://www.linkedin.com/dkoleary
Resume: http://www.olearycomputers.com/resume.html