source: MondoRescue/branches/2.2.5/mondo/src/restore-scripts/mondo/label-partitions-as-necessary@ 1780

Last change on this file since 1780 was 1780, checked in by Bruno Cornec, 16 years ago

In udev case do not insert modules at all (udev should do it alone)
May avoid the issue with rhel4.5 kernel ? To be tested

  • Property svn:keywords set to Id
  • Property svn:unix-mode set to 755
File size: 1.8 KB
RevLine 
[1]1#!/bin/sh
2#
[901]3# $Id: label-partitions-as-necessary 1780 2007-11-09 19:34:53Z bruno $
[1]4#
5############################################
6
7
8read_partition_line() {
[1314]9 local label mountpt command format
[1295]10
[1314]11 label=`echo "$1" | awk '{print $1}' | cut -d'=' -f2`
12 format=`echo "$1" | awk '{print $3}'`
[1755]13 mountpt=`awk '{print $1,$5}' $mountlist | grep " $label$" | awk '{print $1}'`
[1314]14
15 if [ "`echo "$1" | grep -E 'LABEL='`" != "" ] ; then
[1295]16 opttun="-L"
[1314]17 elif [ "`echo "$1" | grep -E 'UUID='`" != "" ] ; then
[1295]18 opttun="-U"
19 else
20 # Nothing to do
21 return
[1314]22 fi
[1295]23
24 if [ ! "$mountpt" ] ; then
[1314]25 LogIt "Not labeling anything as ($label) because ($mountpt) is not a mountpoint"
[1295]26 elif [ ! "$label" ] ; then
[1314]27 LogIt "Not labeling ($mountpt) as anything because ($label) is not a label"
[1295]28 else
29 if [ "$format" = "ext2" ] || [ "$format" = "ext3" ] ; then
30 command="tune2fs $opttun $label $mountpt"
31 LogIt "Running $command"
32 $command
33 elif [ "$format" = "swap" ] ; then
34 if [ "$opttun" = "-U" ]; then
[1780]35 LogIt "Creating uuid $label on swap partition $mountpt"
[1766]36 echo -n "$label" | perl -ne 's/-//g;chomp;print pack "H*",$_' | dd conv=notrunc "of=$mountpt" obs=1 seek=1036
[1295]37 else
38 command="mkswap $opttun $label $mountpt"
39 LogIt "Running $command"
40 $command
41 fi
42 else
43 LogIt "I am NOT going to run tune2fs: the partition is format '$format', which doesn't like tune2fs anyway"
44 fi
[1]45 fi
46}
47
48
49# ---------------------------------------------
50
[1295]51LogIt "Identifying your drives with tune2fs"
[1]52if [ "$#" -ne "1" ] ; then
53 LogIt "label-partitions-as-necessary /tmp/mountlist.txt < /tmp/fstab.new" 1
54 exit 1
55fi
56mountlist=$1
57noof_blank_lines=0
58read line
59while [ "$line" != "" ] && [ "$noof_blank_lines" -le "5" ] ; do
60 if [ "$line" = "" ] ; then
[691]61 noof_blank_lines=$(($noof_blank_lines+1))
[1]62 else
[691]63 noof_blank_lines=0
64 read_partition_line "$line"
[1]65 fi
66 read line
67done
68LogIt "Labeling complete."
69exit 0
Note: See TracBrowser for help on using the repository browser.