Saturday, October 15, 2022

Extending Virtual Disk in a Linux Virtual Machine Using LVM

To increase a disk size in a virtual machine with Linux operating system configured with LVM, below are the steps (these steps were tested using virtualbox):

1. Power off the virtual machine

2. Increase the virtual disk size in the virtual machine using the virtual machine manager

3. Restart the virtual machine

4. Even though the virtual disk has been increased in size, but LVM is not aware of the change. To make LVM aware of the change, run pvresize command
$ sudo pvresize <pv name>

You can get the physical volume (PV) name by running "pvs" command
$ sudo pvs

5. Once the physical volume (PV) has been resized, run "vgs" to see the new volume group (VG) size
$ sudo vgs

6. Resize logical volume (LV) to make the new size available for us to use. Use below command to resize LV to use 100% of the free space available in VG
$ sudo lvextend -l +100%FREE <LV path>

You can get the LV path by running lvdisplay
$ sudo lvdisplay | grep Path

7. Now the partition is aware of the size change, but not the filesystem. Check the filesystem type and mountpoint using below command
$ df -Th

8. Depending on the filesystem type, extend your filesystem to suit the new partition size. 
For xfs:
$ sudo xfs_growfs <mountpoint>

and for ext4:
$ sudo resize2fs <mountpoint>

9. Verify that your filesystem is now using the new size
$ df -Th

Saturday, October 1, 2022

Splitting video using linux command line

To easily split (or cut some part) of video using command line, a tool called ffmpeg can be used.

Why use command line? Lighter on resource. Video editing is a high resource activity, and by using command line, we can reduce the resource used on our machine while doing video splitting, especially if we are using low resources machine. 

To install ffmpeg, on an debian based machine, just run below command
$ sudo apt -y install ffmpeg

To do the splitting, just use below command
$ ffmpeg -i mymovie.mp4 -ss 00:01:00 -t 00:00:30 myeditedmovie.mp4

-i is for which video to edit
-ss is for where in the video that you want to start
-t is for the duration of the output video

So in the above example, you will get an output called myeditedmovie.mp4, which start from the first minute of the original video, and will last 30 seconds.