This section focuses on extending the disk space by attaching a second disk to the Analysis Cockpit. We will add the second disk to our existing volume group and extend the logical volume.
If you increased the disk size please refer to Scenario 2: Extending ASGARD Disk Space by Increasing Disk Size and Resize File System
Step 1: Login in to ASGARD via SSH
Step 2: Stop service
nextron@cockpit:~$ sudo systemctl stop asgard-analysis-cockpit.service
This will stop the Analysis Cockpit service. You can start the service again after you have extended the disk space.
Step 3: Check current disk space
Run the following command to check the current disk space. The output will show the current disk space usage:
nextron@cockpit:~$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 1.9G 0 1.9G 0% /dev
tmpfs 392M 524K 392M 1% /run
/dev/mapper/debian--vg-root 24G 3.4G 19G 16% /
tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
/dev/sda1 455M 51M 380M 12% /boot
tmpfs 392M 0 392M 0% /run/user/1000
Step 4: Identify attached disks
Run the following command to identify your attached disks:
nextron@cockpit:~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 25G 0 disk
├─sda1 8:1 0 487M 0 part /boot
├─sda2 8:2 0 1K 0 part
└─sda5 8:5 0 24.5G 0 part
├─debian--vg-root 254:0 0 23.6G 0 lvm /
└─debian--vg-swap_1 254:1 0 980M 0 lvm [SWAP]
sdb 8:16 0 20G 0 disk
sr0 11:0 1 1024M 0 rom
The output will show the attached disks. In this example, the newly attached disk is sdb, whereas the existing disk is sda.
Step 5: Check physical volumes
Run the following command to check all the physical volumes:
nextron@cockpit:~$ sudo pvs
PV VG Fmt Attr PSize PFree
/dev/sda5 debian-vg lvm2 a-- <24.52g 0
The output will show all the physical volumes. Please note the name of the volume group (VG), in our case debian-vg.
Step 6: Create a new physical volume
Run the following command to create a new physical volume for the new disk:
nextron@cockpit:~$ sudo pvcreate /dev/sdb
Physical volume "/dev/sdb" successfully created.
Check physical the volumes again:
nextron@cockpit:~$ sudo pvs
PV VG Fmt Attr PSize PFree
/dev/sda5 debian-vg lvm2 a-- <24.52g 0
/dev/sdb lvm2 --- 20.00g 20.00g
You can see that the new physical volume /dev/sdb has been created. It is not yet part of the volume group (VG).
Step 7: Identify Volume Group
Run the following command to identify your volume groups:
nextron@cockpit:~$ sudo vgs
VG #PV #LV #SN Attr VSize VFree
debian-vg 1 2 0 wz--n- <24.52g 0
The output will show all the volume groups. In this case, the only volume group is debian-vg.
Step 8: Extend Volume Group
Extend the volume group with our new physical volume:
nextron@cockpit:~$ sudo vgextend debian-vg /dev/sdb
Volume group "debian-vg" successfully extended
Looking at the volume groups again, you will see that the volume group debian-vg has been extended:
nextron@cockpit:~$ sudo vgs
VG #PV #LV #SN Attr VSize VFree
debian-vg 2 2 0 wz--n- <44.52g <20.00g
The volume group has more space (VSize) and free space (VFree).
Step 9: Extend Logical Volume
We now need to extend the logical volume (using the free space):
nextron@cockpit:~$ sudo lvextend -l +100%FREE /dev/debian-vg/root
Size of logical volume debian-vg/root changed from 23.56 GiB (6032 extents) to <43.56 GiB (11151 extents).
Logical volume debian-vg/root successfully resized.
Explanation: /dev/debian-vg/root is the logical volume that we want to extend. The "-l +100%FREE" option tells the lvextend command to use all the free space available in the volume group. The device /dev/debian-vg is our volume group. The logical volume root is what we extended (output of "sudo lvs").
Step 10: Resize file system
Run the following command to resize the file system:
nextron@cockpit:~$ sudo resize2fs /dev/debian-vg/root
resize2fs 1.47.0 (5-Feb-2023)
Filesystem at /dev/debian-vg/root is mounted on /; on-line resizing required
old_desc_blocks = 3, new_desc_blocks = 6
The filesystem on /dev/debian-vg/root is now 11418624 (4k) blocks long.
Step 11: Verify disk size changes
Run the following command to verify the change in disk size:
nextron@cockpit:~$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 1.9G 0 1.9G 0% /dev
tmpfs 392M 532K 392M 1% /run
/dev/mapper/debian--vg-root 43G 3.5G 38G 9% /
tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
/dev/sda1 455M 51M 380M 12% /boot
tmpfs 392M 0 392M 0% /run/user/1000
You will notice that /dev/mapper/debian--vg-root has grown.
Step 12: Reboot system
You successfully extended your disk space. Reboot your Analysis Cockpit to make sure everything is working as expected.
nextron@cockpit:~$ sudo reboot