LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to resize a partition or reallocate space? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-resize-a-partition-or-reallocate-space-163748/)

Avatar 03-29-2004 10:22 AM

How to resize a partition or reallocate space?
 
Hello

[off topic: it is very frustrating that I spend 15 - 20 minutes typing a detailed question only to be logged off when I submit it and have to retype the whole thing over again.]

Okay. I have a Linux box (kernel 2.4.18-8) running Squid proxy/cache version 2.4.STABLE7. The Linux box has a 40 GB hard drive. The hard drive's free space isn't allocated as I would like. Here's the current configuration:

Code:

[root@localhost squid]# df
Filesystem      Size      Used          Avail    Use%    Mounted On
/dev/hda5      3.4G      1.2G            2.0G      38%      /
none            251M        0              250M      0%      /dev/shm
/dev/hda7      33G        33M            33G        1%      /home

[root@localhost squid]# df -i
Filesystem      Inodes        IUsed      IFree  IUse%  Mounted On
/dev/hda5      437K          78K        359K      18%    /
none            63K            1          62K      1%    /dev/shm
/dev/hda7      4.2M          38          4.2M      1%    /home

The problem is my squid keeps on running out of space in the cache directory. Here's the logs from cache.log

Code:

2004/03/27 10:29:13| storeDirWriteCleanLogs: Starting...
2004/03/27 10:29:13| storeDirWriteCleanLogs: /var/spool/squid/swap.state.clean: write:
      (28) No space left on device
2004/03/27 10:29:13| storeDirWriteCleanLogs: Current swap logfile not replaced.
FATAL: Received Segment Violation...dying.
2004/03/27 10:29:13| storeDirWriteCleanLogs: Starting...
2004/03/27 10:29:13| storeDirWriteCleanLogs: /var/spool/squid/swap.state.clean: write:
      (28) No space left on device
2004/03/27 10:29:13| storeDirWriteCleanLogs: Current swap logfile not replaced.
[...]
2004/03/27 10:29:16| Set Current Directory to /var/spool/squid
FATAL: logfileWrite: /var/log/squid/store.log: (28) No space left on device

Squid Cache (Version 2.4.STABLE7): Terminated abnormally.

Here's the settings in squid.conf:
---- cache_dir diskd /var/spool/squid 150 16 256

I'm not sure what the numbers mean but I think 150 means that there's only 150 MB of space allocated for caching. I'd like to increase this by a LOT since my squid is crapping out nearly every day. But I only have 2 GB free on the / partition. And it seems like I have 33 Gigs sitting there gathering dust on the /home partition.

So my question is how do I go about moving at least 30 GB to somewhere that squid can access it in the /var/spool/squid directory? And if anyone is familiar with squid, what size should I increase the cache_dir numbers to, so squid stops running out of space?

Thanks!

jailbait 03-29-2004 08:30 PM

You could do this without rearranging your partitions. Move /home back into the / partition, move squid to /dev/hda7 and make the squid directory the mount point for /dev/hda7.

___________________________________
Be prepared. Create a LifeBoat CD.
http://users.rcn.com/srstites/LifeBo...home.page.html

Steve Stites

Avatar 03-30-2004 08:51 AM

Fantastic! How do I do that?

jailbait 03-30-2004 09:30 AM

"How do I do that?"

Boot into a rescue CD.

Mount your two partitions. I am assuming that they use ext3 filesystems. Change the following mounts if they are not.
mkdir /part5
mkdir /part7
mount -t ext3 /dev/hda5 /part5
mount -t ext3 /dev/hda7/part7

Copy /home to / with:
cp -pR /part7/* /part5/home
Check to make sure that /part5/home has everything that it should and that the ownerships are OK by using the ls -l command.
ls -l /part7/*
ls -l /part5/home/*
Then delete he old /home files:
rm -R /part7/*

I am not familiar with the squid directory structure. From your post I assume that the squid directory that you want to be the mount point is /var/spool/squid. If it is something different then adjust thefollowing commands accordingly:
cp -pR /part5/var/spool/squid/* /part7
Check to make sure that /part7 has everything that it should and that the ownerships are OK by using the ls -l command.
ls -l /part7/*
ls -l /part5/var/spool/squid/*
Then delete the old squid files:
rm -R /part5/var/spool/squid/*

Now edit fstab:
vi /part5/etc/fstab
Change the fstab entry for /home to /var/spool/squid

Boot

___________________________________
Be prepared. Create a LifeBoat CD.
http://users.rcn.com/srstites/LifeBo...home.page.html

Steve Stites

Avatar 03-30-2004 01:53 PM

Thans for your most excellent suggestion. I now understand what you mean. Bascially, copy the contents of the larger partition to the smaller one, and move the squid cache to the large 33G partition.

Although it makes sense, it's not precisely what I was hoping for. What I would prefer, is to be able somehow to make the / partition or main partition a little bigger too (maybe 8 Gigs, instead of just 3.4, since that's in theory where everything is) and make the squid cache around 25 Gigs or so. Is it possible?

If not, your suggestion will work for me too. Thanks again :)

jailbait 03-30-2004 03:12 PM

" What I would prefer, is to be able somehow to make the / partition or main partition a little bigger too (maybe 8 Gigs, instead of just 3.4, since that's in theory where everything is) and make the squid cache around 25 Gigs or so. Is it possible?"

Yes. Partitions have to be contiguous. So the way to do it would be to delete partitions /dev/hda5 and /dev/hda7 and every partition between them, if any. This would leave you with a big empty space on your disk which you can then repartition with the new sizes that you want. You will lose everything in the partitions that you delete so you will have to back everything up before you delete any partitions. After you create the new partitions then you format the new partitions' file systems and restore your backups.

In order to figure out what you have to do you need a map of your partitions. To get a map log in as root and issue this command:

fdisk -l /dev/hda

___________________________________
Be prepared. Create a LifeBoat CD.
http://users.rcn.com/srstites/LifeBo...home.page.html

Steve Stites

Avatar 03-31-2004 01:09 PM

Code:

[root@localhost etc]# fdisk -l /dev/hda

Disk: /dev/hda: 255 heads, 63 sectors, 4865 cylinders
Units = cylinders of 16065 * 512 bytes

  Device  Boot  Start      End      Blocks    ID    System
/dev/hda1      *      8    4866    39021916+    5    Extended
/dev/hda4              1        7        56196    fe    LANstep
/dev/hda5              8      453      3582463+    83    Linux
/dev/hda6            454      484      248967    82    Linux swap
/dev/hda7            485    4866    35190382+    83    Linux

Partition table entries are not in disk order

I have more partitions than I thought! But I see how the partitions are allocated. I believe my distro did this automatically when I installed it.

Is it possible to switch them? like put the / directory at /dev/hda7 and the /home directory at /dev/hda5 (rather than the squid cache directory)? Can I do this with the copy/paste method you described?

amanjsingh 03-31-2004 01:29 PM

this thread has been very enlightening one pals. thanx for the Q & A session here was nice. :)

thanx
aman

jailbait 03-31-2004 02:42 PM

"Is it possible to switch them? like put the / directory at /dev/hda7 and the /home directory at /dev/hda5 (rather than the squid cache directory)? Can I do this with the copy/paste method you described?"

Yes. If you move / and/or /boot then you will have to also change your bootloader configuration and reinstall the bootloader.

-----------------------
Steve Stites

Avatar 03-31-2004 02:55 PM

Ok so just to recap. Say I want to switch the locations of / and /home.

1. Copy all the files in the / folder currently at /dev/hda5 to the partition on /dev/hda7

2. Copy all the files in the /home folder currently at /dev/hda7 to the partition on /dev/hda5. Check permissions and erase old files.

3. Edit the /etc/fstab file to reflect the switch.

4. Change the bootloader configuration.

Could you give me more details on step 4, also let me know if I've missed anything? Then i think I'll be all set!

(Of course I'll have to make sure I have a good backup first). Thanks for all your help jailbait.

jailbait 03-31-2004 03:12 PM

Steps 1 and 2 are scrambled somewhat. You are going to end up with everything duplicated in /dev/hda5 and /dev/hda7. Actually, thinking about it, this is OK. Just be selective about what you erase.

You want everything to end up in /dev/hda7 including the /home directory. But the /home directory will be empty. You want the contents of /home to be in /dev/hda5. For example if you have two users named bonnie and clyde then you will end up with /bonnie and /clyde and their contents in /dev/part5.

"4. Change the bootloader configuration.

Could you give me more details on step 4, also let me know if I've missed anything? Then i think I'll be all set!"

What bootloader are you using? Lilo or grub?

--------------------------
Steve Stites

Avatar 04-15-2004 10:44 AM

Hi Steve

Sorry for not getting back to you before, I was having a lot of trouble getting my CD-RW to work (I wanted to back up everything before I try this).

I have decided to move /home into the small partition along with /, and move the entire /var directory into the large partition. So I won't need to change my lilo.

Thanks for the detailed information.

--a

Avatar 04-22-2004 04:11 PM

Quote:

Originally posted by jailbait
"How do I do that?"

Boot into a rescue CD.

Mount your two partitions. I am assuming that they use ext3 filesystems. Change the following mounts if they are not.
mkdir /part5
mkdir /part7
mount -t ext3 /dev/hda5 /part5
mount -t ext3 /dev/hda7/part7

Copy /home to / with:
cp -pR /part7/* /part5/home
Check to make sure that /part5/home has everything that it should and that the ownerships are OK by using the ls -l command.
ls -l /part7/*
ls -l /part5/home/*
Then delete he old /home files:
rm -R /part7/*

I am not familiar with the squid directory structure. From your post I assume that the squid directory that you want to be the mount point is /var/spool/squid. If it is something different then adjust thefollowing commands accordingly:
cp -pR /part5/var/spool/squid/* /part7
Check to make sure that /part7 has everything that it should and that the ownerships are OK by using the ls -l command.
ls -l /part7/*
ls -l /part5/var/spool/squid/*
Then delete the old squid files:
rm -R /part5/var/spool/squid/*

Now edit fstab:
vi /part5/etc/fstab
Change the fstab entry for /home to /var/spool/squid

Boot

___________________________________
Be prepared. Create a LifeBoat CD.
http://users.rcn.com/srstites/LifeBo...home.page.html

Steve Stites

Steve: I followed your directions, and it worked perfectly (the first time!) ;) Thanks so much.


All times are GMT -5. The time now is 02:04 PM.