Find the answer to your Linux question:
Results 1 to 2 of 2
i am trying to write a shell script for making partiton in usb pen drive 1GB capacity using fdisk command but i am not able to pass the paremeters (like ...
  1. #1
    Just Joined!
    Join Date
    Nov 2007
    Posts
    27

    how to write shell script for partition usb pen drive using fdisk cmd?


    i am trying to write a shell script for making partiton in usb pen drive 1GB capacity using fdisk command
    but i am not able to pass the paremeters (like P or size to partition) in script which are required by fdisk command.
    so please can any one tell me how to write the shell script in red hat linux 9.2-2.6.20 kernel


    please revert
    thanks in advance

  2. #2
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    When I do this at the command line:
    Code:
    man fdisk
    I get back the instructions for using fdisk. Those instructions include this:
    Code:
    BUGS
           There are several *fdisk programs around.  Each has its
           problems and strengths.  Try them in the order cfdisk,
           fdisk, sfdisk.  (Indeed, cfdisk is a beautiful program
           that has strict requirements on the partition tables it
           accepts, and produces high quality partition tables. Use
           it if you can.  fdisk is a buggy program that does fuzzy
           things - usually it happens to produce reasonable results.
           Its single advantage is that it has some support for BSD
           disk labels and other non-DOS partition tables.  Avoid it
           if you can.  sfdisk is for hackers only - the user inter-
           face is terrible, but it is more correct than fdisk and
           more powerful than both fdisk and cfdisk.  Moreover, it
           can be used noninteractively.)
    You have several choices here. My two favorites:
    1. Use sfdisk. Be very careful. This is not for the faint of heart. I've never used sfdisk, but it seems to be suited for use in a script. For more information, do this at the command line:
      Code:
      man sfdisk
    2. Use cfdisk. I've always liked that one. It doesn't lend itself to a script very well, but you can get around that by performing two steps:
      1. Use it interactively for a while until you're extremely familiar with what you want to do, and how you would ask cfdisk to do it interactively.
      2. Learn how to use the program "expect". This program lets you do things in a script with programs which can normally be used only interactively. You say to it, "expect this on the 'screen' and then enter this other stuff on the 'keyboard'" -- all in a script. For more information, do this at the command line:
        Code:
        man expect
        You can also read the wikipedia article on expect. There are some very useful links at the bottom of that article.

        You can also google
        Code:
        expect tutorial
        if you wish.

    Hope this helps.
    --
    Bill

    Old age and treachery will overcome youth and skill.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...