LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 05-30-2003, 11:54 AM   #1
tarballed
Member
 
Registered: Jun 2002
Distribution: RH, FC, FreeBSD,OpenBSD
Posts: 326

Rep: Reputation: 30
Modules: Inserting, removing etc..


Hello everyone. I have a question on modules. This is something I have not had a much experience with, but I want to learn using modules.

I know a few commands: lsmod, insmod but not all of them.

What I was wondering is how to remove modules that are installed?
Secondly, how do you determine which modules can be removed?

Here is a sample of the modules on my samba backup server:

smbfs 43584 2 (autoclean)
cmpci 35944 0 (autoclean)
soundcore 6500 4 (autoclean) [cmpci]
agpgart 42944 0 (unused)
sg 36588 2 (autoclean)
ide-scsi 10512 0
autofs 13348 0 (autoclean) (unused)
3c59x 30608 1
iptable_filter 2412 0 (autoclean) (unused)
ip_tables 14840 1 [iptable_filter]
st 30768 0 (unused)
mousedev 5524 0 (unused)
keybdev 2976 0 (unused)
hid 22244 0 (unused)
input 5920 0 [mousedev keybdev hid]
usb-ohci 21288 0 (unused)
usbcore 77056 1 [hid usb-ohci]
ext3 70336 5
jbd 52212 5 [ext3]
aic7xxx 137140 2
sd_mod 13552 0 (unused)
scsi_mod 107176 5 [sg ide-scsi st aic7xxx sd_mod]

I do not need all of them (for example, iptables...this machine is already behind a firewall) What other modules could I remove? I need the scsi since the backup system is scsi based.

Thanks for your help.

Tarballed
 
Old 05-30-2003, 01:41 PM   #2
bbeers
Member
 
Registered: Jul 2002
Location: Florida
Distribution: Centos, Slackware
Posts: 260

Rep: Reputation: 30
rmmod <module_name> to remove a specific module.
modprobe -r <module_name> to remove and clean up dependencies.
modprobe <module_name> will install the module and any
modules upon which that module depends.
insmod -f <module_name> to force a module to install inspite
of warnings.

Any module can be removed, as long as it is not being used.
For example, your 3x59x module is for a 3COM ethernet card,
you can't remove that module until you bring down that
interface (likely eth0), with "ifconfig eth0 down". And conversely,
you can't bring up the interface until you've loaded the module.

Also, depending on your kernel options, you may be loading
and unloading modules automatically via kmod, et al.

HTH,
-bbeers
 
Old 05-30-2003, 02:31 PM   #3
dorian33
Member
 
Registered: Jan 2003
Location: Poland, Warsaw
Distribution: LFS, Gentoo
Posts: 591

Rep: Reputation: 32
The 3rd parm in the line show the current process use counter. Zero means no process is currently using the module. So look for lines with 3rd parm=0.

You'll find lines with 'autoclean' comment. This modules can be safely removed. But anyway they will be removed by system in any case (like memory shortage etc). So there is no sense to do it.

You'll find also 'unused' comment. This modules can be safely removed also. The difference is that they not be automatically removed like in case of 'autoclean'. So it makes sense to do it manually if they are not needed.
 
Old 06-02-2003, 01:06 PM   #4
tarballed
Member
 
Registered: Jun 2002
Distribution: RH, FC, FreeBSD,OpenBSD
Posts: 326

Original Poster
Rep: Reputation: 30
Thanks guys for your input on this issue.
So what modules do you think I should remove, without hosing my system?

I do not need the ip_tables stuff, as this server is already behind two firewalls.

bbeers mentioned something that I think I need to look into, and that is that my kernel may be loading modules automatically via kmod...whats the best way to sort out that?

Thanks guys.

Tarballed
 
Old 06-02-2003, 01:21 PM   #5
bbeers
Member
 
Registered: Jul 2002
Location: Florida
Distribution: Centos, Slackware
Posts: 260

Rep: Reputation: 30
Well, it would be better to prevent the unnecessary modules from loading based on knowing what you want, rather than guessing which are not needed after they've been loaded. Go through the init sequence (rc.S, etc.)
and see what is being called. Don't start any services or load any modules that you don't need. You'll have to decide what is the function of the box. Which distribution is installed, what does the box do? You already said it is not a firewall. Do you _need_ USB keyboard/mouse? Do you _need_ video? Do you _need_ samba, ext3, sound, etc. etc.?

But having said all that, why worry? Is it working? Do you _need_ to free up some resources? If it isn't broken ...

-bbeers
 
Old 06-02-2003, 01:29 PM   #6
tarballed
Member
 
Registered: Jun 2002
Distribution: RH, FC, FreeBSD,OpenBSD
Posts: 326

Original Poster
Rep: Reputation: 30
Quote:
But having said all that, why worry? Is it working? Do you _need_ to free up some resources? If it isn't broken
Actually, I do need to free up some resources. This particular server is running a basic samba server, but it is also functioning as our backup server as well. It backs up our main server to a 5 tape autoloader every night.

What caught my attention is that doing some initial testing on backups, I checked it one morning and it told me it was out of memory and that I needed to remove some modules to free up memory..

I was not happy and I am in the process of chatting with the vendor as to why this happened. In the mean time, I figured it would be a wise move to see what modules I would and would not need. Plus, it's another aspect of learning all together...

But for now, I guess I need to have this particular server boot up with only what is needed. I will need to sit down and decide what things I will need, but for now, I would like to at least understand how to remove modules, insert, etc.

I appreciate your help.

Tarballed
 
Old 06-02-2003, 01:55 PM   #7
whansard
Senior Member
 
Registered: Dec 2002
Location: Mosquitoville
Distribution: RH 6.2, Gen2, Knoppix,arch, bodhi, studio, suse, mint
Posts: 3,302

Rep: Reputation: 65
those modules are using very little memory.
you just need more swap. your tape program may be
writing a crapload of stuff into memory and not swapping
it out.
make a backup of your modules
tar clfvz - /lib/modules > /modulesbackup.tgz
then you can move or rename any you don't want to load,
if you can't find in the scripts where they are loading.
but that wont make much difference as far as memory
usage, and the kernel will probably remove them from
memory after a while anyway.
you can have your backup process create and add a
swapfile too, with something similar to
dd if=/dev/zero of=swapfile bs=1M count=1000
mkswap swapfile
swapon swapfile
then at the end of the script
swapoff swapfile
rm swapfile
 
Old 06-02-2003, 03:03 PM   #8
tarballed
Member
 
Registered: Jun 2002
Distribution: RH, FC, FreeBSD,OpenBSD
Posts: 326

Original Poster
Rep: Reputation: 30
Quote:
you just need more swap
As it is right now, the system has 512 SWAP, but it has 512MB RAM. The original admin who set it up, originally set it up with 256mb physical RAM, then decided to upgrade it to 512mb RAM.

So what I need to do is increase the swap size. Anyone have any suggestions on the best way to go about doing this?

Granted, I need to be extremely careful when doing this so I dont botch the server.

Any suggestions on how to convert the swap space from 512mb to 1024mb, without reinstalling?

Tarballed
 
Old 06-02-2003, 03:40 PM   #9
whansard
Senior Member
 
Registered: Dec 2002
Location: Mosquitoville
Distribution: RH 6.2, Gen2, Knoppix,arch, bodhi, studio, suse, mint
Posts: 3,302

Rep: Reputation: 65
you can have several swap partitions and files.
if you don't have free unpartitioned space, the easiest
thing would be a swap file, but it looks like that one app
is the only thing that needs it.
 
Old 06-02-2003, 04:12 PM   #10
tarballed
Member
 
Registered: Jun 2002
Distribution: RH, FC, FreeBSD,OpenBSD
Posts: 326

Original Poster
Rep: Reputation: 30
Quote:
you can have several swap partitions and files. if you don't have free unpartitioned space, the easiest
thing would be a swap file, but it looks like that one app
is the only thing that needs it.
Yes. As it is at the moment, I am pretty tight on space on the HD.

Do you recommend setting up the swap file that was suggested in this thread? Any other suggestions/modifiations I can do to get this server "out of the loop" sort a speak.

Cheers.

Tarballed
 
Old 06-02-2003, 05:48 PM   #11
whansard
Senior Member
 
Registered: Dec 2002
Location: Mosquitoville
Distribution: RH 6.2, Gen2, Knoppix,arch, bodhi, studio, suse, mint
Posts: 3,302

Rep: Reputation: 65
dd if=/dev/zero of=swapfile bs=1M count=1000
mkswap swapfile
swapon swapfile

thats for a 1 gig swapfile.

you can add a script to mount it, or edit fstab
 
Old 06-02-2003, 05:59 PM   #12
tarballed
Member
 
Registered: Jun 2002
Distribution: RH, FC, FreeBSD,OpenBSD
Posts: 326

Original Poster
Rep: Reputation: 30
Thanks whansard.
This is very interesting and very cool.

I was thinking about just editing fstab and putting it in there. That would seem to be easiest.

Just a couple of questions.

When editing fstab:

LABEL=/ / ext3 defaults 1 1
LABEL=/backupstorage /backupstorage ext3 defaults 1 2
none /dev/pts devpts gid=5,mode=620 0 0
LABEL=/home /home ext3 defaults 1 2
none /proc proc defaults 0 0
none /dev/shm tmpfs defaults 0 0
LABEL=/usr /usr ext3 defaults 1 2
LABEL=/var /var ext3 defaults 1 2
/dev/hda3 swap swap defaults 0 0
/dev/cdrom /mnt/cdrom iso9660 noauto,owner,kudzu,ro 0 0
/dev/fd0 /mnt/floppy auto noauto,owner,kudzu 0 0

That's my current swap file

Could I just add it in /etc/fstab like so:

label=swapfile swap swap

Or what would be the wisest setup, so I dont blow up my server?

Secondly, if I wanted to tgst my performance for my software, any recommendations there?

T.
 
Old 06-02-2003, 06:12 PM   #13
whansard
Senior Member
 
Registered: Dec 2002
Location: Mosquitoville
Distribution: RH 6.2, Gen2, Knoppix,arch, bodhi, studio, suse, mint
Posts: 3,302

Rep: Reputation: 65
i guess this at the end would work

/swapfile none swap sw 0 0

you better check that first.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
inserting a modules into the Kernel stielinc Linux - Software 1 01-22-2005 01:47 PM
error inserting alsa modules darkleaf Linux - Software 6 09-05-2004 05:40 AM
Inserting and removing modules mwu Linux - Software 4 03-13-2004 12:31 AM
inserting modules during system startup jogurt666 Debian 3 01-15-2004 02:45 AM
Inserting modules wgodois Linux - Hardware 0 08-03-2003 09:37 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:57 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration