Sponsored Content
Top Forums Shell Programming and Scripting How to replace value in fstab file? Post 303026259 by Corona688 on Thursday 22nd of November 2018 02:50:51 PM
Old 11-22-2018
Scripting changes to vital system files is very, very dangerous. Be sure you have a plan B in case that goes badly.

If I had to, I'd be paranoid and verify every part of the line.

Code:
awk '(NF==6)&&($1=="/dev/VolGroup00/tmp")&&($2=="/tmp")&&($3=="ext3")&&($4=="defaults"){ print $1,$2,$3,$4,1,1; next } 1' /etc/fstab > /tmp/fstab
# Uncomment once you've tested and are sure /tmp/fstab is what you want it to be.
# use cat, not mv, because mv may change permissions and ownership
# cat /tmp/fstab > /etc/fstab
rm -f /tmp/fstab


Last edited by Corona688; 11-22-2018 at 04:13 PM..
 

10 More Discussions You Might Find Interesting

1. Linux

/etc/fstab

I've created a new drive and i've added it to my fstab file but on startup it will not mount. here is how i put it into my fstab file, is that right? /dev/hdb2 /disk2a ext3 defaults 1 2 (6 Replies)
Discussion started by: byblyk
6 Replies

2. UNIX for Dummies Questions & Answers

fstab question

Folks; Please be patient with this issue when you read it. I know it's a little tricky. I have a new share created on my SUSE 10 box. I'm trying to edit the /etc/fstab file or find a way to make this share needs no authentication. The reason for that is we're using an outside application to... (3 Replies)
Discussion started by: Katkota
3 Replies

3. UNIX for Dummies Questions & Answers

FSTAB Problem

Hello, I transferred a machine from a tape back into a virtual machine. I created several paritions so I could xfter the date into them and made sda1 the active one. When I try and boot the VM it does not work. I used KNOPPIX to create the partitions and transfer the information from the tape... (1 Reply)
Discussion started by: mojoman
1 Replies

4. Red Hat

edit/write the /etc/fstab file

Hi, I comment out some vol group in fstab accidentally. I also comment the swap space in /etc/fstab But I cannot edit /remove it back by using vi /etc/fstab again in init 1 and init 6 . The file system /etc/fstab is read -only . I cannot chmod ..... What can I do in order to recover it ... (2 Replies)
Discussion started by: chuikingman
2 Replies

5. UNIX for Dummies Questions & Answers

fstab

hi , i'm creating a shell script using fstab for my project of last year, i wonder you can help me to know what is the command allow me to get the list of unmounted partitions. thanks (4 Replies)
Discussion started by: Linux001
4 Replies

6. Ubuntu

fstab question

I have created a thumbdrive with a bootable version of Ubuntu 10.04 LTS, it uses Grub legacy. One of the issues I have is that everytime I boot a new system from the thumbdrive, it writes entries for the partitions in the fstab. Consequently, when I boot another system, the OS reads the fstab... (2 Replies)
Discussion started by: stumpyuk
2 Replies

7. Red Hat

Effects of /etc/fstab file!

Hi Folks! I accidentally overwrote in /etc/fstab file. Can you guys please tell me, what impact it would have created, when I restarted the machine(RHEL6). I executed this command : # blkid /dev/vda5 > /etc/fstab (17 Replies)
Discussion started by: nixhead
17 Replies

8. Red Hat

Mount /etc/fstab

Can you please help me mount below filesystem in fstab ( I have rhel 5 ) as the line is long - it is not taking as single line How can break this in 2 line and act as one ....please help ... (4 Replies)
Discussion started by: saurabh84g
4 Replies

9. Linux

/etc/fstab entries

Hi, Can anyone explain why we use defaults 0 0 in fstab and what does 0 inidicate 10.250.104.50:/home/u /home/u nfs defaults 0 0 Thanks in advance Muzaffar (3 Replies)
Discussion started by: muzaffar.k
3 Replies

10. Ubuntu

Create zip file from root owned fstab

I want to zip up my fstab file for backup purposes. This does not work because of permission issues. cd /etc/ zip -u fstab.zip fstab Can I use this with zip? echo xxx | sudo -S or change fstab owner to me? (3 Replies)
Discussion started by: drew77
3 Replies
FSTAB(5)							File Formats Manual							  FSTAB(5)

NAME
fstab - static information about the filesystems SYNOPSIS
#include <fstab.h> DESCRIPTION
The file fstab contains descriptive information about the various file systems. fstab is only read by programs, and not written; it is the duty of the system administrator to properly create and maintain this file. Each filesystem is described on a separate line; fields on each line are separated by tabs or spaces. The order of records in fstab is important because fsck(8), mount(8), and umount(8) sequen- tially iterate through fstab doing their thing. The first field, fs_spec, describes the block special device or remote filesystem to be mounted. For filesystems of type ufs, the special file name is the block special file name, and not the character special file name. If a program needs the character special file name, the program must create it by appending a ``r'' after the last ``/'' in the special file name. The second field, fs_file, describes the mount point for the filesystem. For swap partitions, this field should be specified as ``none''. The third field, fs_vfstype, describes the type of the filesystem. The system currently supports only two types of filesystems: ufs a local UNIX filesystem swap a disk partition to be used for swapping The fourth field, fs_mntops, describes the mount options associated with the filesystem. It is formatted as a comma separated list of options. It contains at least the type of mount (see fs_type below) plus any additional options appropriate to the filesystem type. If the option ``quotas'' is specified, the filesystem is automatically processed by the quotacheck(8) command, and user disk quotas are enabled with quotaon(8). Filesystem quotas are maintained in the file named quotas located at the root of the associated filesystem. This restriction on the location of the quotas file is needlessly imposed by the kernel but may be lifted in the future. Thus, if the user quota file for /tmp is stored in /var/quotas/tmp.user, this location can be specified as: quotas=/var/quotas/tmp.user The type of the mount is extracted from the fs_mntops field and stored separately in the fs_type field (it is not deleted from the fs_mntops field). If fs_type is ``rw'' or ``ro'' then the filesystem whose name is given in the fs_file field is normally mounted read- write or read-only on the specified special file. If fs_type is ``sw'' then the special file is made available as a piece of swap space by the swapon(8) command at the end of the system reboot procedure. The fields other than fs_spec and fs_type are unused. If fs_type is specified as ``xx'' the entry is ignored. This is useful to show disk partitions which are currently unused. The fifth field, fs_freq, is used for these filesystems by the dump(8) command to determine which filesystems need to be dumped. If the fifth field is not present, a value of zero is returned and dump(8) will assume that the filesystem does not need to be dumped. The sixth field, fs_passno, is used by the fsck(8) program to determine the order in which filesystem checks are done at reboot time. The root filesystem should be specified with a fs_passno of 1, and other filesystems should have a fs_passno of 2. Filesystems within a drive will be checked sequentially, but filesystems on different drives will be checked at the same time to utilize parallelism available in the hardware. If the sixth field is not present or zero, a value of zero is returned and fsck(8) will assume that the filesystem does not need to be checked. #define FSTAB_RW "rw" /* read-write device */ #define FSTAB_RO "ro" /* read-only device */ #define FSTAB_SW "sw" /* swap device */ #define FSTAB_XX "xx" /* ignore totally */ struct fstab { char *fs_spec; /* block special device name */ char *fs_file; /* filesystem path prefix */ char *fs_vfstype; /* type of filesystem */ char *fs_mntops; /* comma separated mount options */ char *fs_type; /* rw, ro, sw, or xx */ int fs_freq; /* dump frequency, in days */ int fs_passno; /* pass number on parallel dump */ }; The proper way to read records from fstab is to use the routines getfsent(3), getfsspec(3), getfstype(3), and getfsfile(3). FILES
/etc/fstab The file fstab resides in /etc. SEE ALSO
getfsent(3) HISTORY
The fstab file format appeared in 4.0BSD. 4.4 Berkeley Distribution January 15, 1996 FSTAB(5)
All times are GMT -4. The time now is 08:43 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy