-1

My /var is full and need to extend its size. I tried different ways but could not succeed. Cent os 7 with two 1 TB HDD RAID 1 Configured. I have added 2 TB HDD to add space for /var.

**# output for fdisk -l**

Disk /dev/sda: 1000.2 GB, 1000204886016 bytes, 1953525168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk label type: dos
Disk identifier: 0x00023fda

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     2101247     1049600   fd  Linux raid autodetect
/dev/sda2         2101248   393244671   195571712   fd  Linux raid autodetect

Disk /dev/sdc: 1000.2 GB, 1000204886016 bytes, 1953525168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk label type: dos
Disk identifier: 0x0006cf87

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1   *        2048     2101247     1049600   fd  Linux raid autodetect
/dev/sdc2         2101248   393244671   195571712   fd  Linux raid autodetect

Disk /dev/sdb: 2000.4 GB, 2000398934016 bytes, 3907029168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/md127: 1074 MB, 1074724864 bytes, 2099072 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/md126: 200.1 GB, 200131215360 bytes, 390881280 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/mapper/centos-root: 200.1 GB, 200085078016 bytes, 390791168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/mapper/centos-swap: 41 MB, 41943040 bytes, 81920 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

**# df -h**
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root  184G  174G     0 100% /
devtmpfs                 1.8G     0  1.8G   0% /dev
tmpfs                    1.9G     0  1.9G   0% /dev/shm
tmpfs                    1.9G  8.5M  1.8G   1% /run
tmpfs                    1.9G     0  1.9G   0% /sys/fs/cgroup
/dev/md127               976M  145M  764M  16% /boot
tmpfs                    370M     0  370M   0% /run/user/0
Sven
  • 97,248
  • 13
  • 177
  • 225

1 Answers1

0

@Iain: not really a duplicate of Move /var to new set of disks.

You have a much bigger problem than merely /var being full. Your / is full and your machine will crash soon (if not already).

You do not seem to have a separate partition for /var. Your /var is part of your / (root) which is on /dev/mapper/centos-root using LVM. You need to extend the / and put /var on a separate partition.

It is a bit unclear, but a safe bet is that the LVM is on the RAID1 (2x1TB).

A possible solution (similar to a recent re-config I did):

  1. Fail one of the RAID1 (/dev/md127) elements (say /dev/sdc2)
  2. Partition /dev/sdb (2 TB) into 2 equal parts of 1 TB each. Ensure that at least 1 partition is at least 195571712 blocks large (size of existing /dev/sdc2). Tag these partitions to be of type fd
  3. Replace the failed /dev/md127 (old /dev/sdc2) with the appropriate /dev/sdb partition (say /dev/sdb1). Array will start to rebuild.
  4. Create a new array say /dev/md125 containing /dev/sdc2 & /dev/sdb2. Owing to the fact that there is data on /dev/sdc2, this array will attempt to re-build. Let it be - AFAIK, you cannot stop it. Wait for a few hours for the array builds to complete. It is possible that you may have to reboot between steps 3 & 4.
  5. Create a LVM2 physical volume using pvcreate on /dev/md125 & grow the centos VG on it (using vgextend). Using lvextend increase the size of the centos-root logical volume (to say another 100GB or so) and that will take care of your immediate problem. Use the -r (resize filesystem) flag to resize the underlying filesystem.

For the long term, you want to move your /var to a different partition. For that create a var logical volume (of say 100 GB or so), boot into single user mode or better use a rescue disk (to mitigate the open files problem discussed in Move /var to new set of disks), copy the old /var to the new one (after mounting it temporarily), adjust /etc/fstab to mount the new /var. Reboot and you should be set.