resize Archives - David Yin's Blog https://www.yinfor.com/tag/resize/ Tech geek. Life geek. Fri, 26 Jul 2024 07:54:39 +0000 en-US hourly 1 https://wordpress.org/?v=6.7.1 https://www.yinfor.com/wp-content/uploads/2016/09/cropped-icon-120x120.png resize Archives - David Yin's Blog https://www.yinfor.com/tag/resize/ 32 32 Shrink the VM disk in Proxmox VE https://www.yinfor.com/2024/07/shrink-the-vm-disk-in-proxmox-ve.html https://www.yinfor.com/2024/07/shrink-the-vm-disk-in-proxmox-ve.html#respond Fri, 26 Jul 2024 15:54:18 +0000 https://www.yinfor.com/?p=9818 I wrote a post about how to expand the VM disk in Proxmox VE last year. Now I want to show you how to shrink the disk or reduce the size of the disk of VM in Proxmox VE. Background...

The post Shrink the VM disk in Proxmox VE appeared first on David Yin's Blog.

]]>
I wrote a post about how to expand the VM disk in Proxmox VE last year. Now I want to show you how to shrink the disk or reduce the size of the disk of VM in Proxmox VE.

Background information:

  • Host: Proxmox VE 8.2.4
  • Guest VM: VM 303
  • The harddisk is 48GB
  • Snap backup file is 34.60GB  in zst format
  • The purpose of this VM is Minecraft server

Backup files
Backup files

The used space in the VM disk is checked with the command df.

davidyin@minecraft:~$ df -h
Filesystem      Size  Used Avail Use% Mounted on
tmpfs           593M 1020K  592M   1% /run
/dev/sda2        47G   11G   35G  24% /
tmpfs           2.9G     0  2.9G   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           593M   12K  593M   1% /run/user/1000
davidyin@minecraft:~$

Only 11GB was used of a total 47GB in /dev/sda2.

I prefer to reduce it to 20GB.  I believe the backup file will also be smaller.

step 0

Backup! Backup! Backup!

Nothing more important than backup.

So, I repeated it three times.

Step 1

Prepare a Debian 12.1.0 live CD iso file. Upload to the ISO images folder of the Proxmox drive.

I am using debian-live-12.1.0-amd64-gnome.iso.

VM303 > Hardware > CD/DVD Drive(ide2), select “Use CD/DVD disk image file(iso). Choose the Storage and the ISO file.

VM303 > Options > Boot Order, move the “ide2” to the top.

Reboot the VM303. Check Console.

Select Live system (amd64)


Wait, until the desktop.

Click the nine-dots icon to show the applications, then click Terminal.

sudo apt install gparted

After installation of Gparted, click the left-up corner, or Activities, then type “gparted” in the top-middle search bar to run the application.

It may ask you the Password of the Debian Live user. It is “live”.

see the current situation of /dev/sda.

Click /dev/sda2 to select it, Menu Partition > Resize/Move

I just entered 20477 into the New size(MiB). Then click the “0” of “Free space preceding (MiB)”.

Press the “Resize/Move” button.

Click the green check mark to apply the operation. It will ask you again to confirm it.

It takes a while to complete the operation.

Close the window when it is done.

Shut down the VM/ Power off the VM. Or, Stop the VM in the Proxmox VE

VM303 > Hardware >  CD/DVD Drive, change it to “Do not use any media”.

Step 2

Backup GUID partition table.

In Proxmox VE Console.

root@pve:~# gdisk /dev/pve/vm-303-disk-0
GPT fdisk (gdisk) version 1.0.9

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.

Command (? for help): b
Enter backup filename to save: guid-bak
The operation has completed successfully.

Command (? for help): q
root@pve:~# ls
guid-bak  l.sh  s.sh

The file table of VM303 is saved at /root/guid-bak file.

Step 3

Resize the VM disk with LVM.

In the step 1, I reduced 28GB. Here I have to reduce less than 28GB. I prefer to give 2GB space. So the command is lvreduce -L -26G /dev/pve/vm-303-disk-0.

root@pve:~# lvreduce -L -26G /dev/pve/vm-303-disk-0
  WARNING: Reducing active logical volume to 22.00 GiB.
  THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce pve/vm-303-disk-0? [y/n]: y
  Size of logical volume pve/vm-303-disk-0 changed from 48.00 GiB (12288 extents) to 22.00 GiB (5632 extents).
  Logical volume pve/vm-303-disk-0 successfully resized.

Step 4

Restore the GUID partition table.

The command is r, l, /root/guid-bak, w, y

root@pve:~# gdisk /dev/pve/vm-303-disk-0
GPT fdisk (gdisk) version 1.0.9

Warning! Disk size is smaller than the main header indicates! Loading
secondary header from the last sector of the disk! You should use 'v' to
verify disk integrity, and perhaps options on the experts' menu to repair
the disk.
Caution: invalid backup GPT header, but valid main header; regenerating
backup header from main header.

Warning! One or more CRCs don't match. You should repair the disk!
Main header: OK
Backup header: ERROR
Main partition table: OK
Backup partition table: ERROR

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: damaged

****************************************************************************
Caution: Found protective or hybrid MBR and corrupt GPT. Using GPT, but disk
verification and recovery are STRONGLY recommended.
****************************************************************************

Command (? for help): r

Recovery/transformation command (? for help): l
Enter backup filename to load: /root/guid-bak
Warning! Current disk size doesn't match that of the backup!
Adjusting sizes to match, but subsequent problems are possible!

Recovery/transformation command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to /dev/pve/vm-303-disk-0.
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot or after you
run partprobe(8) or kpartx(8)
The operation has completed successfully.

Step 5

qm rescan to update the VM303 disk information.

 

root@pve:~# qm rescan
rescan volumes...
  WARNING: Thin volume pve/vm-303-disk-0 maps 46461222912 while the size is only 23622320128.
  WARNING: Thin volume pve/vm-303-disk-0 maps 46461222912 while the size is only 23622320128.
  WARNING: Thin volume pve/vm-108-disk-0 maps 133059510272 while the size is only 42949672960.
  WARNING: Thin volume pve/vm-108-disk-0 maps 133059510272 while the size is only 42949672960.
VM 303 (scsi0): size of disk 'local-lvm:vm-303-disk-0' updated from 48G to 22G

Now,  I can see the 22GB of hard disk size in the Proxmox interface.

 

Step 6

Start the VM303.

In VM303 Console to double-check it.

Oh, enter the following command to use all the space of the VM disk.

The total size of the disk is 22GB. 11GB used, 9.8GB available.

Make a backup. The new backup file is only 11.90GB.

After shrinking the VM disk, I made the VM size smaller and saved the space for backup.

 

Credit: OPS HUB

 

The post Shrink the VM disk in Proxmox VE appeared first on David Yin's Blog.

]]>
https://www.yinfor.com/2024/07/shrink-the-vm-disk-in-proxmox-ve.html/feed/ 0
How to resize the Proxmox VE default disks https://www.yinfor.com/2023/02/how-to-resize-the-proxmox-ve-default-disks.html https://www.yinfor.com/2023/02/how-to-resize-the-proxmox-ve-default-disks.html#respond Mon, 20 Feb 2023 07:56:22 +0000 https://www.yinfor.com/?p=8605 Here is a record of how I changed the default disks of Proxmox VE. I have a 1TB Nvme SSD. And it is the only hard drive in my system. When I install the Proxmox VE 7.3, the default setup...

The post How to resize the Proxmox VE default disks appeared first on David Yin's Blog.

]]>
Here is a record of how I changed the default disks of Proxmox VE.

I have a 1TB Nvme SSD. And it is the only hard drive in my system. When I install the Proxmox VE 7.3, the default setup will take all capacity of the SSD.

Unfortunately, the default setup gives Local(PVE) 100GB, which is used for Backup, ISO, and template. The rest space, 853.40 G is given to Local-LVM(PVE) for VM disks and CT containers.

Actually, 100GB is not enough for backups and ISO templates.  I prefer to let Local-LVM 600GB and give the rest to the Local(PVE).

Let’s do it.

The first step is to remove Local-LVM(PVE) and create a new one.

In the ssh terminal window.
lvremove pve/data

Then create a new Local-LVM(PVE) with a specific size, 600GB.
lvcreate -L+600G -ndata pve

to add the metadata for it, enter the following command.
lvconvert --type thin-pool --poolmetadatasize 6G pve/data

Oh, the metadata size is 1% of the Local-LVM.

The next step is to extend the Local(PVE) to the maximum.

lvextend -l 100%FREE /dev/mapper/pve-root

and enter the following command to make it effective. (The filesystem is ext4)

resize2fs /dev/mapper/pve-root

Now, my PVE system’s 1TB Nvme storage is divided as below:

  • Local(PVE) is 226GB
  • Local-LVM(PVE) is 644.25GB

I just don’t know why the total is not 999GB.

If you know why, please let me know.

The post How to resize the Proxmox VE default disks appeared first on David Yin's Blog.

]]>
https://www.yinfor.com/2023/02/how-to-resize-the-proxmox-ve-default-disks.html/feed/ 0
How to resize an image through the Ubuntu terminal https://www.yinfor.com/2019/04/how-to-resize-an-image-through-the-ubuntu-terminal.html https://www.yinfor.com/2019/04/how-to-resize-an-image-through-the-ubuntu-terminal.html#comments Tue, 02 Apr 2019 22:56:09 +0000 https://www.yinfor.com/?p=6819 Now I have an image in the Ubuntu server. I need to resize it. The original image is youtube.jpg, size is 1024X768. https://images.g2soft.net/image/Ai8 Install FFmpeg sudo apt install ffmpeg   Resize the image ffmpeg -i "youtube.jpg" -vf scale=480:360 "youtubex480.jpg" The...

The post How to resize an image through the Ubuntu terminal appeared first on David Yin's Blog.

]]>
Now I have an image in the Ubuntu server. I need to resize it.

The original image is youtube.jpg, size is 1024X768.

https://images.g2soft.net/image/Ai8

Install FFmpeg

sudo apt install ffmpeg
FFmpeg version

 

Resize the image

ffmpeg -i "youtube.jpg" -vf scale=480:360 "youtubex480.jpg"
FFmpeg resize the image

The command above explains itself.

It resizes the youtube.jpg to a smaller picture, 480×360.

https://images.g2soft.net/image/FFM

The new picture after resizing

 

It is the post of “How to resize the image by FFmpeg”.

The post How to resize an image through the Ubuntu terminal appeared first on David Yin's Blog.

]]>
https://www.yinfor.com/2019/04/how-to-resize-an-image-through-the-ubuntu-terminal.html/feed/ 1
VirtualBox resize hard disk error: VBOX_E_NOT_SUPPORTED https://www.yinfor.com/2015/05/virtualbox-resize-hard-disk-error-vbox_e_not_supported.html https://www.yinfor.com/2015/05/virtualbox-resize-hard-disk-error-vbox_e_not_supported.html#comments Thu, 28 May 2015 09:06:46 +0000 https://www.yinfor.com/?p=4272 There is a error when I tried to resize the VirtualBox hard disk, or vdi file. Progress state: VBOX_E_NOT_SUPPORTED VBoxManage.exe: error: Resize hard disk operation for this format is not implemented yet!   The command I used to resize vdi...

The post VirtualBox resize hard disk error: VBOX_E_NOT_SUPPORTED appeared first on David Yin's Blog.

]]>
There is a error when I tried to resize the VirtualBox hard disk, or vdi file.

Progress state: VBOX_E_NOT_SUPPORTED

VBoxManage.exe: error: Resize hard disk operation for this format is not implemented yet!

 

The command I used to resize vdi file is :

vboxmanage modifyhd "e:\virtual_disk.vdi" --resize 20000

The original size is 8Gb. I want to increase it to 20GB.

 

I did a lot of search and found the problem and solution.

The format of VDI file is not supported by resize function.

fixed-format

Check the format of this vdi file, it is fixed default.

Resize is only support dynamic. So change the format of this vdi file to dynamic before resizing.

clone-vdi

The command is: vboxmanage clonehd “original vdi file” “new vdi file”

The default hard drive file format is dynamic. So no need to specify the format.

Then check the new vdi file’s format.

dynamic-vdi

It is dynamic default now. Then I did the resize and check the format again.

resize-vdi-and-check

Now the capacity is 20G now.

The last step is to unmount the old vdi file in VirtualBox manager, and replace the new one on it.

 

 

The post VirtualBox resize hard disk error: VBOX_E_NOT_SUPPORTED appeared first on David Yin's Blog.

]]>
https://www.yinfor.com/2015/05/virtualbox-resize-hard-disk-error-vbox_e_not_supported.html/feed/ 11