• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 305
  • Last Modified:

sorting out /dev directory

How can I sort out my /dev directory in one go ?
Still from my REDHAT 7.1 installation, thousands of files were created
& I'm pretty sure I don't need them all.
Some weeks ago I found a useful command for that
in a book or document, just can't remember where it was.
So, anybody knows that magical 'clean up' command ?
Thanks ; )

0
xberry
Asked:
xberry
  • 21
  • 5
  • 3
  • +3
1 Solution
 
jlevieCommented:
Yeah there's typically a lot of files in the /dev dir, but they really don't take up all that much space. On this RH 7.1 system I have 5308 files in /dev using 268Kb. While one could remove device files for things that you aren't currently using, it hardly seems worth the effort for the small amout of space you could recover.
0
 
dorwardCommented:
The "files" in /dev take up virtually no space (they are effectivly links as far as size is concerned) and are your interface to your hardware. Erasing any of them isn't a good idea.
0
 
rhymeCommented:
Do not erase your files in /dev . This will seriously affect your Linux installation, and at the very least you will be unable to login again, they don't take up any space and don't do any damage to your machine. Yes, you may not need them all, but this text message probably uses more space than all of them.

If you really want to clean them you can carefully work your way through them and delete the ones you don't have

hda - primary ide disk 1
hdb - ide disk 2
hdc - ide disk 3
hd...  - other disks

sda - scsi disk 1
sdb - scsi disk 2
sd... scsi disk N

Before you do any of this, make a copy of the output of ls -l on /dev. IF you make mistakes you will need to use mknod (type man mknod or info mknod) to fix things. If you make the wrong mistake, you may completely blow your machine up.

I don't recommend doing it though and I don't think anyone ever does.

0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
xberryAuthor Commented:
0. I see that you're new at EE. So WELCOME.
1. Thanks for adding your input
2. This simply doesn't answer my question, please read it         again.
3. It is common practice among experts at EE, not to lock
   questions with an answer. So please put comments & leave    the questions open, thus encouraging other experts to
   add valuable input.

   
         
0
 
xberryAuthor Commented:
0. I see that you're new at EE. So WELCOME.
1. Thanks for adding your input
2. It is common practice among experts at EE, not to lock
   questions with an answer. So please put comments only &         leave questions open, thus encouraging other experts        to contibute with valuable ideas.




   
         
0
 
xberryAuthor Commented:
0. I see that you're new at EE. So WELCOME.
1. Thanks for adding your input
2. It is common practice among experts at EE, not to lock
   questions with an answer. So please put comments only &         leave questions open, thus encouraging other experts        to contibute with valuable ideas.




   
         
0
 
xberryAuthor Commented:
0. I see that you're new at EE. So WELCOME.
1. Thanks for adding your input
2. It is common practice among experts at EE, not to lock
   questions with an answer. So please put comments only &         leave questions open, thus encouraging other experts        to contibute with valuable ideas.




   
         
0
 
xberryAuthor Commented:
0. I see that you're new at EE. So WELCOME.
1. Thanks for adding your input
2. It is common practice among experts at EE, not to lock
   questions with an answer. So please put comments only &         leave questions open, thus encouraging other experts        to contibute with valuable ideas.




   
         
0
 
xberryAuthor Commented:
0. I see that you're new at EE. So, WELCOME.
1. Thanks for adding your ideas.
2. It is common practice among experts at EE, not to lock
   questions with an answer. So please put comments only &         leave questions open, thus encouraging other experts        to contibute with valuable ideas.




   
         
0
 
xberryAuthor Commented:
0. I see that you're new at EE. So, WELCOME.
1. Thanks for sharing your thoughts.
2. It is common practice among experts at EE, not to lock
   a question with an answer. So please put comments only
   & leave questions open, thus encouraging other experts      to contribute with their valuable ideas. Thank you




   
         
0
 
xberryAuthor Commented:
OH NOOOOO
This is so nuts.
I clicked the reject anwer button together with the
comment & every time I tried I got
' Internal server error ' & now this . . .
Comment appeared but reject command wasn't accepted.

Does anything still function at EE ?
0
 
xberryAuthor Commented:
ah . . . now it worked
0
 
xberryAuthor Commented:
Thanks for your replies so far

to jlevie:

So, regardless the real purpose for my /dev/ sortout
you sound as if you know about the shell command that would help. What's the deal ?

to dorward

for me it doesn't look as if there would be a real device behind each /dev/ 'link'. For instance I do have
one 'real' modem but hundreds of 'ttyS*' named.
It really would be nice to know which /dev/* are pointing
to real devices & which one's are dead end.

to rhyme

See text of my question.      
0
 
rhymeCommented:
Yea *I'm* the newbie ;)
0
 
dorwardCommented:
You might not need them... but you could add the hardware at a later date and they are so small it isn't worth removing them. My /dev directory totals 268 kilobytes! It simply isn't worth the effort.
0
 
xberryAuthor Commented:
> It simply isn't worth the effort

Who judges ?

OK, I put the question simple

Is there a command exactly as specified        
or was I just subject to an hullucination when I thought
that I had seen it anywhere in a book.

How far do I have to get up with my points ?



0
 
dorwardCommented:
I've never heard of such a command
0
 
ahoffmannCommented:
cd /dev
# then if you have no sound
ls -l | awk '($4=="audio" && NF!=11){print "rm "$10}'|sh
# if you have only 2 serial interfaces
rm ttyS[1-9]? ttyS[2-9]
# if you don't use uucp and no modem
ls -l|grep -v tty|awk '($4=="uucp" && NF!=11){print "rm "$10}'|sh
# if you do not use video/radio
ls -l | awk '($4=="video" && NF!=11){print "rm "$10}'|sh
# if you have not FAT partitions
rm dos_*
# if you just have one floppy
rm fd[1-9]*
# if you just have one IDE disk
rm hd[b-z]*
# if you have no SCSI disks
rm sd[a-z][1-9]*
# if you do not use RAID
rm md[0-9]*
# if you do not use ISDN
rm isdn*
# if you do not use PPP
rm ippp*
0
 
xberryAuthor Commented:
to dorward:

THANK YOU !  This sounds like an honest, direct & understanding answer to my question. I apologize if
my questions sometimes sound unusual in a fashion
. . . So I'm going to leave this question open for a
while in case someone 'knows' about that one command
which mirrors used devices against /dev/* & automagically removes unoccupied entries.
If it doesn't turn up then I'll accept it as nonexistent
& reward you the points.

to ahoffmann:

Thanks, your effort is admired but not matching my question. Also, your list only covers a minor portion of what I've got in my /dev. The ideal shell input would
have to be accurate as well as secure in it's function.

0
 
ahoffmannCommented:
> .. only covers a minor portion
depends only on how you define "minor": 10%, 50%, 70%, ..
if you have about 5000 devices, and you remove 2500, that saves you approx. 140kb, roughly 0,01% of a 1,4Gb disk ;-)
0
 
xberryAuthor Commented:
> that saves you approx. 140kb

Gaining 'physical' space is not my purpose here, at least not primarily.
The commenters are right when they state that the overall file size of /dev is insignificant,
even on a small partition.
No, actually my item here 'quality' & 'verification'.
I'd like to know my system & what really is behind it's thousands of 'significances' at least to a point where I can say: " Aha, there's an 'appartement' with a name at it's door, but no one is living there, so we don't need a label, do we ?" Anything else is just confusing.

0
 
ahoffmannCommented:
> I'd like to know my system & what really is behind ..

and then you insist on a simple command removing all you {d|w}on't need?

Some devices are there just in case of some peripheral things will be attached, or for special software (like uucp).
The command you're searching for cannot exist, 'cause no program can know what you'll try to connect or use.
You, the human, must tell the system what is necessary and what can be omitted.

I gave you a few examples, it's simple to make more just by doing a  "ls -l /dev" on the remaining.
0
 
kruemelmoCommented:
> No, actually my item here 'quality' & 'verification'.
> I'd like to know my system & what really is behind it's thousands of 'significances' at least to a point
> where I can say: " Aha, there's an 'appartement' with a name at it's door, but no one is living there,
> so we don't need a label, do we ?" Anything else is just confusing.

Altough you might not like this comment, i have some thoughts about this.

You surely have no chance to ever document and understand the functionality of every single file in your system, although a redhat system already does quite a lot for you through rpm. Erasing the /dev files will actually *cover* something that your system can do; you are indeed removing the labels from the doors, but the doors still exist, even if you cannot see them anymore. If you want to remove the doors and appartments, you need to edit your kernel source to remove every driver you currently don't need.

All the files in the /dev directory are will documented.

Does it really make sense to sort of cover device drivers by erasing /dev files and thus create an unneccessary difference between your system and what redhat and rpm document?  In terms of quality and verification, isn't the available documentation the key point of it?

Anyway, if you stil want to delete them, i would suggest that you a) comment on my elaboration (i am really interested) and b)

- boot from a floppy
- remove *all* files from /dev/ (rm -f /dev/*)
- recreate the nodes you need using MAKEDEV and/ro mknod. Both have man pages. Note that MAKEDEV operates in any directory - you must first cd to the correct /dev directory. You can now create only those device nodes you need. Absolutely necessary are those created by "MAKEDEV std", but look at the man page, you will find more which you need and it of course depends on you system configuration.

Greetings!
0
 
kruemelmoCommented:
of couse it should by 'rm -f /mnt/whereever/dev/*' to remove the files in the correct /dev dir, not the one on the floppy, after mounting the root partition on /mnt/whereever
0
 
ahoffmannCommented:
kruemelmo, "rm -f /dev/*"
damit saegst du den Ast ab auf dem du sitzt: /dev/tty*

xberry, sorry for using other language :-)
0
 
xberryAuthor Commented:
to ahofman & kruemelmon

thanks, you both brought in interesting new arguments.
I have to think about them now . . .

0
 
xberryAuthor Commented:
xberry, sorry for using other language :-)

no problem ahofffman, I knew that you'd come up with japanese one day : )
0
 
xberryAuthor Commented:
I just pop over to a discussion thread in 'the lounge' quick.
Didn't load last time, about 242 KB size the complete thread.
I bet they're going for a new hit in the 'quinness book of records'
See you then.
0
 
xberryAuthor Commented:
I just pop over to a discussion thread in 'the lounge' quick.
Didn't load last time, about 242 KB size the complete thread.
I bet they're going for a new hit in the 'quinness book of records'
0
 
xberryAuthor Commented:
Hi,

back again.

ahoffman: DON'T PANIC (!) ;-)
I'm not that unexperienced with system administration
& setup actions. To your all relief:
I'm going to leave my /dev directory exactly as it is,
. . . at least for a longer period of time.

Don't be so harsh to 'kruemelmo.....' .
His tip with MAKEDEV helped me a lot. I just went through
the man page & it actually looks as if there is (the|a) key
to my search with an even better solution (no destruction
or messing about with anything).
Give me some time to go through the mans & docs in order to get a clearer concept. Coming back to you later.

Thanks a lot kruemelmo, you helped me to get
very close to it (!)

By the way, anyone of you know where to discuss
some 'thought provoking' theories about languages
on the net ? ;)

cheers, xberry  

 
0
 
ahoffmannCommented:
if MAKEDEV gave you the most comprehensive answers for your question(s), then IMO points go there.
BTW, I wasn't harsh. Do you agree kruemelmo?

> .. theories about languages ..
check the Lounge topic at EE ;-)
0
 
kruemelmoCommented:
ahoffmann: yes, i agree... :-)
0
 
xberryAuthor Commented:
> if MAKEDEV gave you the most comprehensive answers for  
> your question(s), then IMO points go there.

a very clever point ahoffmann, but /dev/MAKEDEV again
is only one tiny part of /dev/.

Five people did comment to this question. Though YOU bent to my question in different modes you all did base your
opinion on one common argument:
" That I should not erase the files in /dev "
To be true, that made sense to me & each single one of you did help me a lot in order to understand.
. So, in the true spirit of this question I have to reward
you all with equal amount of points.



 
 
   
0
 
xberryAuthor Commented:
Eh, please take your share from the
"Linux Administration" topic area in a while.
Title is: "/dev, MAKEDEV & points for <your name>"
0
 
xberryAuthor Commented:
Please pick your points. You all were right.
Special thanks to kruemelmo for his tip with the MAKEDEV.

The person, who actually ' answered ' the question in a straightforward sense
was dorward. So with a later PAQ in mind I take his comment in order
to close the question. I hope you agree.


0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

  • 21
  • 5
  • 3
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now