Solved

sorting out /dev directory

Posted on 2001-08-27
35
289 Views
Last Modified: 2013-12-15
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
Comment
Question by:xberry
  • 21
  • 5
  • 3
  • +3
35 Comments
 
LVL 40

Expert Comment

by:jlevie
ID: 6430658
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
 
LVL 17

Expert Comment

by:dorward
ID: 6431227
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
 

Expert Comment

by:rhyme
ID: 6435095
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
 
LVL 14

Author Comment

by:xberry
ID: 6435912
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
 
LVL 14

Author Comment

by:xberry
ID: 6435924
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
 
LVL 14

Author Comment

by:xberry
ID: 6435926
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
 
LVL 14

Author Comment

by:xberry
ID: 6435928
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
 
LVL 14

Author Comment

by:xberry
ID: 6435932
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
 
LVL 14

Author Comment

by:xberry
ID: 6435940
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
 
LVL 14

Author Comment

by:xberry
ID: 6435964
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
 
LVL 14

Author Comment

by:xberry
ID: 6436476
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
 
LVL 14

Author Comment

by:xberry
ID: 6436485
ah . . . now it worked
0
 
LVL 14

Author Comment

by:xberry
ID: 6436584
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
 

Expert Comment

by:rhyme
ID: 6436785
Yea *I'm* the newbie ;)
0
 
LVL 17

Expert Comment

by:dorward
ID: 6437614
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
 
LVL 14

Author Comment

by:xberry
ID: 6438093
> 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
 
LVL 17

Accepted Solution

by:
dorward earned 33 total points
ID: 6438418
I've never heard of such a command
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 51

Expert Comment

by:ahoffmann
ID: 6438582
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
 
LVL 14

Author Comment

by:xberry
ID: 6438724
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
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6439576
> .. 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
 
LVL 14

Author Comment

by:xberry
ID: 6440222
> 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
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6440376
> 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
 

Expert Comment

by:kruemelmo
ID: 6441542
> 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
 

Expert Comment

by:kruemelmo
ID: 6441548
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
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6442260
kruemelmo, "rm -f /dev/*"
damit saegst du den Ast ab auf dem du sitzt: /dev/tty*

xberry, sorry for using other language :-)
0
 
LVL 14

Author Comment

by:xberry
ID: 6442314
to ahofman & kruemelmon

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

0
 
LVL 14

Author Comment

by:xberry
ID: 6442332
xberry, sorry for using other language :-)

no problem ahofffman, I knew that you'd come up with japanese one day : )
0
 
LVL 14

Author Comment

by:xberry
ID: 6442345
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
 
LVL 14

Author Comment

by:xberry
ID: 6442356
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
 
LVL 14

Author Comment

by:xberry
ID: 6443016
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
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6444468
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
 

Expert Comment

by:kruemelmo
ID: 6449923
ahoffmann: yes, i agree... :-)
0
 
LVL 14

Author Comment

by:xberry
ID: 6459023
> 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
 
LVL 14

Author Comment

by:xberry
ID: 6459056
Eh, please take your share from the
"Linux Administration" topic area in a while.
Title is: "/dev, MAKEDEV & points for <your name>"
0
 
LVL 14

Author Comment

by:xberry
ID: 6460243
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

In this tutorial I will explain how to make squid prevent malwares in five easy steps: Squid is a caching proxy for the Web supporting HTTP, HTTPS, FTP, and more. It reduces bandwidth and improves response times by caching and reusing frequently-…
I am a long time windows user and for me it is normal to have spaces in directory and file names. Changing to Linux I found myself frustrated when I moved my windows data over to my new Linux computer. The problem occurs when at the command line.…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now