0

I have /usr on a separate partition. At the moment, this is how the server is set up:

[root@localhost ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda2       4.9G  329M  4.6G   7% /
devtmpfs        366M     0  366M   0% /dev
tmpfs           372M     0  372M   0% /dev/shm
tmpfs           372M  5.0M  367M   2% /run
tmpfs           372M     0  372M   0% /sys/fs/cgroup
/dev/sda5       997M  871M  127M  88% /usr
/dev/sda1       9.8G   33M  9.8G   1% /home

[root@localhost ~]# lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0   20G  0 disk 
├─sda1   8:1    0  9.8G  0 part /home
├─sda2   8:2    0  4.9G  0 part /
├─sda3   8:3    0  1.5G  0 part [SWAP]
├─sda4   8:4    0    1K  0 part 
└─sda5   8:5    0 1000M  0 part /usr
sr0     11:0    1 1024M  0 rom

while running a yum update a few minutes back, I encountered the following error:

  installing package swig-2.0.10-4.el7.x86_64 needs 397MB on the /usr filesystem
  installing package diffstat-1.57-4.el7.x86_64 needs 397MB on the /usr filesystem
  installing package rcs-5.9.0-5.el7.x86_64 needs 398MB on the /usr filesystem
  installing package byacc-1.9.20130304-3.el7.x86_64 needs 398MB on the /usr filesystem
  installing package ctags-5.8-13.el7.x86_64 needs 399MB on the /usr filesystem
  installing package indent-2.2.11-13.el7.x86_64 needs 399MB on the /usr filesystem

Error Summary
-------------
Disk Requirements:
  At least 399MB more space needed on the /usr filesystem.

At the moment, I'm thinking of reducing the size of /home and allot that to /usr (which is under /dev/sda5). Since this isn't LVM-based, how would I go about reducing the size of /home (by say 1G) and allot it to /usr without deleting either partition?

  • 1
    Wow, that's tiny. I would just start over and reinstall the whole thing, and not create any separate partitions for /usr or /home. You don't have enough disk space for that. – Michael Hampton May 16 '16 at 15:11
1

Its extremely difficult to achieve what you want.

I dont suggest reformatting as there is a means to salvage this.

I'd drop /usr completely by copying the entire contents of it into the /usr mounted in /.

Something like this should work. I haven't tested it.

mkdir /tmp/reroot
mount /dev/sda2 /tmp/reroot
cp -a /usr/. /tmp/reroot/usr/.
vi /etc/fstab # edit fstab to remove /usr mount
reboot
| improve this answer | |
1

You can move some content from /usr to /home with cp then soft linking the old location to the new. For example you can move the yum data folder, I already did it on some server on the past.

| improve this answer | |
  • That's dirty but quite creative :D. Just a note, if selinux is enable must check that policy apply to the symlink content too (don't know, never tried). – Tsumi May 16 '16 at 20:27
0

You can't really resize a basic partition, since partitions are made via physical slices of the disk, so:

sda      8:0    0   20G
├─sda1   8:1    0  9.8G  0     - 9.8G
├─sda2   8:2    0  4.9G  9.8G  - 14,7G
├─sda3   8:3    0  1.5G  14,7G - 16,2G
├─sda4   8:4    0    1K  16,2G - 20G    (LOGICAL PARTITION)
└─sda5   8:5    0 1000M  16,2G(+1K) - 17,2G

You could only extend the last partition to the disk size.

LVM used a logic layer that puts shards of data on disk (no artificial order). Then it is possible to shrink (free data) (needs to be OFFLINE / unmounted) and grow data of every logical volume (by just allowing the volume to allocate more of the physical shards)

In your case you would have to re-arrange most of the data on disk.

I would recommend backup, reformat the disk with boot partition + LVM, and restore the system onto the new layout.

| improve this answer | |
0

Partitions must be continuous on a disc, and as your /home and /usr aren't contiguous you can't do what you're proposing. Even if there were you would have to move the start of onw of them, that's generally very hard.

It depends on the filesystem how you shrink (if you even can) or expand it, and none of output show what filesystem(s) you use.

| improve this answer | |
  • Btw, moving back the start point of a partition, say sda3, is doable with dd if=/dev/sda3 of=/dev/sda bs=1M seek=newstartingblock – Marco Marsala May 16 '16 at 17:18
0

with RHEL7, one can grow file system using xfs_growfs(8), needless to say it is risky and before doing anything like that, make sure you have backup..

I asked similar question about a year ago and @Michael Hampton answer it:

redhat - How to Increase the Size of an XFS File System? - Server Fault

| improve this answer | |

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.