1

I have a CentOS server with two 1 TB disks. However, it is badly partitioned. Please check below:

[root@p16282558 ~]# fdisk -l

Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0xd4f28eb2

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         523     4194304   fd  Linux raid autodetect
Partition 1 does not end on cylinder boundary.
/dev/sdb2             523         784     2097152   82  Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
/dev/sdb3             784      121602   970470104   fd  Linux raid autodetect
Partition 3 does not end on cylinder boundary.

Disk /dev/sda: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x724abfe3

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1         523     4194304   fd  Linux raid autodetect
Partition 1 does not end on cylinder boundary.
/dev/sda2             523         784     2097152   82  Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
/dev/sda3             784      121602   970470104   fd  Linux raid autodetect
Partition 3 does not end on cylinder boundary.

Disk /dev/md3: 993.8 GB, 993761296384 bytes
2 heads, 4 sectors/track, 242617504 cylinders
Units = cylinders of 8 * 512 = 4096 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000


Disk /dev/md1: 4294 MB, 4294901760 bytes
2 heads, 4 sectors/track, 1048560 cylinders
Units = cylinders of 8 * 512 = 4096 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000


Disk /dev/mapper/vg00-usr: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000


Disk /dev/mapper/vg00-var: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000


Disk /dev/mapper/vg00-home: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000

When I ran df:

[root@p16282558 ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/md1              4.0G  4.0G     0 100% /
/dev/mapper/vg00-usr  4.0G  1.5G  2.4G  38% /usr
/dev/mapper/vg00-var  4.0G  880M  2.9G  23% /var
/dev/mapper/vg00-home
                      4.0G  136M  3.7G   4% /home
none                  7.9G  556K  7.9G   1% /tmp

/opt is within /, and there is no space left in /

My /etc/fstab looks like this:

/dev/md1        /               ext3    defaults        1 1
/dev/sda2   none            swap    sw
/dev/sdb2   none            swap    sw
/dev/vg00/usr   /usr            ext4    defaults        0 2
/dev/vg00/var   /var            ext4    defaults,usrquota   0 2
/dev/vg00/home  /home           ext4    defaults,usrquota   0 2
devpts          /dev/pts        devpts  gid=5,mode=620  0 0
none            /proc           proc    defaults        0 0
none            /tmp    tmpfs   defaults        0 0

So there is a full md1 disk, and a non-utilised Disk /dev/md3 with 993.8 GB free??

But,

[root@p16282558 ~]# df -h /dev/md3
Filesystem            Size  Used Avail Use% Mounted on
-                     7.9G  204K  7.9G   1% /dev

Does this mean /dev is not being mounted at system start (as per fstab)?

Output of vgdisplay:

--- Volume group ---
  VG Name               vg00
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                3
  Open LV               3
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               925.51 GiB
  PE Size               4.00 MiB
  Total PE              236931
  Alloc PE / Size       3072 / 12.00 GiB
  Free  PE / Size       233859 / 913.51 GiB

My problem is: /opt should be mounted in a disk/partition with more space. How can I restructure the disk to utilize all disk space in an efficient way?

5
  • fdisk shows you have 2 1TB drives, likely in a raid-1. df shows you only have 24GB of mounted filesystems. Where is the rest of the space? It does appear you are using LVM, what is the output of vgdisplay? You might have a ton of unallocated space in your volume group you can use.
    – phemmer
    Mar 30, 2014 at 9:08
  • Check the output of vgs.
    – slm
    Mar 30, 2014 at 13:15
  • Probably a bit offtopic, but use fdisk -cu instead of fdisk to work with reasonable units. Look at the manual page for more details. New versions of fdisk use that by default, so you don't need to add -c nor -u in newer systems. Mar 30, 2014 at 15:28
  • @Patrick Please check question for output of vgdisplay Mar 31, 2014 at 12:55
  • @slm VG #PV #LV #SN Attr VSize VFree vg00 1 3 0 wz--n- 925.51g 913.51g Mar 31, 2014 at 12:55

2 Answers 2

2

According to the vgdisplay output, you have over 900gb of unallocated space (Free PE value).

Since your root volume is not an LVM volume, and /opt currently resides on /, you cannot increase the available space.
What you can do however is to create a new filesystem for /opt.

The process would go something like this:

# create a new 5gb logical volume
lvcreate -n opt -L 5G vg00

# format it as ext4
mkfs.ext4 /dev/vg00/opt

# move the old dir out of the way
mv /opt /opt.orig

# mount the new logical volume
echo "/dev/vg00/opt /opt ext4 defaults 0 2" >> /etc/fstab
mkdir /opt
mount /opt

# move all data into the new mount
mv /opt.orig/* /opt
rmdir /opt.orig

LVM does allow resizing volumes, so in the future if you need to add more space to /opt, you can do so very easily.

3
  • when i try df i see that: /dev/md1 is 100% full, does creating a new logical volume help?? Mar 31, 2014 at 18:28
  • I have followed the steps you have mentioned. But at the end when i ran df -h it doesn't show /dev/mapper/vg00-opt? Mar 31, 2014 at 19:33
  • In regards to your first comment, the only free space that matters is what you see in vgdisplay. In regards to your second comment, assuming you got no errors, df will probably show you something like /dev/mapper/vg00-opt. Do an ls -l /dev/vg00 /dev/mapper and you'll see why.
    – phemmer
    Apr 1, 2014 at 0:32
0

If you look at the output from both vgs and vgdisplay you'll not that you have roughly 913.51 GB of free PE. These are physical extents and so your LVM Volume Groups (VG) does not have these physical extents assigned to anything. They're free space.

Output of vgdisplay:

--- Volume group ---
  VG Name               vg00
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                3
  Open LV               3
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               925.51 GiB
  PE Size               4.00 MiB
  Total PE              236931
  Alloc PE / Size       3072 / 12.00 GiB
  Free  PE / Size       233859 / 913.51 GiB

So I would conclude that you need to assign these physical extents. The easiest method to extend one of the logical volumes (LV's) within this VG to allocate all the free space would be the following command, for example:

$ sudo lvextend -l+233859 /dev/vg00/home

Where we're adding (+233859) of the PE's to LV /dev/vg00/home.

1
  • I'm using LVM. How can i allocate more space to /opt from unallocated space? Mar 31, 2014 at 15:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .