I want to do the same thing but need to make sure i dont delete hdisk0 since this is my OS.
Asked
Active
Viewed 1,846 times
1 Answers
0
If the hdisk0 is in use the system wont delete it. it will error out
"smitty->devices ->fixed disk-> remove" don't have the option to select multiple. if you want to remove multiple disks use the following for loop.
it will remove all disks but hdisk0.
for i in `lspv |grep -v hdisk0|awk '{print $1}'`;do rmdev -dl $i; done
if you want to remove all defined disk:
for i in `lsdev -Cc disk |grep Defined|awk '{print $1}'`; do rmdev -dl $i; done
the -d in rmdev command removes the device definition.
JDababseh
- 16
-
so on the command line am i running that entire line?? for i in lspv |grep -v hdisk0|awk '{print $1}'; do rmdev-dl $i; done ??? – Jakekq Aug 30 '16 at 15:12
-
Yes. just fixed the formatting – JDababseh Aug 30 '16 at 15:14
-
https://gyazo.com/d6137e96f291a3a3d2dea218826cda08 is the loop an actual value of how many drives i have in there?? – Jakekq Aug 30 '16 at 15:16
-
Yes. the lspv command will list all disks. and the grep -v will exclude hdisk0. – JDababseh Aug 30 '16 at 15:17
-
Are you trying to remove just the defined disks? – JDababseh Aug 30 '16 at 15:17
-
Yeah so i want to do grep Defined. Im removing all the defined formats. Since these are all created after I format drives. And when Im doing up to 40 at a time its a pain to have to remove each one individually. – Jakekq Aug 30 '16 at 15:19
-
then use the second for loop – JDababseh Aug 30 '16 at 15:20
-
https://gyazo.com/86b044f0e4ab7ce2d8a989bc46096672 – Jakekq Aug 30 '16 at 15:22
-
Should i do -Cc fixed disk?? – Jakekq Aug 30 '16 at 15:23
-
yes the second for loop not the first one – JDababseh Aug 30 '16 at 15:24
-
I took a photo. It gave me an error of rmdev: not a recognized flag: C and rmdev: '}' not found – Jakekq Aug 30 '16 at 15:31
-
Please copy the second for loop and paste that in your shell. you replaced the ticks with single quote – JDababseh Aug 30 '16 at 15:40