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

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

Fix UUID support which was still broken.
Caveat: It can't work for swap partitions as there is no mksap -U option contrary to the -L option for LABEL
So at reboot you won't have swap activated and you'll have to run vol_id -u the_swap_partition to fix your /etc/fstab file

  • Property svn:keywords set to Id
  • Property svn:unix-mode set to 755
File size: 2.0 KB
Line 
1#!/bin/sh
2#
3# $Id: label-partitions-as-necessary 1755 2007-10-31 00:11:44Z bruno $
4#
5############################################
6
7
8read_partition_line() {
9 local label mountpt command format
10
11 label=`echo "$1" | awk '{print $1}' | cut -d'=' -f2`
12 format=`echo "$1" | awk '{print $3}'`
13 mountpt=`awk '{print $1,$5}' $mountlist | grep " $label$" | awk '{print $1}'`
14
15 if [ "`echo "$1" | grep -E 'LABEL='`" != "" ] ; then
16 opttun="-L"
17 elif [ "`echo "$1" | grep -E 'UUID='`" != "" ] ; then
18 opttun="-U"
19 else
20 # Nothing to do
21 return
22 fi
23
24 if [ ! "$mountpt" ] ; then
25 LogIt "Not labeling anything as ($label) because ($mountpt) is not a mountpoint"
26 elif [ ! "$label" ] ; then
27 LogIt "Not labeling ($mountpt) as anything because ($label) is not a label"
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
35 echo "Unable yet to identify swap with UUID"
36 echo "You'll have to modify your /etc/fstab after reboot"
37 echo "Replace the UUID found on the swap line by the one"
38 echo "given by the command vol_id -u $mountpt"
39 echo "And ask Ubuntu guys to deliver a mswap command with"
40 echo "a -U option to update the UUID to what we want !!!"
41
42 sleep 5
43 else
44 command="mkswap $opttun $label $mountpt"
45 LogIt "Running $command"
46 $command
47 fi
48 else
49 LogIt "I am NOT going to run tune2fs: the partition is format '$format', which doesn't like tune2fs anyway"
50 fi
51 fi
52}
53
54
55# ---------------------------------------------
56
57LogIt "Identifying your drives with tune2fs"
58if [ "$#" -ne "1" ] ; then
59 LogIt "label-partitions-as-necessary /tmp/mountlist.txt < /tmp/fstab.new" 1
60 exit 1
61fi
62mountlist=$1
63noof_blank_lines=0
64read line
65while [ "$line" != "" ] && [ "$noof_blank_lines" -le "5" ] ; do
66 if [ "$line" = "" ] ; then
67 noof_blank_lines=$(($noof_blank_lines+1))
68 else
69 noof_blank_lines=0
70 read_partition_line "$line"
71 fi
72 read line
73done
74LogIt "Labeling complete."
75exit 0
Note: See TracBrowser for help on using the repository browser.