Results 1 to 10 of 19
Hi,
I have some testing requirement,need to write script for fdisk command.
I have done the following steps:
1)-------------------------------------------------
#!/bin/sh
fdisk /dev/sda < /root/second.sh
-----------------------------------------------
and the second (answer to ...
- 04-30-2008 #1Just Joined!
- Join Date
- Apr 2008
- Posts
- 13
Need script for fdisk Command
Hi,
I have some testing requirement,need to write script for fdisk command.
I have done the following steps:
1)-------------------------------------------------
#!/bin/sh
fdisk /dev/sda < /root/second.sh
-----------------------------------------------
and the second (answer to fdisk)
---------------------------------------------
n
p
1
t
fb
w
This Script is working,But this is not taking id (which is fb,for vmfs partition),Which is not mentioned in fdisk option also
.Is there any way to give that id ?
Thanks in advance.
Amit
- 05-01-2008 #2Just Joined!
- Join Date
- Apr 2008
- Posts
- 35
Hey There,
Instead of fb, check out fdisk manually and note the number associated with it. I think you have to put the number, instead of "fb" for it to work.
Hope that helps
, Mike
- 05-02-2008 #3Just Joined!
- Join Date
- Apr 2008
- Posts
- 13
Hi,
In fdisk ,when I do manually ,There is no option for 'fb' win hex list,It is unknown one, Still it is taking ,if i do manually.
While using script it is failing and taking the default one 'linux'.
-Amit
- 05-02-2008 #4Just Joined!
- Join Date
- Apr 2008
- Posts
- 35
Hey Amit,
Bummer. Can you try this. For some reason, it works on my vmware. Of course, step through it first (I'd hate to destroy anything).
n
p
t
1
fb
w
I just had to reverse the "t" and the "1"
If that doesn't help you out, let me know. I'm curious to see how this gets fixed.
Best wishes
, Mike
- 05-02-2008 #5Linux Guru
- Join Date
- Nov 2007
- Location
- Córdoba (Spain)
- Posts
- 1,513
The fdisk stuff can be self contained, no need for a second file. This, works for me:
I don't know why is it failing for you. I only removed the stuff to create a partition (since it would failt on my live system, of course) and the stuff to write the partition table (for obvious reasons).Code:# cat a #!/bin/sh fdisk /dev/sda << EOF t 1 fb p q EOF # LC_ALL=en sh a The number of cylinders for this disk is set to 60801. There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with: 1) software that runs at boot time (e.g., old versions of LILO) 2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK) Command (m for help): Partition number (1-4): Hex code (type L to list codes): Changed system type of partition 1 to fb (Unknown) Command (m for help): Disk /dev/sda: 500.1 GB, 500107862016 bytes 255 heads, 63 sectors/track, 60801 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0x00046001 Device Boot Start End Blocks Id System /dev/sda1 1 60540 486287518+ fb Unknown /dev/sda2 60541 60801 2096482+ 82 Linux swap / Solaris Command (m for help):
- 05-02-2008 #6Just Joined!
- Join Date
- Apr 2008
- Posts
- 13
Mike,
I have tried with reverse option.
second file sequence is
n
p
t
1
fb
w..
Still I am getting Linux partition..
I don't know why
-Amit
- 05-06-2008 #7Just Joined!
- Join Date
- Apr 2008
- Posts
- 13
Hi,
This problem is solved by using this sequence:
n
p
1
t
fb
t
fb
w
For me ..this is working fine..
Really no idea..why i need to mention the parameter (t,fb two time..)
Thanks for your response...
-Amit
- 05-06-2008 #8Just Joined!
- Join Date
- Apr 2008
- Posts
- 35
Cool - glad you got it working

i92guboj's solution is more elegant and I can't believe I didn't think of it
Using a "here document" is probably going to be easier to understand later 
Best wishes,
Mike
- 05-06-2008 #9
Looks like problem solved
, but I'm having some basic doubts . 
How to pass arguments to shell script like you do here,passing arguments to fdisk.
Let me know if you got any links about this topic...
So far i thought you can't using interactive commands in shell script
- Lakshmipathi.G
-------------------
FOSS India Award winning ext3fs Undelete tool and tutorials www.giis.co.in
First they criticize you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
-------------------
- 05-06-2008 #10Just Joined!
- Join Date
- Apr 2008
- Posts
- 13
Hi,
Scripts are like this:
fdisk_command.sh
#!/bin/bash
fdisk /dev/sda < /script.sh
script.sh
#!/bin/bash
n
p
1
t
fb
w
you have to pass parameters like this...
-Amit


Reply With Quote