2

I've resized many partitions over the years on Linux, Windows and Mac OS X -- but always using a GUI. However, the time has come where the preset partition sizes my data center placed on my server aren't the right sizes and I need to resize a production server's disks. I could fiddle with it and probably do OK, but given that it is a production server, I wanted to get some advice about the right way to do this. I do have KVM over IP access, so if it is best to take the server offline and boot off a rescue partition, I can do that.

root [/var/lib/mysql]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda2       9.9G  2.1G  7.3G  23% /
tmpfs           7.8G     0  7.8G   0% /dev/shm
/dev/sda1        99M   77M   18M  82% /boot
/dev/sda8       884G  463G  376G  56% /home
/dev/sda3       9.9G  8.0G  1.5G  85% /usr
/dev/sda5       9.9G  9.1G  308M  97% /var
/usr/tmpDSK     2.0G   38M  1.8G   3% /tmp

As you can see /var and /usr are quite close to being full and I've actually had to symlink some logs on /usr to directories in /home to balance things out. What I would like to do is to add 6-10 GB each to /usr and /var, presumably taking the space from /home.

As I think about how the disk is arranged, the best thought I've come up with is to reduce /home by 16 GB, say, and move /var to the spot freed up, then allocating /var's space to /usr. However, that would put /var at the far end of the disk, which seems less than idea, given that MySQL has all of its data on that partition. I'd love to take the space out of the closer end of /usr, but I assume that would take a very arduous (and perhaps risky) process of moving all of the data in /usr around. I seem to recall having such a process fail for me on a computer in the past.

The other option might be to merge / and /usr since / is underutilized, though I'm not sure if that's a good idea.

Do you have any suggestions both on the best reallocation plan and the commands to use to accomplish it?

UPDATE: I should add -- here's the partition table. There's one unused partition, which, if memory serves, was the original tmp location before I created a tmp image:

    Name        Flags      Part Type  FS Type          [Label]      Size (MB)
 ------------------------------------------------------------------------------
                                      Unusable                      1.05*
    sda1        Boot        Primary   Linux ext2                    106.96*
    sda2                    Primary   Linux ext3                    10737.42*
    sda3                    Primary   Linux ext3                    10737.42*
    sda5        NC          Logical   Linux ext3                    10738.47*
    sda6        NC          Logical   Linux swap / Solaris          2148.54*
    sda7        NC          Logical   Linux ext3                    1074.80*
    sda8        NC          Logical   Linux ext3                    964098.53*
1

Re-sizing /var and /home and /usr on a live system is a bad idea. I recommend taking a downtime for this maintenance.

For the future, I'd also recommend that you expand your scope for this and look into setting up LVM on the server, so that you would have the opportunity to do live adjustments if needed, and have less worry about where data is actually allocated on the disk. Here is a link to a decent tutorial on how to do that.

If you do decide to resize partitions without LVM, the commands you are running from your recovery disk are roughly:

  • umount [fs]
  • resize2fs [fs] [shrunk size]
  • fdisk /dev/sda
  • resize2fs [fs]
  • fsck [fs]
  • mount [fs]

The critical command above is fdisk /dev/sda. What you will do there is delete the and recreate the partitions as needed for your adjustments. Just be sure that you are watching where your filesystems are actually stored during that operation, and have a good backup on hand.

  • Thanks for your help, @Travis! Hmm... LVM sounds sensible, though it seems complicated by trying to move the entire system (including /boot) around. The only way I can think of how to do it using the instructions given in that tutorial would be to add another non-RAID drive, set everything up on it and then move it back onto the RAID array (just a two disk RAID1). If I resize without LVM, do you think it would be at all practical to shrink the big partition from "the left" or do I need to go from the right as I was surmising above? – Timothy R. Butler Jun 2 '14 at 1:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.