LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-19-2005, 02:04 PM   #1
kushalkoolwal
Senior Member
 
Registered: Feb 2004
Location: Middle of nowhere
Distribution: Debian Squeeze
Posts: 1,249

Rep: Reputation: 49
Partition warning message?


Hi,

I am trying to format a HDD with the following command through my script:


Code:
echo '0,
'\
| sfdisk -L /dev/hdc
Although it formats the HDD properly, it does give me a warning/error message at the end of the above command which says:

Code:
Warning: no primary partition is marked bootable (active)
This does not matter for LILO, but the DOS MBR will not boot this disk.
Successfully wrote the new partition table

Re-reading the partition table ...

If you created or changed a DOS partition, /dev/foo7, say, then use dd(1)
to zero the first 512 bytes:  dd if=/dev/zero of=/dev/foo7 bs=512 count=1
(See fdisk(8).)
How can I eliminate this message so that my command runs smoothly? I really to eliminate because after giving the sfdisk command I am checking the status of $? to see if the command ran successfully or not. And right now it does not return the status '0' because of the above warning message which I know is not fatal.

Thanks
 
Old 10-19-2005, 02:45 PM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
sfdisk has a "-q" or "--quiet" flag that tells it to suppress warning messages.

FYI: Any time you have a question about a utility try typing:
man <utility>
--OR--
info <utility>

You'll find quite a lot of info is right there in the man pages.
 
Old 10-19-2005, 02:54 PM   #3
kushalkoolwal
Senior Member
 
Registered: Feb 2004
Location: Middle of nowhere
Distribution: Debian Squeeze
Posts: 1,249

Original Poster
Rep: Reputation: 49
Hi jlightner, before posting the message I had already read the man pages and I knew that by giving -q option I can suppress those error messages. but my main concerned is that when I check the command status after giving the sfdisk command I do not get '0' i.e. successful execution code which I am chgecking in my script to constantly check for errors.

Code:
#!/bin/bash
ERROR_LOG_FILE="/tmp/errorLog.txt"
TEST_PS_VALUE=""

rm $ERROR_LOG_FILE
touch $ERROR_LOG_FILE

error_log() 
{
if [[ $TEST_PS_VALUE != 0 ]]
then
echo "An error has occured while executing the script.Please see the file $LOG_FILE."
exit 1
fi
}
echo "Partitioning your IDE Device"
echo '0,
'\
| sfdisk -L -D -V /dev/hdc -N1 1>/dev/null 2>$ERROR_LOG_FILE || TEST_PS_VALUE=$? echo -n Line $LINENO >> $ERROR_LOG_FILE
error_log
echo "Partitioning Completed!"
By giving -q option I can suppress warning message but I can;'t do anythng about the status code? can I?

To make things simpler, all I am looking is for a command which will create a single partiion(of the entire device space) on the given device and make the primary partition as bootable.

Remeber I would like to run this command from a script so the command should not be interactive.

Thanks


To make things simple
 
Old 10-19-2005, 03:38 PM   #4
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
OK - your post asked how to suppress the message though it did make comments about return status later.

Since the exit status is defined in the binary you won't be able to do anything about the status it returns. However you COULD write logic into your script that gets the expected return status and the message detail then accepts that as OK in combination so that it only notifies you if you get that status without that message OR if you got any other non 0 exit status.

Of course if you're feeling really industrious you could get the source for sfdisk and modify the section that sets the return status and tell it to mark it with 0 if this is the only problem then compile your own sfdisk.
 
Old 10-19-2005, 04:38 PM   #5
kushalkoolwal
Senior Member
 
Registered: Feb 2004
Location: Middle of nowhere
Distribution: Debian Squeeze
Posts: 1,249

Original Poster
Rep: Reputation: 49
WEll, thanks for the information. Is there any option in sfdisk command that will make the primary partition bootable. I read the man page but could not figure out. Also, if you know any other command like cfdisk or parted which will do the trick i.e. create a single primary partition on the entire drive and mark it as bootable partition.

Thanks
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
warning message before log in noms Fedora - Installation 1 03-16-2004 09:43 PM
why warning message is appear? eye Red Hat 3 10-22-2003 10:14 AM
Warning message during bootup Akajack Linux - Newbie 2 09-20-2003 12:44 AM
Xemacs warning message mikeshn Linux - Software 0 09-11-2003 06:39 PM
Warning Message at startup onlyhuman9 Linux - General 1 11-29-2001 11:00 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:39 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration