How to resize LVMs on the fly under VMware

When last we joined our intrepid hero, back in *checks notes* 2009.. I was working at a university, helping to run their internal cloud and they had a policy of setting up LVM for all the linux VMs, and I wrote the blog post so I could remember how to do online resizes.

I no longer work in that job, country, or sector, but I still use LVM on my home VMs, so still need them sometimes. However today I needed to extend an LVM containing a PV that was the entire disk, not just a partition, and the instructions didn’t work for me, so this is what I had to do..


root@serverName:~# df -h
Filesystem                 Size  Used Avail Use% Mounted on
/dev/mapper/vgRoot-lvRoot   15G  7.4G  6.6G  53% /
/dev/mapper/vgData-lvData   98G   93G     0 100% /data
#
# Firstly, we see that the volume is 100% full, so we extend in VMWare to 200GB
# and rescan partition geometry
#
root@serverName:/data# echo '1' > /sys/class/scsi_disk/32\:0\:1\:0/device/rescan 
#
# Next, run fdisk for info only, to check it's seen as a 200GB device. We don't make
# any changes though!
#
root@serverName:/data# fdisk /dev/sdb

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

The old LVM2_member signature will be removed by a write command.

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0x44d591a2.

Command (m for help): p
Disk /dev/sdb: 200 GiB, 214748364800 bytes, 419430400 sectors
Disk model: Virtual disk    
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: dos
Disk identifier: 0x44d591a2

Command (m for help): q
#
# Correct new drive size is seen, so we rescan/resize the PV
#
root@serverName:/data# pvresize /dev/sdb
  Physical volume "/dev/sdb" changed
  1 physical volume(s) resized or updated / 0 physical volume(s) not resized
#
# Next, we extend the LV into the new space
#
root@serverName:/data# lvextend -L+100G /dev/vgData/lvData 
  Size of logical volume vgData/lvData changed from <100.00 GiB (25599 extents) to <200.00 GiB (51199 extents).
  Logical volume vgData/lvData successfully resized.
#
# Verify the new space is seen in the LV
#
root@serverName:/data# lvdisplay
  --- Logical volume ---
  LV Path                /dev/vgData/lvData
  LV Name                lvData
  VG Name                vgData
  LV UUID                WsxT1O-jzLF-D4fP-1AN5-ApQs-Kx6i-yQx2iA
  LV Write Access        read/write
  LV Creation host, time ubuntu-server, 2020-08-09 05:07:00 +0000
  LV Status              available
  # open                 1
  LV Size                <200.00 GiB
  Current LE             51199
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0
   
  --- Logical volume ---
  LV Path                /dev/vgRoot/lvRoot
  LV Name                lvRoot
  VG Name                vgRoot
  LV UUID                9bpv9H-q53y-TwUC-n8k5-vYgi-y0ay-lBY367
  LV Write Access        read/write
  LV Creation host, time ubuntu-server, 2020-08-09 05:07:01 +0000
  LV Status              available
  # open                 1
  LV Size                <15.00 GiB
  Current LE             3839
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1
#
# Finally resize the filesystem inside the LV
#
root@serverName:/data# resize2fs /dev/vgData/lvData 
resize2fs 1.45.5 (07-Jan-2020)
Filesystem at /dev/vgData/lvData is mounted on /data; on-line resizing required
old_desc_blocks = 13, new_desc_blocks = 25
The filesystem on /dev/vgData/lvData is now 52427776 (4k) blocks long.
#
# And we're done!
#
root@serverName:/data# df -h
Filesystem                 Size  Used Avail Use% Mounted on
/dev/mapper/vgRoot-lvRoot   15G  7.4G  6.6G  53% /
/dev/mapper/vgData-lvData  197G   93G   95G  50% /data
root@serverName:/data# 

How to wire a reversing camera to a 2009 SH Subaru Forester

I got a new (to me – it was my mum’s!) car back in 2022, for baby hauling. Cars came a long way in the 12 years since it was made, so I added the following to it:

  • 1 – Front and rear dashcam
  • 2 – Head unit with car play
  • 3 – Front and rear sensors
  • 4 – Reversing Camera

Item 2 required item 4, and since I was going to be pulling large portions of it apart anyway, I figured may as well do all of the above..

Reversing cameras require power to run the camera, and that is also sent to the head unit to know when to show the camera, so I needed a feed from the reversing lights to go to the camera and to the head unit. I had installed the sensors back in 2022, but the wire joiners I used were crap, so I didn’t want to do that again, and the wire from the tail lights I hooked into was inconvenient to get to. So a friend suggested using the trailer hookup. I found that, but the documentation on exactly which wire does which isn’t super easy to find – each of the circuits is documented seperately in Subaru’s documentation, so you can’t just say “what is the pinout of connector R79?”

So here it is:

R79

  • 10 – Blue – FB-1 F/B FUSE NO. 1 (BAT)
  • 9 – Brown/Yellow – Reversing Light
  • 8 – Black/Yellow – GND
  • 7 – Black/Yellow – GND
  • 6 – Red – Rear fog light
  • 5 – Blue/Black – Turning – Right
  • 4 – Light green – Turning – Left
  • 3 – Brown – Brake
  • 2 – Pink – License Plate Light
  • 1 – N/C – N/C

So for the camera, pretty obviously you want Brown/Yellow and Black/Yellow. Run a wire from the front to back and also to the camera. Simples, right? Well, once you fish it and the video cable and the dashcam USB cable through the tiny tube to the liftback, sure.. The first camera I got was a piece of poop, so I got a second one which is much better – I recommend this one – https://www.aliexpress.com/item/1005005764743719.html

The more complex question was for the reversing sensors – they require 12V, Brake, Reverse and Negative. You wouldn’t want to use pin 10, as that is live all the time and will drain your battery, so I hooked mine up to 6 – Red – this means the reversing sensors shouldn’t work unless you have your lights on.. except I found they did anyway, so it must also work without it. Your mileage may vary.

Hope this helps someone one day!