[LINUX] VirtualBox storage expansion

Previous article during compiling the Linux kernel on a virtual machine (make modules)

ld: drivers / infininiband / hw / hfi1 / hfi1.ko: final close failed: ld: final link failed: no free space on device There is no free space on the device Is displayed and it ends with an error, so make a note of the solution.

environment

First, check the situation.

$ df -h

File system size used Remaining used% Mount position devtmpfs 977M 0 977M 0% /dev tmpfs 990M 0 990M 0% /dev/shm tmpfs 990M 8.6M 982M 1% /run /dev/sda3 15G 15G 980K 100% / tmpfs 990M 4.0K 990M 1% /tmp /dev/sda1 1014M 139M 876M 14% /boot tmpfs 198M 0 198M 0% /run/user/1000 Look for a location where the usage is close to 100%. / dev / sda3 is obviously full.

Let's also look at it from the virtualbox GUI. Let's check the virtual size of the storage from Settings → Storage. スクリーンショット 2020-06-12 1.17.11.png It says 32GB. that? It was written just like there is only 15GB! I want to use up to 32GB properly! (I brought a screenshot taken at a different timing, so the actual size is strange, but don't worry)

Go back to the terminal again

$ fdisk -l

Disk / dev / sda: 32 GiB, 34359738368 bytes, 67108864 sectors Disc model: VBOX HARDDISK Unit: sector (1 * 512 = 512 bytes) Sector size (logical / physical): 512 bytes / 512 bytes I / O size (minimum / recommended): 512 bytes / 512 bytes Disc label type: dos Disk identifier: 0x71d659f8

Device boot start position end position sector size Id type /dev/sda1 * 2048 2099199 2097152 1G 83 Linux / dev / sda2 2099200 6416383 4317184 2.1G 82 Linux swap / Solaris /dev/sda3 6416384 37873663 31457280 15G 83 Linux

The problem is that the partition of / dev / sda3 is 15GB. I want to be able to use up to 32GB as much as possible.

$ fdisk /dev/sda

Welcome to fdisk (util-linux 2.35.2). The contents set here are retained only in the memory until the write command is executed. Be careful when using the write command.

Command (help with m): d Partition number (1-3, default 3): 3

Partition 3 has been deleted.

Command (help with m): n Partition type p primary partition (2 primary, 0 extended, 2 free) e Extended area (contains logical partition) Selection (default p): p Partition number (3,4, default 3): 3 First sector (6416384-67108863, default 6416384): 6416384 Last sector, +/- sector number or +/- size {K, M, G, T, P} (6416384-67108863, default value 67108863): 67108863

I created a new partition 3 with type Linux, size 29 GiB. Partition # 3 has an xfs signature written on it.

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

The signature disappears when you run the write command.

Command (help with m): w The partition information has changed. The disks are syncing.

Here, the expanded storage cannot be used from the OS yet. You can see that there is no change even if you df.

$ df -h

File system size used Remaining used% Mount position devtmpfs 977M 0 977M 0% /dev tmpfs 990M 0 990M 0% /dev/shm tmpfs 990M 17M 974M 2% /run /dev/sda3 15G 15G 1.3M 100% / tmpfs 990M 4.0K 990M 1% /tmp /dev/sda1 1014M 139M 876M 14% /boot tmpfs 198M 0 198M 0% /run/user/1000

You can use the storage by executing this command.

$ xfs_growfs /dev/sda3

$ df -h

File system size used Remaining used% Mount position devtmpfs 977M 0 977M 0% /dev tmpfs 990M 0 990M 0% /dev/shm tmpfs 990M 8.6M 982M 1% /run /dev/sda3 29G 16G 14G 53% / tmpfs 990M 4.0K 990M 1% /tmp /dev/sda1 1014M 139M 876M 14% /boot tmpfs 198M 0 198M 0% /run/user/1000 You've grown up.

(Bonus) Get bigger storage

This method does not increase the size of the storage itself. If you want more storage, you can get it by editing the Vagrantfile.

Shut down the virtual machine and work on the host side. First, install the plugin,

% vagrant plugin install vagrant-disksize

In Vagrantfile

config.disksize.size = "50GB"

Fill in the size you want.

Vagrant up will increase the storage size. スクリーンショット 2020-06-12 2.06.49.png

After that, the same as above

$ sudo fdisk /dev/sda

Change partition with

$ sudo xfs_growfs /dev/sda3

It is completed with.

$ df -h

File system size used Remaining used% Mount position devtmpfs 977M 0 977M 0% /dev tmpfs 990M 0 990M 0% /dev/shm tmpfs 990M 528K 990M 1% /run /dev/sda3 47G 16G 32G 33% / tmpfs 990M 4.0K 990M 1% /tmp /dev/sda1 1014M 139M 876M 14% /boot tmpfs 198M 0 198M 0% /run/user/1000

Recommended Posts

VirtualBox storage expansion