[root@spacewalk ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos_spacewalk-root 50G 50G 20K 100% /
devtmpfs 913M 0 913M 0% /dev
tmpfs 920M 0 920M 0% /dev/shm
tmpfs 920M 8.3M 912M 1% /run
tmpfs 920M 0 920M 0% /sys/fs/cgroup
/dev/mapper/centos_spacewalk-home 148G 33M 148G 1% /home
/dev/sda1 497M 89M 409M 18% /boot
tmpfs 184M 0 184M 0% /run/user/0Now I powered off this machine and added new disk:
Once the system is booted I checked again if the disk is listed as device:
# fdisk -l | grep "^Disk /"
Disk /dev/sdb: 42.9 GB, 42949672960 bytes, 83886080 sectors
Disk /dev/sda: 214.7 GB, 214748364800 bytes, 419430400 sectors
Disk /dev/mapper/centos_spacewalk-root: 53.7 GB, 53687091200 bytes, 104857600 sectors
Disk /dev/mapper/centos_spacewalk-swap: 2147 MB, 2147483648 bytes, 4194304 sectors
Disk /dev/mapper/centos_spacewalk-home: 158.3 GB, 158318198784 bytes, 309215232 sectorsYes! indeed there is new device /dev/sdbNow it will get complicated. Lets check volume group situation. Mainly I need to look only above "Physical volumes" section:
# vgdisplay -v
Using volume group(s) on command line.
--- Volume group ---
VG Name centos_spacewalk
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 199.51 GiB
PE Size 4.00 MiB
Total PE 51074
Alloc PE / Size 51058 / 199.45 GiB
Free PE / Size 16 / 64.00 MiB
VG UUID nVGa5O-D3xL-b9au-vdy3-0Lvc-UHqd-BuulcE
--- Logical volume ---
LV Path /dev/centos_spacewalk/swap
LV Name swap
VG Name centos_spacewalk
LV UUID llyVnR-J92n-4Ccu-QSnO-cWJt-HE0D-3cRyCB
LV Write Access read/write
LV Creation host, time spacewalk.pro, 2016-09-29 11:46:42 -0400
LV Status available
# open 2
LV Size 2.00 GiB
Current LE 512
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:1
--- Logical volume ---
LV Path /dev/centos_spacewalk/home
LV Name home
VG Name centos_spacewalk
LV UUID 1YfWDN-gjDn-SFV1-NvCd-Yfj3-yXna-GKUMgI
LV Write Access read/write
LV Creation host, time spacewalk.pro, 2016-09-29 11:46:42 -0400
LV Status available
# open 1
LV Size 147.45 GiB
Current LE 37746
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:2
--- Logical volume ---
LV Path /dev/centos_spacewalk/root
LV Name root
VG Name centos_spacewalk
LV UUID MJVsOj-WB6q-RAP6-8iKI-LxPF-Ca6o-8PyQou
LV Write Access read/write
LV Creation host, time spacewalk.pro, 2016-09-29 11:46:43 -0400
LV Status available
# open 1
LV Size 50.00 GiB
Current LE 12800
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:0
--- Physical volumes ---
PV Name /dev/sda2
PV UUID syRcb1-52G9-epzE-gVJX-aN97-RRR0-Aw12vC
PV Status allocatable
Total PE / Free PE 51074 / 16I note down volume group base name which is this case is /dev/centos_spacewalkAnother thing is Free PE which means how much free space are unused. In very tight situations this can be 0 which means that every block is in production
Lets add the new disk to be managed by volume group.
/dev/sdb do not need any partitions. This is weird and cool in same time :)# vgextend /dev/centos_spacewalk /dev/sdb
Physical volume "/dev/sdb" successfully created
/etc/lvm/backup/centos_spacewalk.tmp: write error failed: No space left on device
Backup of volume group centos_spacewalk metadata failed.
Volume group "centos_spacewalk" successfully extendedI received "No space left on device" which looks like very bad.Some success messages also appears.
I decided to clean some log files before I continue.
This will save something like 1 megabyte to operate in next commands:
> /var/log/cobbler/cobbler.log
> /var/log/messagesI have to work very quickly cause /var/log/messages are empty right now but it will fill full very quickly.I run again
vgdisplay -v to see that I have new blocks to use in environment :) --- Physical volumes ---
PV Name /dev/sda2
PV UUID syRcb1-52G9-epzE-gVJX-aN97-RRR0-Aw12vC
PV Status allocatable
Total PE / Free PE 51074 / 16
PV Name /dev/sdb
PV UUID odzNaM-CBf4-PFpD-todW-sLoD-IDUP-dQrBNb
PV Status allocatable
Total PE / Free PE 10239 / 10239Lets give some unallocated space for /dev/centos_spacewalk/root which is the partition which desperately needs some free space:lvextend /dev/centos_spacewalk/root /dev/sdb
Size of logical volume centos_spacewalk/root changed from 50.00 GiB (12800 extents) to 90.00 GiB (23039 extents).
Logical volume root successfully resized. The final step is to let actual file system eat all the unallocated space:resize2fs /dev/centos_spacewalk/root
resize2fs: Bad magic number in super-block while trying to open /dev/centos_spacewalk/root
Couldn't find valid filesystem superblock.WTFloppy?Turns out for xfs file system I need to use:
# xfs_growfs /dev/centos_spacewalk/root
meta-data=/dev/mapper/centos_spacewalk-root isize=256 agcount=4, agsize=3276800 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0 finobt=0
data = bsize=4096 blocks=13107200, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal bsize=4096 blocks=6400, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 13107200 to 23591936Now I have successfully extended root mount point :)# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos_spacewalk-root 90G 50G 40G 56% /
devtmpfs 913M 0 913M 0% /dev
tmpfs 920M 0 920M 0% /dev/shm
tmpfs 920M 8.3M 912M 1% /run
tmpfs 920M 0 920M 0% /sys/fs/cgroup
/dev/mapper/centos_spacewalk-home 148G 33M 148G 1% /home
/dev/sda1 497M 89M 409M 18% /boot
tmpfs 184M 0 184M 0% /run/user/0echo "- - -" > /sys/class/scsi_host/host0/scan
echo "- - -" > /sys/class/scsi_host/host1/scan
echo "- - -" > /sys/class/scsi_host/host2/scan