On Wednesday 25 March 2009 11:28:51 Pádraig Brady wrote: > Andrew McGill wrote: > > A longstanding nit with fdisk is that you cannot tell it what you want it > > to do all at once, but have to talk to it interactively. This patch > > allows you to say things like > > d 2 > > to delete partition 2, and > > c p 3 '' +1G > > to create a primary partition, number 3, starting at default position, > > 1Gb big. A particular annoyance that it fixes is that to delete the > > first partition, you can now use "d 1". > > > > I'm fairly confident that my mail client will mangle this message beyond > > usefulness -- and any guidance / flames as to how I should send the patch > > (and corrections) would be appreciated. > > I've used fdisk in scripts like: > > echo "\ > d 2 > c p 3 '' +1G" | > fdisk > > Does that not suffice? It doesn't work. Since fdisk requires each input on a separate line, you can do that only if you pepper your data with newlines, something more like this marvel of clarity: echo $'d\n2\nc\np\n3\n\n+1G' | fdisk $DEVICE However, the primary problem the patch addresses is that when using fdisk *interactively*, it doesn't do what I expect. To my twisted mind, it violates the principle of least surprise that only the first character of each input line is considered, and the rest of the line is discarded. I expect to be able to say "d 2", but only "d 2" is acceptable. I keep doing that, and now that all sorts virtual machines also get partitioned, it's bothering me. A problem which this patch fixes, as a side-effect, is that when you type "d" - enter - "1" - enter - to delete the last partition, you get an error report complaining "1: unknown command" (because the last partition was automatically selected) and a copy of the menu scrolls an important sector off the screen / scrollback buffer (depending on the time of night that you are hacking your system). I want to tell fdisk what to do, without interrupting my thoughts to (1) read the prompt I was presented with (because I know what it says), and (2) find that little enter key, when the big space bar is so close by. I envision generations of happy children, whose parents force them to use Linux "because it's good for you", learning nursery rhymes like "n p 1 1 +64G" and "t 1 82". > I'd be wary about putting non standard option stuff on the command line. Scripts which rely on the last part of the line being an implicit comment would break ... but fdisk is pretty tricky to script, so adding comments is flying by the seat of your pants: echo "n we need a new partition l logical should be okay +2G Smallish (that last line was to accept defaults) w we're done here" | fdisk $DEVICE vs. # make a 2Gb logical partition: echo "n l +2G w" | fdisk $DEVICE &:-) -- To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html