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
FDISK(8)						      System Manager's Manual							  FDISK(8)

NAME
fdisk - partition a hard disk [IBM] SYNOPSIS
fdisk [-hm] [-sn] [file] OPTIONS
-h Number of disk heads is m -s Number of sectors per track is n EXAMPLES
fdisk /dev/hd0 # Examine disk partitions fdisk -h9 /dev/hd0 # Examine disk with 9 heads DESCRIPTION
When fdisk starts up, it reads in the partition table and displays it. It then presents a menu to allow the user to modify partitions, store the partition table on a file, or load it from a file. Partitions can be marked as MINIX, DOS or other, as well as active or not. Using fdisk is self-explanatory. However, be aware that repartitioning a disk will cause information on it to be lost. Rebooting the sys- tem immediately is mandatory after changing partition sizes and parameters. MINIX, XENIX, PC-IX, and MS-DOS all have different partition numbering schemes. Thus when using multiple systems on the same disk, be careful. Note that MINIX, unlike MS-DOS , cannot access the last sector in a partition with an odd number of sectors. The reason that odd partition sizes do not cause a problem with MS-DOS is that MS-DOS allocates disk space in units of 512-byte sectors, whereas MINIX uses 1K blocks. Fdisk has a variety of other features that can be seen by typing h. Fdisk normally knows the geometry of the device by asking the driver. You can use the -h and -s options to override the numbers found. SEE ALSO
part(8). FDISK(8)
All times are GMT -4. The time now is 05:33 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy