Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

resizing vbox disk of encrypted guest not so easy

Ask for help with issues regarding the Installations of the Debian O/S.
Post Reply
Message
Author
oxyopes
Posts: 4
Joined: 2023-05-23 07:43
Has thanked: 1 time

resizing vbox disk of encrypted guest not so easy

#1 Post by oxyopes »

Hi,

wanna increase the size of the guest disk in virtualbox, but it is not so simple for encrypted systems :-/

I run debian into a virtualbox with (debian/LUKS) disk encryption, no vbox disk encryption. The guests disk has ~7GB, I resized it by doing:

1) open vbox > File > Virtual Media Manager > slide the bar to 30GB size;

2) open a hosts shell and do:
vboxmanage modifymedium disk "vmName.vdi" --resize 30000
(this gave me a non-understandable error msg... whatever..)

3) I started the VM, opened gparted and saw the whole 30GB there... cool Off course it was showing the additional ~23GB as unused space.

4) I use the gparted slider to resize the partition /dev/sda3 (where my home is) to use the whole space, thus going to ~30GB;

5) I rebooted the guest system, logded in reopened gparted at the guest and saw /dev/sda3 having 30GB ... great!

6) Diagnosis:
I typed 'du -h' in the guest and saw only the former 7GB there ... :-/
If i 'du -h vmName.dvi' from the host shell i keep seeing only the 7GB there, but it does not need to mean much, since the initial setting was already for dynamically allocated disk space;
From the guest shell i do 'fdisk -l' and see the whole 30GB inside /dev/sda3 (mounted as /dev/mapper/sda3_crypt ... 30GB);
Now i open virtualbox from the guest, open settings for my VM and go to storage. There it says: Virtual size: 30GB; Actual size: 7GB (?? no idea, maybe it refers to dynamic allocation);
I open gparted, right-click on the problematic partition and click on information, than I read: ''22.29 GiB of unallocated space within the partition. To grow the file system to fill the partition, select the partition and choose the menu item: Partition --> Check." However option 'check' is disabled in menu.

Can anyone help me further audit or solve this problem ??
Thanks a lot!

Note1: when i encrypt a guest disk, dynamic allocation from virtualbox does not have any effect, meaning, the encrypted partition goes directly to its full potential size, at leas if i 'du' its image file from the guest OS. Thus step 6 above should indeed show right alway 30GB;

Note2: cross question from stackexchange/linux&unix, since no answer there .. :-(

Host: ubuntu Guest: debian/openbox on virtualbox, dynamic allocation of HD space

CwF
Global Moderator
Global Moderator
Posts: 2625
Joined: 2018-06-20 15:16
Location: Colorado
Has thanked: 41 times
Been thanked: 190 times

Re: resizing vbox disk of encrypted guest not so easy

#2 Post by CwF »

You have have only addressed the 'partition' part of the process. You need to separately expand the logical volume group to now fill this space within the guest. I'm not the expert on that.
man cryptsetup includes resize info.

User avatar
kent_dorfman766
Posts: 529
Joined: 2022-12-16 06:34
Location: socialist states of america
Has thanked: 56 times
Been thanked: 69 times

Re: resizing vbox disk of encrypted guest not so easy

#3 Post by kent_dorfman766 »

In terms of being practical, if it were me I would not want to play with resizing luks encrypted VM disk images. I would create a separate image of the desired size, format and encrypt it, mount it in parallel under the vm and copy the content to the new image under VM control. Finally, I'd change the mount points to use the new image.

oxyopes
Posts: 4
Joined: 2023-05-23 07:43
Has thanked: 1 time

Re: resizing vbox disk of encrypted guest not so easy

#4 Post by oxyopes »

You need to separately expand the logical volume group
That makes sense. I tried 'cryptsetup resize --device-size XXXXXX' but it does not seem to work.
I am losing hope, or else some expert in the subject jumps in here ...

CwF
Global Moderator
Global Moderator
Posts: 2625
Joined: 2018-06-20 15:16
Location: Colorado
Has thanked: 41 times
Been thanked: 190 times

Re: resizing vbox disk of encrypted guest not so easy

#5 Post by CwF »

oxyopes wrote: 2023-05-24 12:27 I tried 'cryptsetup resize --device-size XXXXXX' but it does not seem to work.
I think I was wrong...

Code: Select all

$  apropos LVM
lvm (8)              - LVM2 tools
lvm-config (8)       - Display and manipulate configuration information
lvm-dumpconfig (8)   - Display and manipulate configuration information
lvm-fullreport (8)   - (unknown subject)
lvm-lvpoll (8)       - (unknown subject)
lvm.conf (5)         - Configuration file for LVM2
lvm2-activation-generator (8) - generator for systemd units to activate LVM volumes on boot
lvmcache (7)         - LVM caching
lvmconfig (8)        - Display and manipulate configuration information
lvmdiskscan (8)      - List devices that may be used as physical volumes
lvmdump (8)          - create lvm2 information dumps for diagnostic purposes
lvmpolld (8)         - LVM poll daemon
lvmraid (7)          - LVM RAID
lvmreport (7)        - LVM reporting and related features
lvmsadc (8)          - LVM system activity data collector
lvmsar (8)           - LVM system activity reporter
lvmsystemid (7)      - LVM system ID
lvmthin (7)          - LVM thin provisioning
pvcreate (8)         - Initialize physical volume(s) for use by LVM
pvremove (8)         - Remove LVM label(s) from physical volume(s)
virt-filesystems (1) - List filesystems, partitions, block devices, LVM in a virtual machine or disk image
The answer is in there somewhere, look at lvmconfig (8)

oxyopes
Posts: 4
Joined: 2023-05-23 07:43
Has thanked: 1 time

Re: resizing vbox disk of encrypted guest not so easy

#6 Post by oxyopes »

i tried this and several variations of it ... no success, no helpful error msg...

lvresize --resizefs --size 30714880MB /dev/mapper/sda3_crypt

Again, this is my 'fdisk -l' :

Code: Select all

# fdisk -l
Disk /dev/sda: 30.29 GiB, 32519028736 bytes, 63513728 sectors
Disk model: VBOX HARDDISK   
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: gpt
Disk identifier: blabladiskxxx

Device       Start      End  Sectors  Size Type
/dev/sda1     2048  1050623  1048576  512M EFI System
/dev/sda2  1050624  2050047   999424  488M Linux filesystem
/dev/sda3  2050048 63512575 61462528 29.3G Linux filesystem


Disk /dev/mapper/sda3_crypt: 29.29 GiB, 31452037120 bytes, 61429760 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/mapper/blasys--vg-root: 6.03 GiB, 6476005376 bytes, 12648448 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/mapper/blasys--vg-swap_1: 976 MiB, 1023410176 bytes, 1998848 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Last edited by oxyopes on 2023-05-26 03:11, edited 1 time in total.

User avatar
canci
Global Moderator
Global Moderator
Posts: 2497
Joined: 2006-09-24 11:28
Has thanked: 135 times
Been thanked: 134 times

Re: resizing vbox disk of encrypted guest not so easy

#7 Post by canci »

@oxyopes Please put the output in code tags. It's easier to read. Thanks.
Image Stable / Asus VivoBook X421DA / AMD Ryzen 7 3700U / Radeon Vega Mobile Gfx (Picasso) / 8 GB RAM / 512GB NVMe

READ THIS:

* How to Post a Thread Here
* Other Tips and Great Resources

oxyopes
Posts: 4
Joined: 2023-05-23 07:43
Has thanked: 1 time

Re: resizing vbox disk of encrypted guest not so easy

#8 Post by oxyopes »

canci wrote: 2023-05-25 11:23 @oxyopes Please put the output in code tags.
Sry, can you help me understand what you mean by ''output in code tags'' ?

User avatar
canci
Global Moderator
Global Moderator
Posts: 2497
Joined: 2006-09-24 11:28
Has thanked: 135 times
Been thanked: 134 times

Re: resizing vbox disk of encrypted guest not so easy

#9 Post by canci »

When you write your posts, could you please mark the text that you paste from your log files and just click on the little button that says "Code display" (fifth icon from left), or, if you want to do it manually, just put the word code in angular brackets before the text and again /code in angular brackets after the text.

The text should look like this then:

Code: Select all

Example code tag
Image Stable / Asus VivoBook X421DA / AMD Ryzen 7 3700U / Radeon Vega Mobile Gfx (Picasso) / 8 GB RAM / 512GB NVMe

READ THIS:

* How to Post a Thread Here
* Other Tips and Great Resources

Post Reply