https://gravatar.com/userimage/16926726/2de44cb9918f08ff7f430244b10bf37b.jpeg?size=256

gowinder's Blog

Adding a Cron Job for Automatic TRIM in Proxmox VE

Adding a Cron Job for Automatic TRIM in Proxmox VE

Check the status

1
2
3
4
5
6
7
8
sudo systemctl status fstrim.timer
# output:
● fstrim.timer - Discard unused blocks once a week
     Loaded: loaded (/lib/systemd/system/fstrim.timer; disabled; vendor preset: enabled)
     Active: inactive (dead)
    Trigger: n/a
   Triggers: ● fstrim.service
       Docs: man:fstrim

Start the service

1
sudo systemctl start fstrim.timer

Check the next cleanup time

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
sudo systemctl list-timers --all
# output:

NEXT                        LEFT           LAST                        PASSED     UNIT                         ACTIVATES
Fri 2023-02-17 23:54:54 CST 8h left        Thu 2023-02-16 23:54:54 CST 15h ago    systemd-tmpfiles-clean.timer systemd-tmpfiles-clean.servi>
Sat 2023-02-18 00:00:00 CST 8h left        Fri 2023-02-17 00:00:00 CST 15h ago    atop-rotate.timer            atop-rotate.service
Sat 2023-02-18 00:00:00 CST 8h left        Fri 2023-02-17 00:00:00 CST 15h ago    logrotate.timer              logrotate.service
Sat 2023-02-18 00:00:00 CST 8h left        Fri 2023-02-17 00:00:00 CST 15h ago    man-db.timer                 man-db.service
Sat 2023-02-18 04:19:48 CST 13h left       Fri 2023-02-17 05:29:22 CST 9h ago     pve-daily-update.timer       pve-daily-update.service
Sat 2023-02-18 05:18:55 CST 14h left       Fri 2023-02-17 06:45:48 CST 8h ago     apt-daily.timer              apt-daily.service
Sat 2023-02-18 06:41:05 CST 15h left       Fri 2023-02-17 06:02:36 CST 9h ago     apt-daily-upgrade.timer      apt-daily-upgrade.service
Sun 2023-02-19 03:10:12 CST 1 day 12h left Sun 2023-02-12 03:10:19 CST 5 days ago e2scrub_all.timer            e2scrub_all.service
Mon 2023-02-20 00:37:59 CST 2 days left    n/a                         n/a        fstrim.timer                 fstrim.service
n/a                         n/a            n/a                         n/a        pvesr.timer

Done

Extending pvm-local Space in Proxmox VE

Extending pvm-local Space in Proxmox VE

Reason

The proxmox ve I installed earlier on the DIY E3 server used a 120G SSD. Back then, being young and naive, I also carved a 30g data partition out of the pve logical volume. Now I want to use local for glusterfs, so I wanted to merge the space in data into root.

Steps

First, copy out the contents of the data partition

  • First delete what you don’t need on the pve webui; for what you do need, copy it out first. My data is mounted at /mnt/data:
1
sudo rsync -ar --info=progress2 /mnt/data/ /var/lib/vz
  • After copying is done, remove the data logical volume:
1
2
sudo umount /mnt/data
sudo lvdisplay
  • Take a look at the result:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
 --- Logical volume ---
  LV Path                /dev/pve/data
  LV Name                data
  VG Name                pve
  LV UUID                xxxx
  LV Write Access        read/write
  LV Creation host, time pve, 2020-12-13 12:19:01 +0800
  LV Status              available
  # open                 0
  LV Size                30.39 GiB
  Current LE             7781
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:2
  • Remove it:
1
2
3
sudo lvremove pve/data

# Logical volume "data" successfully removed
  • Check the vg space with sudo vgdisplay:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
  --- Volume group ---
  VG Name               pve
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  73
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               <106.60 GiB
  PE Size               4.00 MiB
  Total PE              27289
  Alloc PE / Size       19508 / 76.20 GiB
  Free  PE / Size       7781 / 30.39 GiB
  VG UUID               xxxx
  • As you can see, there is 30.39 Gib of space. Now merge it into pve-root:
  • sudo lvresize -l +100%FREE /dev/pve/root:
1
2
  Size of logical volume pve/root changed from 72.70 GiB (18612 extents) to <103.10 GiB (26393 extents).
  Logical volume pve/root successfully resized.`
  • It becomes 103.10 GiB.

Drastic Disk Performance Drop Caused by NVMe Power Management in Proxmox VE

Drastic Disk Performance Drop Caused by NVMe Power Management in Proxmox VE

A few days ago I deployed a two-node proxmox ve cluster. It worked fine at first, but after a day, when I logged in to the dell r720 host over ssh, I found the shell responding very slowly, and going into the linux container on it was even worse — every time I typed a command, zsh would freeze for quite a while.

Rebuilding a GlusterFS Volume

Rebuilding a GlusterFS Volume

Background

When I first set up the glusterfs cluster I was in a hurry and used the network addresses of the pve hosts directly. After a few days I noticed that when volume replication ran it was saturating the pve hosts’ own network channel. The dell r720 happened to have four NICs and the e3 host had two, so I took one from each and dedicated it as the gluster bind address.

NestJS: Service Cannot Find Repository Dependency

NestJS: Service Cannot Find Repository Dependency

Cause

The following code:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27

@Injectable()
export class SiteRbacService {
  constructor(
    @InjectRepository(RbacEntity)
    public readonly repository: Repository<RbacEntity>,
  ) {}
  create(createRbacDto: CreateRbacDto) {
    return 'This action adds a new rbac';
  }

  findAll() {
    return `This action returns all rbac`;
  }

  findOne(id: number) {
    return `This action returns a #${id} rbac`;
  }

  update(id: number, updateRbacDto: UpdateRbacDto) {
    return `This action updates a #${id} rbac`;
  }

  remove(id: number) {
    return `This action removes a #${id} rbac`;
  }
}

At runtime it reports: Nest can't resolve dependencies of the SiteRbacService, and the log shows that @InjectRepository(RbacEntity) public readonly repository: Repository<RbacEntity> was not injected.

Mounting a Physical Disk to a Proxmox VE VM

Mounting a Physical Disk to a Proxmox VE VM

First, find the id of the disk you want to mount:

1
lsblk |awk 'NR==1{print $0" DEVICE-ID(S)"}NR>1{dev=$1;printf $0" ";system("find /dev/disk/by-id -lname \"*"dev"\" -printf \" %p\"");print "";}'|grep -v -E 'part|lvm'

The output looks similar to this:

1
2
3
4
5
NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT DEVICE-ID(S)
loop0          7:0    0    20G  0 loop
loop1          7:1    0    80G  0 loop
loop2          7:2    0    50G  0 loop
sda            8:0    0   3.6T  0 disk   /dev/disk/by-id/ata-WDC_WD40EJRX-XXXXXXX_WD-WWWWW0XXXXXX /dev/disk/by-id/wwn-0x5000000000000

For example, to mount /dev/disk/by-id/wwn-0x5000000000000 for a VM whose ID is 103, run the following: