wood burning stoves 2.0*
The moose likes Linux / UNIX and the fly likes Increasing Disk Partition Size on Linux Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "Increasing Disk Partition Size on Linux" Watch "Increasing Disk Partition Size on Linux" New topic
Author

Increasing Disk Partition Size on Linux

Stan Levine
Greenhorn

Joined: Jan 21, 2001
Posts: 22
I am new to Linux. I installed Redhat Linux 7.0.My main file system
/dev/hda5, mounted on /, is at 98% use(2236716 1K blocks used out of
24192560, according to command df). Is there any way to increase this (the
disk holds 7 GIG) without losing any data or having to re-install
everything? Thanks for any help. Stan
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16141
    
  21

I'm not real happy with RedHat about their default partitioning scheme for a new install. They allocate minimal space for "/" and put the major subdirectories (such as /home and /var) in other partitions. This can lead to serious problems when the /tmp or /root directories get a lot of stuff in them.
Use the following to see what's eating up space:
du -a -x | sort -n
You may see files or directories that can be moved to another location and referenced via softlink. CAUTION. DON'T move "/tmp" that way! If the destination's partition hasn't been mounted yet, you'll experience boot problems.
For a more extreme case, allocate a new partition (preferably a primary one), install a copy of the OS there and redirect LILO to boot out of that partition (making IT be "/"). Then you can free up the original OS partition. It's much easier to do this if you can install to a new drive. For one thing, you are more likely to be able to put the boot code below the problematical 1024-cylinder barrier.
Alternatively, back everything up, re-install RedHat using the custom install option (which will permit you to use Disk Druid and/or fdisk) to partition things YOUR way, and restore the files from your backup.


Customer surveys are for companies who didn't pay proper attention to begin with.
Michael Ernest
High Plains Drifter
Sheriff

Joined: Oct 25, 2000
Posts: 7292

I'm having a private laugh here -- this was one of the things Linux users of 2-3 years ago loved to complain about in Solaris -- a default partitioning scheme that no one likes.
------------------
Michael Ernest, co-author of: The Complete Java 2 Certification Study Guide


Make visible what, without you, might perhaps never have been seen.
- Robert Bresson
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9047
    
  10
I'm having a similar problem.
My df command shows
<pre>Filesystem 1K-blocks Used Available Use% Mounted on
/dev/hda3 2703972 2385812 180808 93% /
/dev/hda2 101107 9327 86559 10% /boot
none 63096 0 63096 0% /dev/shm</pre>

Why doesn't it show others like /dev/hda1 and /dev/hda11?

Why do I have 63096 without a name?

How do I know which files it's safe to move?

I haven't really done anything other than the install except to install the "updates", and the system is already telling me it's running out of room. Why?

It seems that /home and /var are in the same partition (as far as I can tell). /home doesn't have anything new in it except the j2sdk-1_4_1_02-linux-i586-rpm file which I'm thinking I won't even have room to unpack. /var and /tmp don't have anything in them except what the install put there. Can I safely remove some of those files? How do I know which ones? I've already deleted some "duplicate" files -- files with the same name but different version numbers, but I don't see much difference in the df command results.

I'm sorry if these are really basic questions, but I don't really have a clue where to start.

(addendum)Oops. Looks like I deleted something I shouldn't have. When I reboot it says
INIT: Id "x" respawning too fast: disabled for 5 minutes
but at the end of 5 minutes, I get the same message.
[ June 14, 2003: Message edited by: Marilyn de Queiroz ]

JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11478
    
  94

Why doesn't it show others like /dev/hda1 and /dev/hda11?
Try running "<code>echo p | /sbin/fdisk /dev/hda</code>". What System type is /dev/hda1? For example on my system this currently reads:

In my case, /dev/hda1 is not a Linux partition, so I would not expect it to be loaded automagically.
If you do want your partitions loaded automatically, you can put entries into <code>/etc/fstab</code> to tell the system to auto load them ( <code>man fstab</code> will tell you about this file).
Why do I have 63096 without a name?
According to the mountpoint, this is /dev/shm - from memory this is Virtual memory file system support. This will be allocated from your swap space, not from your / partition.
How do I know which files it's safe to move?
Because the system still boots? If it doesnt boot, you shouldnt have moved that last file! :roll:
Seriously, this is a bit arcane. But if you consider that /opt and /usr are meant for optional software and user software respectively, then neither of them should contain software that is required before partitions are mounted. You do need to make sure that either the partition you move files to is also automatically mounted, or that you do not have any software in those directories that gets started automatically. But otherwise you should be safe with them.
As an alternate to Tim's method of finding large files, I tend to use the command "<code>du -ks * | sort -n</code>" to find out which directory in the current one is taking up the most amount of space:

Ooops - I know I am the worst culprit on my home directories. Then I go into that directory, and repeat the command. Hopefully along the line I will find something that can be moved or deleted.
Regards, Andrew
[ June 15, 2003: Message edited by: Andrew Monkhouse ]

The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11478
    
  94

/var and /tmp don't have anything in them except what the install put there. Can I safely remove some of those files? How do I know which ones?
My basic rule of thumb for /tmp: reboot the system, and see which files in that directory have been modified at (or around) the boot time: dont delete them. Usually most other files can go.
/var usually contains lots of directories used by the different subsystems (e.g. mail, news, syslog). The files inside these directories should be maintained by OS. But if you are running standard cron, and turning your machine off every night (or every weekend) then the script to clean up some of these directories may not be running. If these directories seem to be taking up large amounts of space, let us know and we will tell you more about cleaning them up.
(addendum)Oops. Looks like I deleted something I shouldn't have. When I reboot it says
INIT: Id "x" respawning too fast: disabled for 5 minutes
but at the end of 5 minutes, I get the same message.

Take a look at this FAQ on your error message - does it help?
Regards, Andrew
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9047
    
  10
Originally posted by Andrew Monkhouse:
Take a look at this FAQ on your error message - does it help?

Does it help? Yes and no. It tells me that I've deleted something I shouldn't have deleted. But it seems like I have to be able to login to fix it, or is there another way to undelete a file without being logged in? Do I need to reinstall Linux now?
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11478
    
  94

Hi Marilyn
Do I need to reinstall Linux now?
It is rare that you have to reinstall Linux, however you may want to, just to save yourself the effort of trying to fix the problem.
I would recommend that if you can afford the time, and are willing to try, then you should try and fix the problem rather than reinstalling, since you will then be in a more knowledgable position to fix things if something goes wrong later and you dont have the option of reinstalling (or you dont have backups).
If you do want to try and fix it, then read on...
But it seems like I have to be able to login to fix it
Yes, I think you will have to log in. Can you do that? (Ignoring the messages that appear every few minutes). If the login prompt has disapeared because of the messages, just pressing enter may provide you with a new login prompt.
or is there another way to undelete a file without being logged in?
In a worst case scenario, you can boot into single user / maintenance mode. This bypasses the multi user, networking, and graphics startup routines, and just dumps you at a shell prompt with root priveliges. It is difficult to work in this mode, so normally people only use it to recover from drastic situations. If you cannot get a normal login prompt, then let me know and I will try and walk you through getting into single user mode.
By the way, it would help to know the make and version of the distribution you are using (e.g. RedHat, Debian, Mandrake etc. and version 7.1, 8.0, potato etc).
Previously, were you booting into a graphical login screen? If so, then the first thing I would recommend is changing your runlevel so that it does not keep putting those log messages on screen. Login as root, and enter the command "<code>telinit 3</code>". This will change your runlevel from 5 (graphics (or at least attempting to go into graphics)) to 3 (standard text mode).
You might also want to change the system to boot into a text mode in case you cant fix everything at once. While loged in as root, edit the file "<code>/etc/inittab</code>". Look for the line
Change the 5 to a 3, and save the file. Next time you boot, you should get a text login prompt.
Then we can start looking at how to fix the problem. To do this, we need to know what was deleted and what distribution (and version) of Linux you are using.
Regards, Andrew
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11478
    
  94

Hi Marilyn
If you cannot get a normal login prompt, then you could try and go into single user mode, and make the same change to <code>/etc/inittab</code> that I mentioned earlier.
To do this, you need to know whether you are booting using lilo or grub.
Lilo (old format) gives you a prompt <code>lilo:</code> with a timeout before booting. new format gives you a graphical screen with the text somewhere on it something like "press Ctrl-X for text mode".
Grub should give you a graphical screen, with options like "press c for console, e to edit ....".
When you know which one you are using, you can follow the RedHat Booting Single-User Mode.
The instructions should really be the same, no matter which distribution you are running.
Regards, Andrew
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9047
    
  10
Yes, I think you will have to log in. Can you do that? (Ignoring the messages that appear every few minutes). If the login prompt has disapeared because of the messages, just pressing enter may provide you with a new login prompt.


I'll try that.

In a worst case scenario, you can boot into single user / maintenance mode. This bypasses the multi user, networking, and graphics startup routines, and just dumps you at a shell prompt with root priveliges. It is difficult to work in this mode, so normally people only use it to recover from drastic situations. If you cannot get a normal login prompt, then let me know and I will try and walk you through getting into single user mode.

I won't be able to try this out for a day or so, but I'll let you know.
By the way, it would help to know the make and version of the distribution you are using (e.g. RedHat, Debian, Mandrake etc. and version 7.1, 8.0, potato etc).

RedHat 8.0

Previously, were you booting into a graphical login screen?

Yes.

Then we can start looking at how to fix the problem. To do this, we need to know what was deleted and what distribution (and version) of Linux you are using.

If I can get logged in, I should be able to give you a list of (at least most of) the files I deleted.

Thanks so much for your help, Andrew.
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9047
    
  10
Yes, I think you will have to log in. Can you do that? (Ignoring the messages that appear every few minutes). If the login prompt has disapeared because of the messages, just pressing enter may provide you with a new login prompt.

I was able to do that.

Previously, were you booting into a graphical login screen? If so, then the first thing I would recommend is changing your runlevel so that it does not keep putting those log messages on screen. Login as root, and enter the command "<code>telinit 3</code>". This will change your runlevel from 5 (graphics (or at least attempting to go into graphics)) to 3 (standard text mode).

As soon as I did this, I got an error message
<pre>Starting lpd: /usr/sbin/checkpc: error while loading shared libraries: liblpr.so.0: cannot open shared object file: No such file or directory
/usr/sbin/lpd: error while loading shared libraries: liblpr.so.0: cannot open shared object file: No such file or directory [failed]</pre>

[I]You might also want to change the system to boot into a text mode in case you cant fix everything at once. While loged in as root, edit the file "<code>/etc/inittab</code>". Look for the line

Change the 5 to a 3, and save the file. Next time you boot, you should get a text login prompt.[/I]

I was able to do this.

Then we can start looking at how to fix the problem. To do this, we need to know what was deleted and what distribution (and version) of Linux you are using.

RedHat 8.0 I know I deleted old kernals. I was using Grub. Is there any way I can get the computer to give me a list of the stuff I deleted, you know, like a "trashcan/recycle bin" in Windows? Or is it gone forever?
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11478
    
  94

Andrew: Login as root, and enter the command "<code>telinit 3</code>".
Marilyn: As soon as I did this, I got an error message
<code>Starting lpd: /usr/sbin/checkpc: ....</code>

Hmmm, this sounds like you may have different services starting in runlevel 3 than in runlevel 5.
Try changing to the "<code>/etc/rc.d</code> directory and running <code>diff rc3.d rc5.d</code>. That will show you which services are configured differently in the two runlevels. Anything starting with a capital S is a service that starts in that particular runlevel, anything that starts with a capital K is killed when you leave that runlevel.
When I run this, I get:
Note: in my example above, the two options have lowercase k and s respectivly: this is one way of disabling a service. Had they been uppercase, then I would have been able to see that my adsl service would only be started if I booted into runlevel 3. It would not be started if I booted into runlevel 5.
I suspect that when you run it, you will be told that "<code>S60lpd</code>" only exists in runlevel 3. Meaning that your printer service (lpd: line printer daemon) is only attempting to start in runlevel 3. You can disable this by changing the capital S to a lowercase s. This is the quick and dirty way of fixing things (I do a lot of quick and dirty fixes since I used to a lot of maintenance over dial up modems: I just didn't want to be trying to run tools over links).
By the way, the number between the S and the service itself (in the example for the line printer daemon the number was 60) just helps the sysinit application to work out what order to start the services. So the printer at number 60 will start a long time after networking (which is S10network) - this is necessary because you may have a networked printer defined, so obviously you would need networking before you need the printers.
Is there any way I can get the computer to give me a list of the stuff I deleted, you know, like a "trashcan/recycle bin" in Windows? Or is it gone forever?

It is easier to assume it is gone forever. In practice it depends on what filesystem you are using. From memory RH 8 uses the ext3 filesystem, so your files are gone forever. Earlier versions of RH used the ext2 filesystem. With this filesystem if you had heaps and heaps of time and had not written anything to disk since you deleted the files, then you could recover them. The downside with ext2 was that if your computer was powered down without doing a proper shutdown then on bootup it would check the entire hard drive(s) for errors. I have 170Gb on my server, and when it did this I would not be able to boot for an hour while it checked the drives! ext3 is a journaling file system so it handles unclean shutdowns much better, but it means that when a file is deleted, it is gone (unless you take the drive to a disk recovery specialist maybe).
Anyway, unless you deleted any files from /var/lib/rpm you should be able to find out what RedHat believes you should have installed. The trick is to ask RedHat to verify it's packages. You do this by giving the <code>--verify</code> option to rpm. To give you an example, you could verify the kernels you have installed by typing:
<code> rpm --verify kernel</code>
When I run this on my machine I get the response:
<code> .M...... /dev/shm
.M...... /dev/shm</code>
(The entry appeared twice because I have two kernels loaded).
This response tells me that mode has been changed on the /dev/shm file since it was installed. For an explanation of what the entries in that .M..... means, you can <code>man rpm</code> which will give you the following entries:
<code> S file Size differs
M Mode differs (includes permissions and file type)
5 MD5 sum differs
D Device major/minor number mis-match
L readLink(2) path mis-match
U User ownership differs
G Group ownership differs
T mTime differs</code>
In your case I wouldn't worry about changed files: only deleted files.
If I tried to verify a package where I had deleted files, the output would tell me explicitly that files are missing:
<code> [andrewm@andrewm andrewm]$ rpm --verify aterm
S.5....T /usr/X11R6/bin/aterm
S.5....T d /usr/X11R6/man/man1/aterm.1.gz
missing /usr/doc/aterm-0.4.0
missing d /usr/doc/aterm-0.4.0/ChangeLog
missing /usr/doc/aterm-0.4.0/doc
...</code>
So the aterm executable and man file are the wrong size, MD5 doesnt match, and the last modified time is wrong. Then all the documentation is missing.
(Side note: normally if you saw something like this you should be very worried: it is a possible sign that you have been hacked. In this particular case, I do know what has gone on, so I am not worried).
If I wanted to restore all those files in the aterm package, I could tell the system to install it, overwritting the package that it thinks is already installed:
<code> rpm --freshen --replacepkgs /mnt/cdrom/RPMS/aterm*</code>
Note: I tend to use the "freshen" option rather than the install option, since it will only freshen an installed package - it will not install a package that is not already installed. So the command I listed above would only try and re-install aterm if I had it installed already.
Normally RedHat is very good with keeping old configuration files. So if you tried to do a freshen on all rpms on your installation media, it will normally try and be logical about your existing configuration files. Where it thinks your existing configuration file should be OK, it will leave it alone, and rename the sample configuration file that is included in the package as *.rpmnew. But there are times when it is unsure about your existing configuration, so it will name your existing configuration to *rpmold or *rpmsave and then put the standard configuration in its place.
So if you did decide to just freshen all your installed RPMs, then afterwards you would have to find all the rpmold or rpmsave files and check what the difference is between them and the versions currently running.
If you are not feeling so brave, you could try running the following script. It will try and create a list of packages that are installed that are missing files. You can then look at the items on that list one by one to determine what you need to do.

When this is complete you will get a file in your current directory named "<code>packagesMissingFiles.out</code>" containing entries such as the following (from my system):

You can then look at this and work out whether the package is important to you right now, and whether you want to recover it. If the packages' configuration files are still intact (if any exist) then you can decide whether to back them up before you attempt recovery.
Hope something in this helps.
Regards, Andrew
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9047
    
  10
Try changing to the "/etc/rc.d directory and running diff rc3.d rc5.d. That will show you which services are configured differently in the two runlevels. Anything starting with a capital S is a service that starts in that particular runlevel, anything that starts with a capital K is killed when you leave that runlevel.

I get nothing -- just the command prompt back. (I tried rc0.d and rc3.d just to make sure it worked, and I got lots of differences then).

Anyway, unless you deleted any files from /var/lib/rpm you should be able to find out what RedHat believes you should have installed. The trick is to ask RedHat to verify it's packages. You do this by giving the --verify option to rpm. To give you an example, you could verify the kernels you have installed by typing:rpm --verify kernel

Now this is kinda weird. Even though I'm running "Kernel 2.4.20-13.8 on an i686", I get a bunch of missing files beginning with
missing /boot/System.map-2.4.18-14
missing /boot/config-2.4.18-14
(more of the same)
.M...... /dev/shm
missing /lib/modules/2.4.18-14
(many more of the same)
missing /boot/System.map-2.4.18-27.8.0
(5 files ending with 2.4.18-27.8.0)
.M...... /dev/shm
.M...... /dev/shm

Why is it looking for 2.4.18 stuff?

If I wanted to restore all those files in the aterm package, I could tell the system to install it, overwritting the package that it thinks is already installed:
rpm --freshen --replacepkgs /mnt/cdrom/RPMS/aterm*


A more practical question is Where should I freshen/replace the missing kernel files? I would think that /mnt/cdrom/... would be the wrong directory. Maybe something like
rpm --freshen --replacepkgs /lib/modules/2.4.18-26.8.0/*
??

Normally RedHat is very good with keeping old configuration files. So if you tried to do a freshen on all rpms on your installation media ...

How would I do that?
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11478
    
  94

OK - I am going to ignore the lpd issue for the moment. If your printer was working before, I guess it is not working now, so when you fix everything else, then it will get fixed at the same time. If it wasn't working before then nothing has changed except that you are now aware that the system is complaining at boot time. (If you want to stop the complaining, go into /etc/rc3.d/ and find the file S??lpd (possibly S60lpd) and change the capital S to a lowercase s. But you dont have to worry about this for now - it should just be a boot time warning, after which the lpd will not be running.

Now this is kinda weird. Even though I'm running "Kernel 2.4.20-13.8 on an i686", I get a bunch of missing files beginning with
missing /boot/System.map-2.4.18-14
missing /boot/config-2.4.18-14
(more of the same)
.M...... /dev/shm
missing /lib/modules/2.4.18-14
(many more of the same)
missing /boot/System.map-2.4.18-27.8.0
(5 files ending with 2.4.18-27.8.0)
.M...... /dev/shm
.M...... /dev/shm
Why is it looking for 2.4.18 stuff?

This sounds like you started with a 2.4.18 kernel, and later upgraded or installed the 2.4.20 kernel. RedHat believes both kernels are installed, so when you asked for a verification of package 'kernel' it tried to verify both packages, and found that some files were missing from the 2.4.18 kernel. I would advise against your trying to recover the missing files from the 2.4.18 kernel - it is probable that doing so would downgrade your running kernel. You can verify if the system thinks you have kernel 2.4.18 installed by running:
<code>rpm -q kernel-2.4.18</code>
If it responds with the package name, then you know it is installed.
If you are planning on trying to recover all packages (which I will describe later) then you probably want to make RedHat think that you no longer have the old kernel installed. You should be able to do this by:
<code>rpm -e --justdb kernel-2.4.18</code>
This will remove the entry from the RPM database, without touching any files on the hard drive. This may leave some orphaned files around, but this is preferable to deleting some required files.
rpm --freshen --replacepkgs /mnt/cdrom/RPMS/aterm*
A more practical question is Where should I freshen/replace the missing kernel files? I would think that /mnt/cdrom/... would be the wrong directory. Maybe something like
rpm --freshen --replacepkgs /lib/modules/2.4.18-26.8.0/*

The example command line I gave is telling RPM to freshen the package. RPM will work out where the files should go from the package itself. So the option on the command line is the fully qualified path to the package. Not to the missing file(s).
So if you tried to do a freshen on all rpms on your installation media ...
How would I do that?

Carefully Seriously, I am glad that you noticed the kernel issue before trying to do an automated freshen. Fortunately the kernel is the only package I know of where RPM will happily install two different versions of the same package side by side. In all other cases, an upgrade will remove the old package first.
Now - since you have been doing upgrades, this is going to be a little bit more complicated. I am going to add a couple more posts to follow this one with some alternate suggestions. I will put them in seperate posts so that it is obvious that they are alternatives, and you don't have to follow both suggestions.
Regards, Andrew
[ July 17, 2003: Message edited by: Andrew Monkhouse ]
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11478
    
  94

Actually, by the time I got to the second post, I realised that one of my two alternatives was not going to gain anything, and would require too much spare hard drive space (which you didn't have or you wouldn't have gotten into this problem). So I am only offering the one option.
It is programattically possible to work out what packages you have installed. The following command will do that:
<code>rpm --query --all --queryformat "%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}.rpm\n"</code>
Hopefully that is fairly self explanitory - I am doing a query of all packages installed, and having the output show the package name, version number, release number, and architecture followed by a ".rpm" (because the package should be in an rpm file).
So, all we need to do is load the CD(s) containing your original installation packages, and then try and freshen any matching packages. The following script should do that (sorry, I have not been able to test this - if you want me to, I should be able to set up a test box on the weekend to see if it is Ok.

Note that this assumes that all your packages are on RedHat standard CDs. You would have to load the CDs one by one and run this script for each of them to ensure that you have freshened all your installed packages.
Since this script is looking at package names including version and release numbers, it should not retrograde any of your updates.
If you have updated packages somewhere else, then you will have to:
  • remove the commands that mount, umount, and eject the cdrom.
  • remove the commands that change directories.
  • change to the directory where your updates are.
  • run this script from that directory.
    Regards, Andrew
    [ July 17, 2003: Message edited by: Andrew Monkhouse ]
  • Marilyn de Queiroz
    Sheriff

    Joined: Jul 22, 2000
    Posts: 9047
        
      10
    I am going to ignore the lpd issue for the moment. If your printer was working before, I guess it is not working now, so when you fix everything else, then it will get fixed at the same time. If it wasn't working before then nothing has changed except that you are now aware that the system is complaining at boot time. (If you want to stop the complaining, go into /etc/rc3.d/ and find the file S??lpd (possibly S60lpd) and change the capital S to a lowercase s. But you dont have to worry about this for now - it should just be a boot time warning, after which the lpd will not be running.

    Printer (it finally sinks in) ... I have no printer connected to this box. That might give me an error, mightn't it. Anyway, when you say change the 'S' to an 's', are you talking about renaming the file?

    So, all we need to do is load the CD(s) containing your original installation packages, and then try and freshen any matching packages. The following script should do that

    Do I need to save this script in an executable file in order to use it?

    How is freshening all my files different from reinstalling?

    I probably have updated rpms somewhere because I kept getting updates from the RedHatNetwork and I would install the updates as they became available. I'm not sure whether the updated rpm's replaced the rpm's I already had or whether they just installed over the internet without downloading the files. But I'll just forget about that part for now.

    rpm -e --justdb kernel-2.4.20

    Is there a way to reverse this command and make the files available again? Would
    rpm --rebuilddb --justdb kernel-2.4.20
    work?

    Thank you for being so patient with me.
    Andrew Monkhouse
    author and jackaroo
    Marshal Commander

    Joined: Mar 28, 2003
    Posts: 11478
        
      94

    Printer (it finally sinks in) ... I have no printer connected to this box. That might give me an error, mightn't it.

    It might - or it might not. And the error may not be what you are expecting - from memory there used to be an error "printer on fire" which was output whenever the lpd could not work out what was wrong with the printer (not out of paper, not jamed, not out of ink, hmmm: tell them it's on fire and they will run to the printer ).
    But if you don't have a printer connected, then you probably dont need the printer daemon.
    Anyway, when you say change the 'S' to an 's', are you talking about renaming the file?
    Yes - rename the startup script that attempts to start the printer daemon.
    Do I need to save this script in an executable file in order to use it?

    Yes, save that script into a plain text file, then make it executable by running "<code>chmod +x </code><filename>".
    How is freshening all my files different from reinstalling?

    Lots of little things, probably none of which is important to you for this exercise...
    Freshening your files will generally keep your existing configurations. If all configuration was done during installation, this may not mean anything to you, but if you ever had to tweak configurations to get them to work properly then having the existing configurations kept is a very nice thing (I typically modify my X Windows System configuration file, and add scripts to provide all users with Oracle environmental variables, and of course all the firewall rules are saved etc.)
    You also do not have to reselect which packages to install. If you had gone with one of the default install options (desktop / server) and have not added or removed any packages since then, then this may not mean anything, but if you have a customised system, then you probably do not want to reselect all those packages from the lists all over again.
    Also, depending on what sort of installation you do, you may loose whatever non packaged software you have as well as any user data.

    rpm -e --justdb kernel-2.4.20
    Is there a way to reverse this command and make the files available again? Would
    rpm --rebuilddb --justdb kernel-2.4.20
    work?

    Remember that this command is only removing the database entries: it is not actually removing anything from the hard drive. So the files are always available.
    If you want to put the entries back in the rpm database, you were close: the correct command would be:
    <code>rpm -i --justdb kernel-2.4.20</code>
    or to spell it out:
    <code>rpm --install --justdb kernel-2.4.20</code>

    Thank you for being so patient with me.

    No drama - it is nice that I am able to provide help sometimes instead of just asking questions.
    Regards, Andrew
    Marilyn de Queiroz
    Sheriff

    Joined: Jul 22, 2000
    Posts: 9047
        
      10
    rpm -i --justdb kernel-2.4.20

    error: open of kernel-2.4.20 failed: No such file or directory

    rpm -i --justdb kernel-2.4.20-13.8
    error: open of kernel-2.4.20-13.8 failed: No such file or directory

    But rpm --verify kernel-2.4.20 gives me
    .M...... /dev/shm

    and rpm --verify kernel gives me
    .M...... /dev/shm

    and rpm --verify kernel-2.4.20-13.8 gives me
    .M...... /dev/shm


    ps. I found the up2date rpm files in the /var/spool/up2date directory. There are a bunch of them, but most of them are pretty small. The total size is 242280. This includes kernel-2.4.20-13.8.i686.rpm, kernel-2.4.18-26.8.i686.rpm, kernel-2.4.18-27.8.i686.rpm, and kernel-2.4.18-24.8.i686.rpm

    Maybe I shouldn't upgrade my kernel each time a new one becomes available?
    [ July 18, 2003: Message edited by: Marilyn de Queiroz ]
    Andrew Monkhouse
    author and jackaroo
    Marshal Commander

    Joined: Mar 28, 2003
    Posts: 11478
        
      94

    Sorry, my bad. To install (even just to install records into the database) we need to give the name of the package. So that command should be:
    <code>rpm -i --justdb /mnt/cdrom/RedHat/RPMS/kernel-2.4.20-13.8.i586.rpm</code>
    (Substituting the location of the RPM if it is not on the CD, and substituting the architecture if it is not a 586).
    You need to give the name of the package as it exists on your hard drive for any installation or upgrade.
    To query, verify, or delete a package, you need to provide the base name (optionally with a version number) for the package.
    Assuming the file the package is shipped in is in your current directory, you could install, upgrade, or freshen your kernel by typing:
    <code><pre> rpm -i kernel-2.4.20-13.8.i586.rpm
    rpm -U kernel-2.4.20-13.8.i586.rpm
    rpm -F kernel-2.4.20-13.8.i586.rpm</pre></code>
    To query or erase a package, you do not need the file the package is shipped in. You cannot specify the architecture or the suffix ".rpm". So a query or erase would be:
    <code><pre> rpm -q kernel-2.4.20-13.8
    rpm -e kernel-2.4.20-13.8</pre></code>
    Technically you do not need the version numbers for a query or an erase either, but for the kernel, it is a good idea, otherwise you do not know which one is being referenced.

    (Ignore my directory structure: you wont have the same structure on your system).
    Maybe I shouldn't upgrade my kernel each time a new one becomes available?

    Hmmm, that is a really hard call. In an ideal world, we would check why a package is being upgraded, and only upgrade it if we need the upgrade. So, only upgrade if it gives us something new, or if it fixes a security issue. But checking each update can be a full time job. Personally I keep all my packages at the latest release provided by RedHat or a later release.
    Regards, Andrew
    [ July 19, 2003: Message edited by: Andrew Monkhouse ]
    Marilyn de Queiroz
    Sheriff

    Joined: Jul 22, 2000
    Posts: 9047
        
      10
    When I type
    ls -l fr*
    I get
    -rwsr-xr-x 1 root root 434 Jul 19 20:15 freshen.script
    -rwxr-xr-x 1 root root 388 Jul 19 20:38 freshenUp2date.script


    However typing
    freshen.script or freshenUp2date.script gave me
    -bash: freshen.script: command not found.

    I don't understand why they don't execute.

    But, the good news is that I did manage to run both scripts by typing
    . freshen.script and . freshenUp2date.script

    I still get an error when I type
    man cp for example.
    The error is
    /usr/bin/gtbl: error while loading shared libraries: libstdc++.so.5: cannot open shared object file: No such file or directory
    groff: error while loading shared libraries: libstdc++.so.5: cannot open shared object file: No such file or directory

    If I type startx I get
    [i]/usr/bin/gnome-session: error while loading shared libraries: libgtk-x11-2.0.so.0: cannot open shared object file: No such file or directory

    It seems that freshening the files didn't help ??
    Andrew Monkhouse
    author and jackaroo
    Marshal Commander

    Joined: Mar 28, 2003
    Posts: 11478
        
      94

    Hi Marilyn,
    Irrelevant waffle first:

    Mode rws....?
    to create this, you would have had to type: <code>chmod 4755 freshen.script</code> or <code>chmod +s freshen.script</code>
    This may be old hat to you, but just in case it isn't ... Setting the sticky bit (mode s) means that the program being run will be run as though the owner is the person running it. So for example, there is the program ping:

    Any user can run the program ping. But when it runs, it runs with the permissions and authority of the root user, since sticky bit is on.
    While this can be very useful, it is a security risk: say you set the sticky bit on a program like "vi" or "emacs". Then any user could run the editor on any file anywhere in the system. And since those two editors allow the user to drop to the shell, they could effectively get root priviledges through this.
    Because of the potential for misuse, setting the sticky bit on a script is silently ignored by many Unix operating systems (Linux included). So setting the sticky bit on the freshen.script does nothing.
    Now back to your problems....
    However typing
    freshen.script or freshenUp2date.script gave me
    -bash: freshen.script: command not found.
    I don't understand why they don't execute.
    But, the good news is that I did manage to run both scripts by typing
    . freshen.script and . freshenUp2date.script

    Many Unix users set their executable PATH to include the current directory "." so that if they type the name of a program and it is in their current directory, the shell will find it and execute it. Several Linux distributions also set this automatically for end users as well, as it helps when people are coming over from working in MS Dos, where it is built into the OS that the current directory is in the path.
    However this is also a security risk, as a malicious user could create a program with the same name as a standard utility, get someone with higher priveledges to come over to their machine and run it, doing all sorts of things behind the privelidged user's back (trojan horse attack). For this reason, every system I have ever worked on does not put the current directory into the PATH for the root user.
    This is why just typing the name of the script did not work - the shell did not know to look in the current path.
    What you should do is either type the full path to the script: <code>/root/freshen.script</code> or provide the relative path to the script: <code>./freshen.script</code> - note the leading period (".").
    I still get an error when ...

    Hmmm, I wonder if some packages were not freshened properly. Try finding out what package provides libstdc++.so.5 by typing:
    <code><pre> rpm -q --whatprovides libstdc++.so.5 </pre></code>
    On my system it repsonds with:
    <code><pre> libstdc++-3.2.2-5</pre></code>
    I think for RedHat 8.0 it should be libstdc++-3.2-7.
    Then verify just that package (substituting your own package name of course):
    <code><pre> rpm --verify libstdc++-3.2.2-5</pre></code>
    Any errors?
    If you still have errors, then it is possible (probable) that when you ran those scripts, they did not find the file to freshen with. (If you don't have errors, stop and let me know - I will have to think some more.
    Try getting the full package name:
    <code><pre> rpm -q --qf "%{NAME}-%{VERSION}-%{RELEASE}-%{ARCH}.rpm\n" libstdc++-3.2.2-5</pre></code>
    On my system that responded with:
    <code><pre> libstdc++-3.2.2-5-i386.rpm</pre></code>
    I think there were no updates to this package for RedHat 8, so it would not be in your /var/spool/up2date directory - it should be on one of your CDs. Try mounting each CD in turn, and typing <code>ls -l /mnt/cdrom/RedHat/RPMS/libstdc++-3.2-7.i386.rpm</code>
    Keep swapping CDs until you find the one that has it.
    The size should be 4181584 bytes (if I am right about the version number).
    Try freshening it manually: <code>rpm --freshen --replacepkgs /mnt/cdrom/RedHat/RPMS/libstdc++-3.2-7.i386.rpm</code>
    And then check again if there are errors: <code>rpm --verify /mnt/cdrom/RedHat/RPMS/libstdc++-3.2-7.i386.rpm</code>
    If there are still errors then we may have to try and force the freshen:
    <code>rpm --freshen --replacepkgs --force /mnt/cdrom/RedHat/RPMS/libstdc++-3.2-7.i386.rpm</code>
    Regards, Andrew
    Marilyn de Queiroz
    Sheriff

    Joined: Jul 22, 2000
    Posts: 9047
        
      10
    Oops. Typo alert

    When I type
    ls -l fr*
    I get
    -rwxr-xr-x 1 root root 434 Jul 19 20:15 freshen.script
    -rwxr-xr-x 1 root root 388 Jul 19 20:38 freshenUp2date.script


    But thanks for the warning. I'll be very careful to not accidentally substitute 's' for 'x' in chmod.
    Marilyn de Queiroz
    Sheriff

    Joined: Jul 22, 2000
    Posts: 9047
        
      10
    However this is also a security risk, as a malicious user could create a program with the same name as a standard utility, get someone with higher privileges to come over to their machine and run it, doing all sorts of things behind the priviliged user's back (trojan horse attack). For this reason, every system I have ever worked on does not put the current directory into the PATH for the root user.

    [tangent]Do you think that this might be why Sun didn't put the '.' by default into the classpath originally?[/tangent]

    Hmmm, I wonder if some packages were not freshened properly. Try finding out what package provides libstdc++.so.5 by typing:

    <code><pre> rpm -q --whatprovides libstdc++.so.5 </pre></code>


    On my system it repsonds with:
    libstdc++-3.2-7

    [I]Then verify just that package (substituting your own package name of course):


    On my system that responded with:

    libstdc++-3.2-7-i386.rpm

    [I]it should be on one of your CDs. Try mounting each CD in turn, and typing [/I]

    Keep swapping CDs until you find the one that has it.

    I found it on CD 1 of 3

    The size should be 4181584 bytes (if I am right about the version number).

    Mine is 1478392 bytes. This seems significantly smaller.

    [I]Try freshening it manually:

    And then check again if there are errors: [/I]

    package /mnt/cdrom/RedHat/RPMS/libstdc++-3.2-7.i386.rpm is not installed

    If there are still errors then we may have to try and force the freshen:


    I get the same error after this step. Maybe I should try ??
    [ July 20, 2003: Message edited by: Marilyn de Queiroz ]
    Andrew Monkhouse
    author and jackaroo
    Marshal Commander

    Joined: Mar 28, 2003
    Posts: 11478
        
      94

    Hi Marilyn
    I have done it again - i really shouldnt be on the computer this late at night.
    The following command I gave you is wrong:<code>rpm --verify /mnt/cdrom/RedHat/RPMS/libstdc++-3.2-7.i386.rpm</code>
    As I said earlier - for the verification, we should not be specifiying the file the package was shipped in. This is why you got the error stating that the package was not installed.
    Sorry.
    Try <code>rpm --verify libstdc++</code> now that you have done the forced freshen.
    If you still have missing files from that package, then you may have to perform the install as you suggested.
    By the way, check your <code>/etc/sysconfig/rhn/up2date</code> file. There should be a couple of lines in there like:

    Is yours set to zero as well? If so, then you are only keeping the header information for the packages you have upgraded - you will have to download them again if they are missing files.
    Regards, Andrew
    Marilyn de Queiroz
    Sheriff

    Joined: Jul 22, 2000
    Posts: 9047
        
      10
    i really shouldnt be on the computer this late at night.

    What time is it now where you are?

    Try <code>rpm --verify libstdc++</code> now that you have done the forced freshen.

    still missing
    If you still have missing files from that package, then you may have to perform the install as you suggested.


    seems to have worked.... no more error when I type

    By the way, check your <code>/etc/sysconfig/rhn/up2date</code> file. Is yours set to zero as well? If so, then you are only keeping the header information for the packages you have upgraded - you will have to download them again if they are missing files.

    Mine is set to '1', but remember that I tried manually deleting files originally and that's probably where I went wrong, deleting files, headers, and who knows what else
    Marilyn de Queiroz
    Sheriff

    Joined: Jul 22, 2000
    Posts: 9047
        
      10
    Getting that file seems to have fixed the "startx" command as well.
    Andrew Monkhouse
    author and jackaroo
    Marshal Commander

    Joined: Mar 28, 2003
    Posts: 11478
        
      94

    Excellent
    What time is it now where you are?

    Right now in Sydney: 2am. Time for me to go.
    Regards, Andrew
    Ashok Pancharya
    Greenhorn

    Joined: Feb 18, 2004
    Posts: 1
    My Linux partition is filled up and I have some space on my Windows98 partition. Is there any way I can expand my Linux partition size and reduce the Windows98 partition size?
    I am using Fedora Core 1.
    Thanks for any help.
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Increasing Disk Partition Size on Linux