Increase the size of disk image and root file system

31 views
Skip to first unread message

GD rub

unread,
Mar 23, 2020, 4:09:16 AM3/23/20
to qubes...@googlegroups.com
Hi,

How can I increase the size of disk image and root file system whithout cutting off the branch on which we are sitting on (umount) ?

[R4.0] -> StandaloneVM -> settings -> increase system storage max size - OK

Unallocated free space (5 GB) at the end of xvda disk :

# fdisk -l
Disk /dev/xvda: 14 GiB, 15032385536 bytes, 29360128 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
Disklabel type: dos
Disk identifier: 0xb607ef98

Device     Boot    Start      End  Sectors  Size Id Type
/dev/xvda1          2048 18946047 18944000    9G 83 Linux
/dev/xvda2      18946048 20969471  2023424  988M 82 Linux swap / Solaris

Best,

GD Rub

Chris Laprise

unread,
Mar 24, 2020, 1:40:03 PM3/24/20
to qubes...@googlegroups.com
On 3/23/20 4:07 AM, GD rub wrote:
> Hi,
>
> How can I increase the size of disk image and root file system whithout
> cutting off the branch on which we are sitting on (umount) ?
>
> [R4.0] -> StandaloneVM -> settings -> increase system storage max size - OK
>
> Unallocated free space (5 GB) at the end of xvda disk :
>
> # fdisk -l
> Disk /dev/xvda: *14 GiB*, 15032385536 bytes, 29360128 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
> Disklabel type: dos
> Disk identifier: 0xb607ef98
>
> Device     Boot    Start      End  Sectors  Size Id Type
> /dev/xvda1          2048 18946047 18944000 *9G* 83 Linux
> /dev/xvda2      18946048 20969471  2023424  988M 82 Linux swap / Solaris

Have you tried the 'resize2fs' command?

--
Chris Laprise, tas...@posteo.net
https://github.com/tasket
https://twitter.com/ttaskett
PGP: BEE2 20C5 356E 764A 73EB 4AB3 1DC4 D106 F07F 1886

GD rub

unread,
Mar 25, 2020, 10:14:01 AM3/25/20
to Chris Laprise, qubes...@googlegroups.com
Hi Chris,

You can't do that on the root filesystem. resize2fs is permissible only if the partition is unmounted.

Best,

--
You received this message because you are subscribed to the Google Groups "qubes-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qubes-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/qubes-users/2ff61e95-9552-889a-ffe4-5d1f37ad5c00%40posteo.net.

dhorf-hfre...@hashmail.org

unread,
Mar 25, 2020, 10:22:13 AM3/25/20
to GD rub, qubes...@googlegroups.com
On Wed, Mar 25, 2020 at 03:12:04PM +0100, GD rub wrote:

> You can't do that on the root filesystem. resize2fs is permissible only if
> the partition is unmounted.

actualy, no, resize2fs works just fine on a mounted filesystem.


> > > Device Boot Start End Sectors Size Id Type
> > > /dev/xvda1 2048 18946047 18944000 *9G* 83 Linux
> > > /dev/xvda2 18946048 20969471 2023424 988M 82 Linux swap / Solaris

but in this case, you need to repartition first, and that is going to
be a problem while things are mounted.
and you will have to move the swap out of the way for resizing
the root partition too...

i would recommend doing the resizing from a different appVM (or dom0).


GD rub

unread,
Mar 25, 2020, 10:35:55 AM3/25/20
to dhorf-hfre...@hashmail.org, qubes...@googlegroups.com

GD rub

unread,
Mar 25, 2020, 11:23:28 AM3/25/20
to dhorf-hfre...@hashmail.org, qubes...@googlegroups.com
This is the modus operandi I used :

---%<-----------------------------------------------
# df -hT | grep /dev/xvda
/dev/xvda1       ext4       8,9G    6,3G  2,1G  76% /

# parted /dev/xvda 'unit s print' free
Model: Xen Virtual Block Device (xvd)
Disk /dev/xvda: 29360128s
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number  Start      End        Size       Type     File system     Flags
        63s        2047s      1985s               Free Space
 1      2048s      18946047s  18944000s  primary  ext4
 2      18946048s  20969471s  2023424s   primary  linux-swap(v1)
        20969472s  29360127s  8390656s            Free Space

# free -h
              total        used        free      shared  buff/cache   available
Mem:          1,9Gi       209Mi       1,2Gi       6,0Mi       532Mi       1,6Gi
Swap:         987Mi          0B       987Mi

swap is unused here so I can turn it off

# swapoff /dev/xvda2

Now I change the partition table :

# fdisk /dev/xvda -c

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.


Command (m for help): p
Disk /dev/xvda: 14 GiB, 15032385536 bytes, 29360128 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
Disklabel type: dos
Disk identifier: 0xb607ef98

Device     Boot    Start      End  Sectors  Size Id Type
/dev/xvda1          2048 18946047 18944000    9G 83 Linux

/dev/xvda2      18946048 20969471  2023424  988M 82 Linux swap / Solaris

Command (m for help): d
Partition number (1,2, default 2): 1

Partition 1 has been deleted.

Command (m for help): n
Partition type
   p   primary (1 primary, 0 extended, 3 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (1,3,4, default 1): 1
First sector (2048-29360127, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-29360127, default 29360127):

Created a new partition 1 of type 'Linux' and of size 14 GiB.
Partition #1 contains a ext4 signature.

Do you want to remove the signature? [Y]es/[N]o: N

Command (m for help): a
Partition number (1,2, default 2): 1

The bootable flag on partition 1 is enabled now.

Command (m for help): w
The partition table has been altered.
Failed to update system information about partition 1: Périphérique ou ressource occupé

The kernel still uses the old partitions. The new table will be used at the next reboot.
Syncing disks.

# swapon /dev/xvda2

# fdisk -l /dev/xvda
Disk /dev/xvda: 14 GiB, 15032385536 bytes, 29360128 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
Disklabel type: dos
Disk identifier: 0xb607ef98

Device     Boot    Start      End  Sectors  Size Id Type
/dev/xvda1 *        2048 29360127 29358080   14G 83 Linux

/dev/xvda2      18946048 20969471  2023424  988M 82 Linux swap / Solaris

# reboot

# resize2fs /dev/xvda1
resize2fs 1.44.4 (18-Aug-2018)
Filesystem at /dev/xvda1 is mounted on /; on-line resizing required
old_desc_blocks = 2, new_desc_blocks = 2
The filesystem on /dev/xvda1 is now 3669760 (4k) blocks long.

# df -hT | grep /dev/xvda
/dev/xvda1       ext4        14G    6,3G  6,8G  49% /
---%<-----------------------------------------------

dhorf-hfre...@hashmail.org

unread,
Mar 25, 2020, 11:43:10 AM3/25/20
to GD rub, qubes...@googlegroups.com
On Wed, Mar 25, 2020 at 04:21:29PM +0100, GD rub wrote:

> Device Boot Start End Sectors Size Id Type
> /dev/xvda1 * 2048 29360127 29358080 14G 83 Linux
> /dev/xvda2 18946048 20969471 2023424 988M 82 Linux swap / Solaris

urgh! be super careful there.
your xvda2 is currently overlapping / in the middle of your xvda1!

that means your rootfs is currently corrupted in an _interesting_ way.

if you have snapshots left for the vm from before the resize,
consider keeping/reverting! (check with qvm-volume and/or lvs)

if not ... i recommend deleting xvda2 (and moving swap to xvdc),
then running a full fsck on xvda1 from outside the vm, or flagging
it for fsck and rebooting.




GD rub

unread,
Mar 25, 2020, 2:20:06 PM3/25/20
to dhorf-hfre...@hashmail.org, qubes...@googlegroups.com
It works fine.

I restored the VM from a backup and I changed the procedure a little bit.

# fdisk -l /dev/xvda
Disk /dev/xvda: 14 GiB, 15032385536 bytes, 29360128 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
Disklabel type: dos
Disk identifier: 0xb607ef98

Device     Boot    Start      End  Sectors  Size Id Type
/dev/xvda1 *        2048 27265023 27262976   13G 83 Linux
/dev/xvda2      27265024 29360127  2095104 1023M 82 Linux swap / Solaris

# lsblk -f
NAME    FSTYPE   LABEL UUID                                 MOUNTPOINT
loop0   squashfs                                            /snap/amass/770
loop1   squashfs                                            /snap/core/8689
loop2   squashfs                                            /snap/amass/671
loop3   squashfs                                            /snap/core/7270
xvda                                                        
├─xvda1 ext4           3aed92f4-f9db-4e41-bb44-a4ea0cfc05a1 /
└─xvda2 swap           ea7fa869-0054-4b8e-ae14-64c55d69203f [SWAP]
xvdb                                                        
└─xvdb1 ext4           07c7f4fe-be16-460e-abee-cb382c3497d4 /home
Reply all
Reply to author
Forward
0 new messages