UUID confusion revisited
SYNass IT Ubuntu / Linux
i-ubux at synass.net
Tue Mar 25 00:39:32 UTC 2008
On Mon, 2008-03-24 at 17:09 -0700, NoOp wrote:
> On 03/24/2008 04:34 PM, SYNass IT Ubuntu / Linux wrote:
> > On Mon, 2008-03-24 at 14:25 -0700, NoOp wrote:
> >> On 03/21/2008 06:53 AM, JosephK wrote:
> >> > Following the recent posts regarding UUIDs I thought I'd take a look at
> >> > mine as I'm forever installing and deleting different Linux distros. I
> >> > have 3 drives with Gutsy on sda as my main distro for the moment.
> >> > However, if I instal another distro on sdb or sdc and after a few months
> >> > use I decide I like it then it may be that my main distro is on sdc and
> >> > at a later date sda could house something else.
> >> >
> >> > The upshot of this is that when I checked my /etc/fstab against
> >> > /dev/disk/by-uuid I found that none of the 3 swap partitions (one on
> >> > each drive) were labelled correctly so I was using no swap space.
> >> >
> >> > I've knocked together a quick script to compare the UUIDs in
> >> > /dev/disk/by-uuid with the mounted disks in /etc/fstab. If it of any use
> >> > to you please feel free to use, modify or what you will. Any
> >> > constructive criticism is welcomed as I am just starting to learn bash
> >> > shell scripting.
> >> >
> >> > #!/bin/sh
> >> >
> >> > ls -l /dev/disk/by-uuid/ |\
> >> > awk '{print $10, "UUID="$8}' | sort |\
> >> > awk -F"/" '{print $3}' > drives.tmp
> >> >
> >> > cat /etc/fstab |\
> >> > sed -e '/.*\/dev.*$/N;s/\n */ /' |\
> >> > sed -e 's;^# *;;' |\
> >> > sed -e 's/\(^\/dev\/[a-z0-9]* UUID=[a-z0-9]\{8\}-[a-z0-9]\{4\}-[a-z0-9]\{4\}-[a-z0-9]\{4\}-[a-z0-9]\{12\}\).*/\1/' |\
> >> > sed -e '/^\/dev\/.*UUID.*/!d' |\
> >> > sed -e 's/^\/dev\///' > mounts.tmp
> >> >
> >> > join -a 1 drives.tmp mounts.tmp
> >> >
> >> >
> >>
> >> Cool! I just saved as uuidcompare and:
> >>
> >> sh uuidcomare
> >>
> >> Works great, thanks.
> >>
> >> Thanks
> >
> > Hi Joseph and NoOp
> > Your topic and script interests me too !
> >
> > The topic:
> > As a newbie I am preparing my Ubuntu 8.04 LTS to be better than my first
> > installation.
> > Thinking of 2 Ubuntu's (one PROD & the other TEST) with sharing the
> > common data i.e. /BOOT, /HOME and SWAP !?
> >
> > Your recommendations / suggestions and warnings are very appreciated !
> >
> > The script:
> > As newbie I am struggling with these helpful commands and scripts and
> > would like to understand better how to save a script like yours !
> >
> > I have already saved it as UUIDcomp on desktop and checked for /bin/sh
> > location
> > assuming that sh is a folder under bin !? I seem to be wrong !!
> >
> > Can you help me little better ? ;-)
> >
> > TIA and cheers, svobi
> >
> >
>
> Open the text editor (gedit)
> Copy & paste the script into the new file
> Save as uuidcompare (or whatever you want to name it) into one of
> your home folders. Exit the text editor.
OK, this I had already done ! ;-)
> Open a terminal
> cd to the folder where you saved it
> issue the shell command:
> sh <uuidcompare/name>
OK, this I had already done too !! ;-))
As from Desktop it works, cool !!! ;-D
> sh is the shell command, info (in terminal window) is:
>
> man sh
OK & yes !
But normally to where are you place these own scripts ?
Just into "/bin" ?? or into an extra folder i.e. /bin/scripts ???
I assume you as experienced old foxes are having some tips and tricks
for am Linux / Ubuntu newbie ! ;-)
Thanks and cheers, svobi
PS:
My version of the script got some little modifications already:
I named it "UUIDcomp" and the two tmp outputs were renamed to
UUID_drives.tmp & UUID_mounts.tmp !!
How can i displayed i.e. ymmdd_hhmmss instead of "tmp" ???
More information about the ubuntu-users
mailing list