Results 1 to 2 of 2

Thread: How To: Expand btrfs root file system of VirtualBox installation on Win10

  1. #1

    Default How To: Expand btrfs root file system of VirtualBox installation on Win10

    ​Introduction

    If you installed openSUSE Leap 42.3 on a virtual machine, like I did, using the openSUSE installer on your Windows 10 system and went with all the defaults, you probably ran into the issue where the 8GB of default storage is already running short after your first boot and updates have run their course. I then had to figure out how to expand the root filesystem a little to make room for all the stuff I still had yet to install.

    The following procedure highlights a specific way to accomplish the expansion using the tools provided with the current install and installation media. No other tools or software will need to be downloaded/installed.

    Host OS: Windows 10, ver. 1709
    Virtual Machine: Oracle VM VirtualBox, Version 5.2.8 r121009 (Qt5.6.2)
    Virtual Image OS: openSUSE Leap 42.3

    Resize The Virtual Hard Disk

    Before beginning, ensure the virtual machine running Leap 42.3 has been shutdown.
    Verify this in the Oracle VM VirtualBox Manager, Machine Tools view, left-hand side.
    Should say "Powered Off"


    1) Click on the "Global Tools" drop-down menu and select "Virtual Media Manager"


    2) On the "Properties" view>"Hard disks" tab, select the virtual disk for Leap 42.3.

    3) On the "Attributes" tab, use the "Size" slider or text box to increase the size of the virtual disk (I went with 20GB for my purposes)


    4) Click "Apply"

    That's it for resizing the virtual hard disk.

    Resize The Root Partition (1)

    Now we need to resize the root partition on the virtual machine by booting into a rescue system. You will need to boot into the installation media in the VM.

    1) Start the "openSUSE Leap 42.3 x86_64" virtual machine with the installation DVD image.
    (If you're boot order is default, the DVD usually boots first. If not, hit F12 when prompted and select the install DVD.)

    2) Once the virtual machine has booted into the install media menu, use the down arrow key on the keyboard to highlight the "More ..." selection and hit Enter.

    3) Ensure "Rescue System" is highlighted and press Enter.
    It will take a few minutes to boot up. Be sure to answer any prompts and login as root (there is no password prompt).

    4) Once logged in, display your disk partitions using GNU Partition Editor and note the disk number of the root partition (should be the only one with a "boot" flag).
    Note: Size values shown should not be taken literally, your system may be different.
    Code:
    tty1:rescue:~ # parted -l
    Model: ATA VBOX HARDDISK (scsi)
    Disk /dev/sda: 21.5GB
    Sector size (logical/physical): 512B/512B
    Partition Table: msdos
    Disk Flags:
    
    Number  Start   End     Size    Type     File system     Flags
    1       1049kB  1044MB  1043MB  primary  linux-swap(v1)  type=82
    2       1044MB  7.9GB   6.8GB   primary  btrfs           boot, type=83
    5) Resize the partition, again, using GNU Partition Editor.
    The following command will bring you into an interactive instance of the partition editor.
    "resize" is the command you enter, then just follow the prompts as captured below.
    (Note: The "End?" value you enter below should match the "Disk /dev/sda:" value shown above.)
    Important: Do not forget the units for your new size.
    Code:
    tty1:rescue:~ # parted /dev/sda
    GNU Parted 3.1
    Using /dev/sda
    Welcome to GNU Parted! Type 'help' to view a list of commands.
    (parted) resize
    Partition number? 2
    End?  [7.9GB]? 21.5GB
    (parted) quit
    Information: You may need to update /etc/fstab.
    Now that the partition is resized you can verify using
    Code:
    parted -l
    Next we need to resize the filesystem to match the new partition size.

    Resize btrfs File System (1)

    In order to make use of all the room we just added, we'll need to expand the btrfs filesystem.

    1) Mount the newly expanded partition.
    Code:
    tty1:rescue:~ # mount /dev/sda2 /mnt
    2) Resize the file system.
    Code:
    tty1:rescue:~ # btrfs filesystem resize max /mnt
    Resize '/mnt' of 'max'
    That's it! The root partition is now resized and ready for action. You can verify the filesystem size using
    Code:
    df -h
    ​Reboot and Enjoy The Space

    Reboot your Virtual Machine back to your virtual system hard drive and you should be running with all the new space you just set.




    Reference
    1) How to resize/extend a btrfs formatted root partition - https://www.suse.com/support/kb/doc/?id=7018329

  2. #2
    Join Date
    Jun 2008
    Location
    San Diego, Ca, USA
    Posts
    13,295
    Blog Entries
    2

    Default Re: How To: Expand btrfs root file system of VirtualBox installation on Win10

    Very nice.
    You could even create an appropriately named SDB on the subject.

    I developed a slightly different procedure to accomplish the same things...

    Generically, for whatever virtualization technology you're using, nowadays most manager apps will have a way of enlarging the virtual disk file, similar to what you describe for VBox. In the "old days" and may still be preferable for some, there is always a command that will do this, and will be specific to the virtual disk file type (ie. VDI, RAW, VMDK, VHD, QCOW2, etc).

    Then, configure the Virtual CDROM of your Guest, pointing to a Gparted Live iso.
    Boot to the LiveCD and modify your partitions and file systems as you wish.

    Reboot and enjoy.

    As described in your recommendation, the method I describe also addresses the problem many procedures have in not being able to make some changes to the root partition while the system is running.

    TSU
    Beginner Wiki Quickstart - https://en.opensuse.org/User:Tsu2/Quickstart_Wiki
    Solved a problem recently? Create a wiki page for future personal reference!
    Learn something new?
    Attended a computing event?
    Post and Share!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •