we need to add disks on more then 100 redhat machines,

therefore we need to update also the /etc/fstab on each machine

the problem is that some machines configured with UUID and other with ordinary dev in fstab

so I want to make a bash script that will identify the fstab configuration as the following

  1. in case fstab configured with UUID add new UUID lines for each additional disk
  2. in case fstab configured with ordinary dev then add new dev lines for each additional disk

so my question is - what is the best approach to identify what configured in fstab UUID or ordinary dev ?

remark - not include the OS , we talk here only on additional disks in HW machines

here is example of linux machine with UUID conf in fstab

/dev/mapper/vg00-loov_root /                    xfs     defaults      00 
UUID=7de1dc5c-b605-4a6f-bdf1-f1e869f6ffb9 /boot                   xfs     
defaults        0 0
/dev/mapper/vg00-loov_var /var                    xfs     defaults       00 
/dev/mapper/vg00-loov_swap swap                    swap    defaults      00 
UUID="fcb73644-4ad3-4b19-85f8-dbb9ed53a871"   /data/sdb                       
ext4 defaults,noatime 0 0
UUID="5f56c1d6-266f-4ea2-a8f7-df06f08e01c0"   /data/sdc                       
ext4 defaults,noatime 0 0
UUID="4c908671-4045-41e8-a396-a5198978e3ac"   /data/sdd                       
ext4 defaults,noatime 0 0
UUID="d44fe62a-72dc-4674-91ac-5a1962797e22"   /data/sde                       
ext4 defaults,noatime 0 0
UUID="ee3d8fa8-e000-4abb-a26c-da99499e630c"   /data/sdf                       
ext4 defaults,noatime 0 0
UUID="61e9e16f-eb49-4c97-aaf0-0ed2dc3f3007"   /data/sdg                       
ext4 defaults,noatime 0 0
UUID="ada12394-0e0b-4657-a148-d85548d7bc75"   /data/sdh                       
ext4 defaults,noatime 0 0
  • Why is it a problem that some systems do not use UUIDs yet? Is that anyhow an argument against UUIDs for the new disks? – Hauke Laging Jan 4 '18 at 0:22
  • 3
    If you already have 100 machines that have inconsistent configuration styles then you have a bigger problem to solve first. You need to look into using something like puppet or ansible – cas Jan 4 '18 at 1:58
  • what we want is to do the same conf on fstab I mean that if machine have UUID then need to insert UUID lines if machine have ordinary dev lines then need to insert DEV ordinary lines to fstan , all this to avoid mishmash on fstab file , it will not be good if fstab file will include both configuration isnt it? – yael Jan 4 '18 at 5:47

You may have to define more precisely what counts as UUID configuration.

If it is enough that a single volume is mounted via UUID then you can simply use

if grep -q '^\s*UUID=' /etc/fstab; then
| improve this answer | |
  • not good , because in some linux machines the disk sda ( OS ) is with UUID , while other disks in machine are isn't – yael Jan 4 '18 at 5:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.