#!/bin/sh ## ## NAUTILUS ## SCRIPT: 00_anyfile_LIST-STORAGE-PARITIONS_xterm-sudo-fdisk-l.sh ## ## PURPOSE: List attached storage devices and their paritions. ## (See sample output at the bottom of this script.) ## ## METHOD: Uses 'sudo fdisk -l' --- in an 'xterm'. ## ## HOW TO USE: In Nautilus, select ANY file in ANY directory. ## Then right-click and choose this script to run (name above). ## ########################################################################### ## Script ## Created: 2012apr06 ## Changed: 2012apr18 Changed script name in comments above and touched up ## the comments. Changed some indenting below. ####################################################################### ## FOR TESTING: (show statements as they execute) # set -x ##################################################### ## Use 'sudo fdisk -l' in an 'xterm' to show the info. ##################################################### xterm -hold -fg white -bg black -geometry 80x40 \ -title "sudo fdisk -l" -e \ sudo fdisk -l exit ## SOMEDAY we might try to put the output in a text file, with ## a header and trailer, like follows. ################################################################## ## Prep a temporary filename, to hold the list. ## We put the outlist file in /tmp, in case the user ## does not have write-permission in the current directory, ## and because the output does not, usually, have anything ## to do with the current directory. ################################################################## OUTLIST="/tmp/${USER}_list_STORAGE-PARTITIONS.lis" if test -f "$OUTLIST" then rm -f "$OUTLIST" fi ################################# ## Make the HEADER for the list. ################################# THISHOST=`hostname` echo "\ ................ `date '+%Y %b %d %a %T%p %Z'` ...................... STORAGE DEVICE PARITIONS --- for host: $THISHOST This data, from the 'sudo fdisk -l' command, is especially useful for finding mount info for BLOCK (disk) devices and USB devices. Some more information is at the bottom of this list. ------------------------------------------------------------------------------ " > "$OUTLIST" ################################## ## Make the TRAILER for the list. ################################## SCRIPT_BASENAME=`basename $0` SCRIPT_DIRNAME=`dirname $0` echo " ................ `date '+%Y %b %d %a %T%p %Z'` ...................... The list above was generated by the script $SCRIPT_BASENAME in directory $SCRIPT_DIRNAME If you want to change the ouput or the method of operation, you can simply edit the script. ------------------------------------------------------------------------------ FOR MORE INFO ON THESE EXECUTABLES: For some of these topics (or commands like 'fdisk'), you can type 'man ' to see details on the topic. ('man' stands for Manual. It gives you a user manual for a command/utility/protocol/topic.) You can type 'man man' at a shell prompt to see a description of the 'man' command. Or use the 'show_manhelp_4topic' Nautilus script in the 'LinuxHELPS' group of Nautilus scripts. ******* END OF LIST of STORAGE PARTITION info on host $THISHOST ******* " >> "$OUTLIST" ########################### ## Show the listing. ########################### ## . $HOME/.gnome2/nautilus-scripts/.set_VIEWERvars.shi . $HOME/.freedomenv/feNautilusScripts/set_DIR_NautilusScripts.shi . $DIR_NautilusScripts/.set_VIEWERvars.shi $TXTVIEWER "$OUTLIST" exit ## SAMPLE 'sudo fdisk -l' OUTPUT: Disk /dev/sda: 160.0 GB, 160041885696 bytes 255 heads, 63 sectors/track, 19457 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0xfcb47097 Device Boot Start End Blocks Id System /dev/sda1 * 1 9726 78124063+ 83 Linux /dev/sda2 9727 19457 78164257+ 5 Extended /dev/sda5 9727 19335 77184261 83 Linux /dev/sda6 19336 19457 979933+ 82 Linux swap / Solaris Disk /dev/sdb: 8061 MB, 8061451776 bytes 64 heads, 32 sectors/track, 7687 cylinders Units = cylinders of 2048 * 512 = 1048576 bytes Disk identifier: 0x78698815 Device Boot Start End Blocks Id System /dev/sdb1 * 1 4297 4400128 17 Hidden HPFS/NTFS Disk /dev/sdb1: 4505 MB, 4505731072 bytes 64 heads, 32 sectors/track, 4297 cylinders Units = cylinders of 2048 * 512 = 1048576 bytes Disk identifier: 0x78698815 Device Boot Start End Blocks Id System /dev/sdb1p1 * 1 4297 4400128 17 Hidden HPFS/NTFS