Quote:
Code:
dev=$(blkid | grep $d | awk 'BEGIN{FS=":"} {print $1}'); Code:
uuid=($(echo "$block_new" | awk 'BEGIN{RS="UUID="}/-/{gsub(/ .*/,"");print}')) |
Well I am curious, I am guessing it must be the way your machine is setup, but when I run blkid on the command line on its own
I get nothing returned. Also, I am not sure if the awk is perhaps required seeing as man of blkid says: Quote:
|
Pherhaps I understand right.
I run su or sudo then run blkid else it says blkid not found This operations under super user mode. blkid I use offten to get informations like dev,uuid and label blkid -U uuid searches the concrete device. I god output: uuid eab515e9-bc3e-4024-9f01-55fddaa0fb1c e12487ff-6d6f-44c4-9e03-33f545b3b798 not found That's right However I don't know how to make from e.g. /dev/sda3 the hd(0,2) ... Should I use awk to generate? Edit: But the last code I posted dosn't work right :-( It should to show: /dev/sda3 uuid e12487ff-6d6f-44c4-9e03-33f545b3b798 not found 1. contidion -z fail 2. the d var. is array not a string? Edit: Yeah the d var contains this sting or array eab515e9-bc3e-4024-9f01-55fddaa0fb1c e12487ff-6d6f-44c4-9e03-33f545b3b798 not separated... Bad too bad |
Thanks for the info, I too get results when using the sudo, but can use the -U option as normal user.
Yes it will return an array unless there is only one device attached (unlikely in modern systems) Another issue you might face may be if someone has a RAID/LVM setup (like mine) and the output is even less useful: Code:
grail@wetworks:~$ sudo blkid the string: Should be able to map a = 1, b = 2, ... So sda1 ... a = 1 and 1 - 1 = 0 therefore: hd1,0 |
Quote:
For the 2nd uuid of your list on 1st column it returns: /dev/mapper/isw_cehbidjbfj_RaidME2 So how this corresponds with your menu.lst if is this a system device? I ask about your menu.lst root=??? argument |
My menu.lst:
Code:
title Ubuntu 9.10, kernel 2.6.31-21-generic |
Grail,
I also have Ubuntu (9.04) and I have there default root=UUID=<uuid> We would just take your $1 column and giveit to root=<$1> place |
So what's the problem. Why this command doesn't get the separated uuid (one item)
Code:
for d in ${uuid[@]}; do 1. $d=>eab515e9-bc3e-4024-9f01-55fddaa0fb1c 2. $d=>e12487ff-6d6f-44c4-9e03-33f545b3b798 in the loop? |
You have echoed the wrong item .... change:
Code:
echo $uuid I was just thinking (sometimes this can be bad lol) you are going to a lot of trouble to alter an already unique identifier. Just wondering if this is the best course of action?? |
Sometimes it's good to use uuid, sometimes it's better to use hd(?,?)
Quote:
Code:
for d in ${uuid[@]}; do; clear; echo $d; read; done |
Now just to be sure, as i recently got caught out by someone else, you are using bash?
ie your code starts with: Code:
#!/bin/bash Code:
#!/bin/sh I have run the code below and am greeted with each line and waiting for enter key: Code:
#!/bin/bash |
Problem found with IFS. The block precluding
Code:
OLD_IFS=$IFS; IFS="|"; This is the block from my last thread. I just wonder why there is not IFS=$"|"; And why I don't see "|" on output when I run echo $IFS. It shows " " |
By default IFS is whitespace. If you run the following you will see what it is set to:
Code:
$>set | grep IFS a space or a tab or a new line. Therefore doing echo $IFS will only show you an empty line. Quote:
I presume you are doing a for within a for loop, the first would split content so block = stanza. awk would then work on block and return a new array .... ahhh there it is ... took me a little bit, because the new array has zero pipes in it it says that all data, ie both uuid's and new lines are one field. Tricky :) Maybe you need to rethink exactly what it is you want to change in menu.lst, ie is it necessary to break up each stanza or maybe make your necessary replacements in place??? A really nasty hack would be to alter the IFS backward and forward in the loop, but I see this as potentially very messy and may just run into more trouble if you expand further. Just one extra word ... and i know this isn't really your fault per se, but if you are going to test something, like the code we have been working on in this thread, you should first test in isolation and then add into your script, then we would have come across this issue as putting it together with older script and not bashing our heads on whether or not it is doing the right thing, which it was. Just a thought :) |
OK so, now this works:
Code:
IFS=$OLD_IFS; # In outer loop should be IFS="|"; hd(x,y) Code:
hd=$(echo $dev | awk 'BEGIN{RS="/dev/";} { |
I just had a thought and would like to back up a little :)
We seem to have missed the point that in any single menu.lst file there would only ever be a handful of UUIDs. Meaning, root (/) will be assigned a UUID and the same for any other systems on the single machine, but, the UUID for root would always be the same (as it is unique and only assigned to one value) and therefore you could now parse the entire file for that UUID and change it and so on for the other UUIDs. I thought it worth mentioning as, for example, the menu.lst you sent me had 20+ stanzas, but ultimately everywhere that root is being referred to will have the same UUID. So if the only reason to break the menu.lst into stanzas and then get the UUIDs to then be changed into hdx,y - I think this may be able to be done easier. Let me know what you think or if you don't understand, ask me and I will see if I can draft a suggestion. As for your recent post: Quote:
if you could get your computer to have enough connections for a hundred drives I guess it is possible. |
All times are GMT -5. The time now is 09:14 AM. |