diskparts: list disk partitions, including any ext2 labels
D. Hugh Redelmeier
hugh-pmF8o41NoarQT0dZR+AlfA at public.gmane.org
Tue Mar 2 02:21:01 UTC 2004
I often upgrade the OS on a machine by installing a new version of the OS.
When planning to do this, I often want a hard-copy of the partition layout
as a worksheet.
fdisk -l doesn't tell me quite enough: I'd like to know what is on the
partitions. I label all my ext[23] partitions, but the labels don't show
up in the fdisk output.
Generally, I do an fdisk -l and then scrible on the results. As a
labour-saving device, I've just written a script to do the annotation
automatically.
I'm posting it here to get some feedback:
- do you find this useful?
- what would you add to this?
- is there a simpler way?
Hugh Redelmeier
hugh-pmF8o41NoarQT0dZR+AlfA at public.gmane.org voice: +1 416 482-8253
#!/bin/sh
# diskparts: list disk partitions, including any ext2 labels
# Synopsis: disparts [drive]...
# D. Hugh Redelmeier 2004 March 1
set -u
# default to /dev/hda
case "$#" in
0) set - /dev/hda
;;
esac
for drive
do
# oddity: the each line of the fdisk output is prepended with a backslash
# to prevent any leading whitespace being discarded by the sh read command.
/sbin/fdisk -l "$drive" | sed -e 's/^/\\/' |
while read line
do
case "$line" in
*Linux)
vol=` echo "$line" | sed -e 's/ .*//' `
lab=` /sbin/e2label "$vol" 2>/dev/null || echo '???'`
line="$line: $lab"
;;
esac
echo "$line"
done
done
--
The Toronto Linux Users Group. Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml
More information about the Legacy
mailing list