Skip to content

Instantly share code, notes, and snippets.

@dhrp
Created March 23, 2021 16:04
Show Gist options
  • Save dhrp/f17168a2420efc8a5fda7382fac4a7fd to your computer and use it in GitHub Desktop.
Save dhrp/f17168a2420efc8a5fda7382fac4a7fd to your computer and use it in GitHub Desktop.
Resizing a volume on OpenStack and making it available in your machine
Oswald:authentication thatcher$ os volume list
+--------------------------------------+--------------------------------------------------------------------------------------------+-----------+------+-------------------------------------------------------+
| ID | Name | Status | Size | Attached to |
+--------------------------------------+--------------------------------------------------------------------------------------------+-----------+------+-------------------------------------------------------+
| f04e5683-6a67-4208-b4b4-9c6d544d41db | | in-use | 20 | Attached to wireguard-vpn on /dev/vda |
+--------------------------------------+--------------------------------------------------------------------------------------------+-----------+------+-------------------------------------------------------+
Oswald:authentication thatcher$ openstack --os-volume-api-version 3.42 volume set --size 28 f04e5683-6a67-4208-b4b4-9c6d544d41db
Oswald:authentication thatcher$ ssh vpn
Welcome to Ubuntu 20.04.1 LTS (GNU/Linux 5.4.0-42-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
System information as of Tue Mar 23 15:45:51 UTC 2021
System load: 0.0 Processes: 108
Usage of /: 16.9% of 19.21GB Users logged in: 0
Memory usage: 24% IPv4 address for ens3: 195.114.30.163
Swap usage: 0% IPv4 address for wg0: 10.0.42.1
* Introducing self-healing high availability clusters in MicroK8s.
Simple, hardened, Kubernetes for production, from RaspberryPi to DC.
https://microk8s.io/high-availability
90 updates can be installed immediately.
0 of these updates are security updates.
To see these additional updates run: apt list --upgradable
*** System restart required ***
Last login: Thu Mar 11 16:48:20 2021 from 94.157.182.79
ubuntu@wireguard-vpn:~$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 474M 0 474M 0% /dev
tmpfs 99M 980K 98M 1% /run
/dev/vda1 20G 3.3G 16G 17% /
tmpfs 491M 0 491M 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 491M 0 491M 0% /sys/fs/cgroup
/dev/vda15 105M 3.9M 101M 4% /boot/efi
/dev/loop1 56M 56M 0 100% /snap/core18/1885
/dev/loop4 56M 56M 0 100% /snap/core18/1988
/dev/loop5 70M 70M 0 100% /snap/lxd/19188
/dev/loop6 33M 33M 0 100% /snap/snapd/11107
tmpfs 99M 0 99M 0% /run/user/1000
/dev/loop0 71M 71M 0 100% /snap/lxd/19647
/dev/loop2 33M 33M 0 100% /snap/snapd/11402
ubuntu@wireguard-vpn:~$ sudo resize2fs /dev/vda1
resize2fs 1.45.5 (07-Jan-2020)
The filesystem is already 5213954 (4k) blocks long. Nothing to do!
ubuntu@wireguard-vpn:~$ sudo resize2fs /dev/vda
resize2fs 1.45.5 (07-Jan-2020)
resize2fs: Device or resource busy while trying to open /dev/vda
Couldn't find valid filesystem superblock.
ubuntu@wireguard-vpn:~$ sudo apt install fdisk
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be upgraded:
fdisk
1 upgraded, 0 newly installed, 0 to remove and 94 not upgraded.
Need to get 119 kB of archives.
After this operation, 0 B of additional disk space will be used.
Get:1 http://europe-nl-ams1.clouds.archive.ubuntu.com/ubuntu focal-updates/main amd64 fdisk amd64 2.34-0.1ubuntu9.1 [119 kB]
Fetched 119 kB in 1s (236 kB/s)
(Reading database ... 171942 files and directories currently installed.)
Preparing to unpack .../fdisk_2.34-0.1ubuntu9.1_amd64.deb ...
Unpacking fdisk (2.34-0.1ubuntu9.1) over (2.34-0.1ubuntu9) ...
Setting up fdisk (2.34-0.1ubuntu9.1) ...
Processing triggers for man-db (2.9.1-1) ...
ubuntu@wireguard-vpn:~$ sudo fdisk /dev/vda
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.
GPT PMBR size mismatch (41938999 != 58720255) will be corrected by write.
The backup GPT table is not on the end of the device. This problem will be corrected by write.
Command (m for help): m
Help:
GPT
M enter protective/hybrid MBR
Generic
d delete a partition
F list free unpartitioned space
l list known partition types
n add a new partition
p print the partition table
t change a partition type
v verify the partition table
i print information about a partition
Misc
m print this menu
x extra functionality (experts only)
Script
I load disk layout from sfdisk script file
O dump disk layout to sfdisk script file
Save & Exit
w write table to disk and exit
q quit without saving changes
Create a new label
g create a new empty GPT partition table
G create a new empty SGI (IRIX) partition table
o create a new empty DOS partition table
s create a new empty Sun partition table
Command (m for help): p
Disk /dev/vda: 28 GiB, 30064771072 bytes, 58720256 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: gpt
Disk identifier: 28F14FE7-A959-452C-B0A2-266A3C37C1EB
Device Start End Sectors Size Type
/dev/vda1 227328 41938966 41711639 19.9G Linux filesystem
/dev/vda14 2048 10239 8192 4M BIOS boot
/dev/vda15 10240 227327 217088 106M EFI System
Partition table entries are not in disk order.
Command (m for help): d
Partition number (1,14,15, default 15): 1
Partition 1 has been deleted.
Command (m for help): n
Partition number (1-13,16-128, default 1): 1
First sector (34-58720222, default 227328):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (227328-58720222, default 58720222):
Created a new partition 1 of type 'Linux filesystem' and of size 27.9 GiB.
Partition #1 contains a ext4 signature.
Do you want to remove the signature? [Y]es/[N]o: n
Command (m for help): p
Disk /dev/vda: 28 GiB, 30064771072 bytes, 58720256 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: gpt
Disk identifier: 28F14FE7-A959-452C-B0A2-266A3C37C1EB
Device Start End Sectors Size Type
/dev/vda1 227328 58720222 58492895 27.9G Linux filesystem
/dev/vda14 2048 10239 8192 4M BIOS boot
/dev/vda15 10240 227327 217088 106M EFI System
Partition table entries are not in disk order.
Command (m for help): w
The partition table has been altered.
Syncing disks.
ubuntu@wireguard-vpn:~$ sudo resize2fs /dev/vda1
resize2fs 1.45.5 (07-Jan-2020)
Filesystem at /dev/vda1 is mounted on /; on-line resizing required
old_desc_blocks = 3, new_desc_blocks = 4
The filesystem on /dev/vda1 is now 7311611 (4k) blocks long.
ubuntu@wireguard-vpn:~$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 474M 0 474M 0% /dev
tmpfs 99M 984K 98M 1% /run
/dev/vda1 27G 3.3G 24G 13% /
tmpfs 491M 0 491M 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 491M 0 491M 0% /sys/fs/cgroup
/dev/vda15 105M 3.9M 101M 4% /boot/efi
/dev/loop1 56M 56M 0 100% /snap/core18/1885
/dev/loop4 56M 56M 0 100% /snap/core18/1988
/dev/loop5 70M 70M 0 100% /snap/lxd/19188
/dev/loop6 33M 33M 0 100% /snap/snapd/11107
tmpfs 99M 0 99M 0% /run/user/1000
/dev/loop0 71M 71M 0 100% /snap/lxd/19647
/dev/loop2 33M 33M 0 100% /snap/snapd/11402
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment