Sponsored Content
Top Forums Shell Programming and Scripting Help with UUID replacement in fstab and menu.lst Post 302512031 by mirni on Friday 8th of April 2011 08:03:16 AM
Old 04-08-2011
Something like this..
Code:
miro@miro-ntb:Downloads$ cat partlist.txt 
/dev/sda1 "f75b104c-678e-4f80-a618-70d4bf4a3ede" /
/dev/sda3 "hsjsd675-678e-4f80-a618-70d4bf4a3ede" /home
/dev/sda2 "psb8767c-678e-4f80-a618-70d4bf4a3ede" /boot

Code:
miro@miro-ntb:Downloads$ cat fstab.txt 
#
# /etc/fstab
# Created by anaconda on Mon Feb 14 16:03:26 2011
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/VolGroup-lv_root /                       ext4    defaults        1 1
UUID=10cb97f9-e52e-472b-a20b-c1e90c6d561b /boot                   ext4    defaults        1 2
/dev/mapper/VolGroup-lv_swap swap                    swap    defaults        0 0
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
HHH     /home  smthn defs 0 0

Code:
miro@miro-ntb:Downloads$ awk '
NR==FNR{a[$3]=$2; next} #store uuids in assoc. array
{ #on each line from fstab
for(i in a) { #loop through array
  if($2==i)  #check whether mountpoint is the same
  {$1="UUID=" a[i]} #replace 1st field with UUID=uuid
}; 
print $0;  #print the whole line
}
' <(sed -e 's/\r//' -e 's/"//g' partlist.txt) fstab.txt  

#
# /etc/fstab
# Created by anaconda on Mon Feb 14 16:03:26 2011
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=f75b104c-678e-4f80-a618-70d4bf4a3ede / ext4 defaults 1 1
UUID=psb8767c-678e-4f80-a618-70d4bf4a3ede /boot ext4 defaults 1 2
/dev/mapper/VolGroup-lv_swap swap                    swap    defaults        0 0
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
UUID=hsjsd675-678e-4f80-a618-70d4bf4a3ede /home smthn defs 0 0

The sed command gets rid of carriage return and quotes.
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

menu.lst, boot options?

Hi all, I would like to have some details on menu.lst!! the reason is ,if i am trying to add my own boot option where do i need to add it? is it in menu.lst only or elsewere(am referring to unix os) because i tried adding a unique boot option and it was not reflected when the system booted?... (8 Replies)
Discussion started by: wrapster
8 Replies

2. Shell Programming and Scripting

shell script to alter grub menu.lst

Hi folks, I have a dual-boot Ubuntu/Windows machine and I wanted to create a script to change the menu.lst file so it will change the default boot partition (this is so I can reload the machine remotely and allow it to boot to the Windows partition). Today I have to sudo cp a template file I... (1 Reply)
Discussion started by: ppucci
1 Replies

3. UNIX for Advanced & Expert Users

Generate UUID for a host

Hello Experts, Is there a way to generate Universally Unique identifiers on all Unix flavours such as Solaris, RHELinux,Suse Linux, MacOS,HP UX etc? If i can get a system command or a system call or an algorithm/script/program to generate a unique identifier, it will be helpful. Thanks in... (1 Reply)
Discussion started by: GajendraSharma
1 Replies

4. SuSE

Need to edit the menu.lst so it can work

I am trying to install three OS (Windows VISTA, OpenSUSE 11.3 & Solaris 11 Express) on a single drive of a laptop. However when I go to edit the /rpool/boot/grub/menu.lst to put the entry so it can boot the OpenSUSE 11.3 I get errors some of which result into starting all over again. I have also... (0 Replies)
Discussion started by: Tenyhwa
0 Replies

5. Solaris

Need to create a menu.lst for Solaris 11 Express, OpenSUSE 11.3 & Windows Vista

I have partitioned and installed Windows Vista, OpenSUSE and Solaris 11 Express on a LapTop hardDrive. However I am not able to boot OpenSUSE 11.3 although I have it in menu.lst which I put in a Solaris partition directory /rpool/boot/grub. Could someone tell me how to go about it. See what I did... (2 Replies)
Discussion started by: Tenyhwa
2 Replies

6. Boot Loaders

Help Me edit the menu.lst !

I am trying to install three OS (Windows VISTA, OpenSUSE 11.3 & Solaris 11 Express) on a single drive of a laptop. However when I go to edit the /rpool/boot/grub/menu.lst to put the entry so it can boot the OpenSUSE 11.3 I get errors some of which result into starting all over again. I have also... (3 Replies)
Discussion started by: Tenyhwa
3 Replies

7. UNIX for Dummies Questions & Answers

Missing menu.lst file in Ubuntu

I am not able to find menu.lst in /boot. During the Linux Kernel Compilation I installed the kernel using make install. Next I created an initrd image. I had to modify the Grub configuration file - /boot/grub/menu.lst which I am not able to find. Any resolution for the issue? (3 Replies)
Discussion started by: rupeshkp728
3 Replies

8. 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

9. BSD

Find Partition/Slice UUID

I thought I had figured this out at one point, but I can't remember. Is there a way/command to get the UUIDs of a disk's partitions/slices in FreeBSD? Linux has the blkid command, which doesn't seem to be available. (2 Replies)
Discussion started by: AntumDeluge
2 Replies
FSTAB(5)							   File Formats 							  FSTAB(5)

NAME
fstab - static information about the filesystems SYNOPSIS
/etc/fstab 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. Lines starting with '#' are comments, blank lines are ignored. The order of records in fstab is important because fsck(8), mount(8), and umount(8) sequentially iterate through fstab doing their thing. The first field (fs_spec). This field describes the block special device or remote filesystem to be mounted. For ordinary mounts it will hold (a link to) a block special device node (as created by mknod(8)) for the device to be mounted, like `/dev/cdrom' or `/dev/sdb7'. For NFS mounts one will have <host>:<dir>, e.g., `knuth.aeb.nl:/'. For procfs, use `proc'. Instead of giving the device explicitly, one may indicate the filesystem that is to be mounted by its UUID or LABEL (cf. e2label(8) or xfs_admin(8)), writing LABEL=<label> or UUID=<uuid>, e.g., `LABEL=Boot' or `UUID=3e6be9de-8139-11d1-9106-a43f08d823a6'. It's also possible to use PARTUUID= and PARTLABEL=. These partitions identifiers are supported for GUID Partition Table (GPT) and MAC partition table only. See blkid(8) or lsblk(8) for more details about devices identifiers. Note that mount(8) uses UUIDs as strings. The string representation of the UUID should be based on lower case characters. The second field (fs_file). This field describes the mount point for the filesystem. For swap partitions, this field should be specified as `none'. If the name of the mount point contains spaces these can be escaped as `40'. The third field (fs_vfstype). This field describes the type of the filesystem. Linux supports lots of filesystem types, such as adfs, affs, autofs, coda, coher- ent, cramfs, devpts, efs, ext2, ext3, hfs, hpfs, iso9660, jfs, minix, msdos, ncpfs, nfs, ntfs, proc, qnx4, reiserfs, romfs, smbfs, sysv, tmpfs, udf, ufs, umsdos, vfat, xenix, xfs, and possibly others. For more details, see mount(8). For the filesystems currently supported by the running kernel, see /proc/filesystems. An entry swap denotes a file or partition to be used for swapping, cf. swapon(8). An entry none is useful for bind or move mounts. mount(8) and umount(8) support filesystem subtypes. The subtype is defined by '.subtype' suffix. For example 'fuse.sshfs'. It's recommended to use subtype notation rather than add any prefix to the first fstab field (for example 'sshfs#example.com' is depre- cated). The fourth field (fs_mntops). This field 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 plus any additional options appropri- ate to the filesystem type. For documentation on the available mount options, see mount(8). For documentation on the available swap options, see swapon(8). Basic file system independent options are: defaults use default options: rw, suid, dev, exec, auto, nouser, and async. noauto do not mount when "mount -a" is given (e.g., at boot time) user allow a user to mount owner allow device owner to mount comment or x-<name> for use by fstab-maintaining programs nofail do not report errors for this device if it does not exist. The fifth field (fs_freq). This field 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 will assume that the filesystem does not need to be dumped. The sixth field (fs_passno). This field 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 will assume that the filesystem does not need to be checked. NOTES
The proper way to read records from fstab is to use the routines getmntent(3) or libmount. The keyword ignore as filesystem type (3rd field) is not more supported by the pure libmount based mount utility (since util-linux v2.22). FILES
/etc/fstab, <fstab.h> SEE ALSO
findmnt(8), mount(8), swapon(8), fs(5), getmntent(3) HISTORY
The ancestor of this fstab file format appeared in 4.0BSD. AVAILABILITY
This man page is part of the util-linux package and is available from ftp://ftp.kernel.org/pub/linux/utils/util-linux/. util-linux August 2010 FSTAB(5)
All times are GMT -4. The time now is 12:48 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy