Jump to content

Expand Drive Space in Linux


Cowboy Denny
 Share

Recommended Posts

I was messing around with a nice monitoring tool called LibreNMS and all was cool until I started logging syslog data and over the weekend I come back to LibreNMS not running and I couldn't figure out why.  I then noticed docker was down and so I run my command to look at the drive space and saw the issue.  Only 20k of space left on drive

[root@usdet1lvdwb002 /]# df -h /
Filesystem           Size  Used Avail Use% Mounted on
/dev/mapper/cl-root  744G  744G   20K 100% /

I tried to check for large files and the command won't even run since there is no space available on the drive even for a tmp file

[root@usdet1lvdwb002 /]# find -type f -exec du -Sh {} + | sort -rh | head -n 5
du: cannot access './proc/1998/task/1998/fdinfo/5': No such file or directory
du: cannot access './proc/1998/task/1998/fdinfo/10': No such file or directory
du: cannot access './proc/1998/fdinfo/5': No such file or directory
sort: cannot create temporary file in '/tmp': No space left on device

Luckily I'm using a Virtual CentOS 8 image on VMware ESX so I can beg with the team to provide me with more HDD space after they just move me from 500GB to 750Gb.

I was supplied with the move from 750G to 1TB so now let me work on applying it

[root@usdet1lvdwb002 ~]# df -h
Filesystem           Size  Used Avail Use% Mounted on
devtmpfs              12G     0   12G   0% /dev
tmpfs                 12G     0   12G   0% /dev/shm
tmpfs                 12G  9.9M   12G   1% /run
tmpfs                 12G     0   12G   0% /sys/fs/cgroup
/dev/mapper/cl-root  744G  580G  164G  78% /
/dev/sda2           1014M  234M  781M  24% /boot
/dev/sda1            599M  7.3M  592M   2% /boot/efi
tmpfs                2.4G     0  2.4G   0% /run/user/0
tmpfs                2.4G  4.0K  2.4G   1% /run/user/968
overlay              744G  580G  164G  78% /var/lib/docker/overlay2/ea9a25ca518754c9aea7124bd12fc8e508f00ea06994e04029f4cab0fef7b883/merged
overlay              744G  580G  164G  78% /var/lib/docker/overlay2/0932e12a1b4200adb37f65c590de10fa7c873f8b85d2fe67be716f8a159931d1/merged
overlay              744G  580G  164G  78% /var/lib/docker/overlay2/b247fd04b3b4081c7137c04e56df42c9be8b26b668d63ac76df7a8213ff19f03/merged
overlay              744G  580G  164G  78% /var/lib/docker/overlay2/19f7bd2a1af369b2cde32a82646d8b24fb96d3f3d10ca7109f545397bf7af2ac/merged
overlay              744G  580G  164G  78% /var/lib/docker/overlay2/7fdb2594ee6cd21e5913397745a8258b2b323ff153905fc142eb4532bc1eb65a/merged
overlay              744G  580G  164G  78% /var/lib/docker/overlay2/d6d33f797eba15afd9757f2b464bb77a03e13bb04f3ea8e5200519aa989a2456/merged
overlay              744G  580G  164G  78% /var/lib/docker/overlay2/cd0efaa3c4ca6f4306707b24a9835d921f097d528c24b46016d08d4acdac2405/merged
overlay              744G  580G  164G  78% /var/lib/docker/overlay2/7d565dc86f507066f612310cf1d0ec96e2f8a63b298f2008a3de17be73bbe13f/merged

....

[root@usdet1lvdwb002 ~]# lsblk
NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda           8:0    0     1T  0 disk
├─sda1        8:1    0   600M  0 part /boot/efi
├─sda2        8:2    0     1G  0 part /boot
└─sda3        8:3    0 748.4G  0 part
  ├─cl-root 253:0    0 743.4G  0 lvm  /
  └─cl-swap 253:1    0     5G  0 lvm  [SWAP]
sr0          11:0    1  1024M  0 rom

....

[root@usdet1lvdwb002 ~]# pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda3
  VG Name               cl
  PV Size               748.41 GiB / not usable 1.98 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              191593
  Free PE               0
  Allocated PE          191593
  PV UUID               xMlTP5-qVmX-LJXM-QVXf-3xRk-2W3a-11yKk0

....

[root@usdet1lvdwb002 ~]# fdisk /dev/sda

Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

GPT PMBR size mismatch (1572863999 != 2147483647) will be corrected by write.
The backup GPT table is not on the end of the device. This problem will be corrected by write.

Command (m for help): p

Disk /dev/sda: 1 TiB, 1099511627776 bytes, 2147483648 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 532953BD-AC98-4EF9-9C0D-BBDDB871EB4C

Device       Start        End    Sectors   Size Type
/dev/sda1     2048    1230847    1228800   600M EFI System
/dev/sda2  1230848    3327999    2097152     1G Linux filesystem
/dev/sda3  3328000 1572863966 1569535967 748.4G Linux filesystem

Command (m for help): d
Partition number (1-3, default 3): 3

Partition 3 has been deleted.

Command (m for help): n
Partition number (3-128, default 3): 3
First sector (3328000-2147483614, default 3328000):
Last sector, +sectors or +size{K,M,G,T,P} (3328000-2147483614, default 2147483614):

Created a new partition 3 of type 'Linux filesystem' and of size 1022.4 GiB.
Partition #3 contains a LVM2_member signature.

Do you want to remove the signature? [Y]es/[N]o: n

Command (m for help): t
Partition number (1-3, default 3): 3
Partition type (type L to list all types): 8e

Type of partition 3 is unchanged: Linux filesystem.

Command (m for help): p
Disk /dev/sda: 1 TiB, 1099511627776 bytes, 2147483648 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 532953BD-AC98-4EF9-9C0D-BBDDB871EB4C

Device       Start        End    Sectors    Size Type
/dev/sda1     2048    1230847    1228800    600M EFI System
/dev/sda2  1230848    3327999    2097152      1G Linux filesystem
/dev/sda3  3328000 2147483614 2144155615 1022.4G Linux filesystem

Command (m for help): w
The partition table has been altered.
Syncing disks.

....

[root@usdet1lvdwb002 ~]# partx -u /dev/sda

....

[root@usdet1lvdwb002 ~]# pvresize /dev/sda3
  Physical volume "/dev/sda3" changed
  1 physical volume(s) resized or updated / 0 physical volume(s) not resized

...

[root@usdet1lvdwb002 ~]# lsblk
NAME        MAJ:MIN RM    SIZE RO TYPE MOUNTPOINT
sda           8:0    0      1T  0 disk
├─sda1        8:1    0    600M  0 part /boot/efi
├─sda2        8:2    0      1G  0 part /boot
└─sda3        8:3    0 1022.4G  0 part
  ├─cl-root 253:0    0  743.4G  0 lvm  /
  └─cl-swap 253:1    0      5G  0 lvm  [SWAP]
sr0          11:0    1   1024M  0 rom

...

[root@usdet1lvdwb002 ~]# pvs
  PV         VG Fmt  Attr PSize    PFree
  /dev/sda3  cl lvm2 a--  1022.41g 274.00g

...

[root@usdet1lvdwb002 ~]# lvs
  LV   VG Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root cl -wi-ao---- 743.41g
  swap cl -wi-ao----   5.00g

....

[root@usdet1lvdwb002 ~]# lvextend -r cl/root /dev/sda3
  Size of logical volume cl/root changed from 743.41 GiB (190313 extents) to 1017.41 GiB (260457 extents).
  Logical volume cl/root successfully resized.
meta-data=/dev/mapper/cl-root    isize=512    agcount=69, agsize=2844928 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=1, rmapbt=0
         =                       reflink=1
data     =                       bsize=4096   blocks=194880512, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
log      =internal log           bsize=4096   blocks=5556, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 194880512 to 266707968


Thats it folks..  pretty easy

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...