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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
10-19-2005, 02:04 PM
|
#1
|
Senior Member
Registered: Feb 2004
Location: Middle of nowhere
Distribution: Debian Squeeze
Posts: 1,249
Rep:
|
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
|
|
|
10-19-2005, 02:45 PM
|
#2
|
LQ Guru
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
|
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.
|
|
|
10-19-2005, 02:54 PM
|
#3
|
Senior Member
Registered: Feb 2004
Location: Middle of nowhere
Distribution: Debian Squeeze
Posts: 1,249
Original Poster
Rep:
|
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
|
|
|
10-19-2005, 03:38 PM
|
#4
|
LQ Guru
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
|
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.
|
|
|
10-19-2005, 04:38 PM
|
#5
|
Senior Member
Registered: Feb 2004
Location: Middle of nowhere
Distribution: Debian Squeeze
Posts: 1,249
Original Poster
Rep:
|
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
|
|
|
All times are GMT -5. The time now is 01:39 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|