Expand partitions/fs in linux

Resizing partitions

Sometimes necessary so lets write this down so I won't forget next time.

This is easy for expanding. If you want to shrink the size it is going to be a bit harder, and I am not covering it in this note.

fdisk -l /dev/sda

growpart --dry-run /dev/sda 2
# ^ device and then the partition to grow
# The partition on the disk is now expanded.
# now to expand the filesystem it contains

df -h
resize2fs /dev/sda2

Github authorized_keys into terraform list

I needed to create a list of my authorized keys from the Github source in terraform. The following will provide a list that you can use. Handy for cloud init.

data "http" "github-keys" {
  url = "https://github.com/ledakis.keys"
}

output "keys" {
    value = compact(split("\n",data.http.github-keys.body))
}

Gist here.

WSL DNS issues

Sometimes my WSL's DNS changed to something weird and it stopped resolving.

/etc/resolv.conf contains the relevant nameservers, usually when WSL breaks this contains some 172. something IP that is not resolving properly.

You can change the nameserver section but that will not keep the settings for a while as WSL reapplies it.

To fix, you need to add the following to /etc/wsl.conf

[network]
generateResolvConf = false

This will stop the WSL from updating the DNS entries on the next WSL boot.

You need to turn it off and start it again using this in an Elevated Powershell: wsl --shutdown After that, open WSL again and the DNS should not be automatically modified.

Now remove the symlink that is the previous /etc/resolv.conf:

sudo rm /etc/resolv.conf

And then create it again and save:

nameserver 8.8.8.8

From now on the DNS entry should stay as is.

© Copyright 2019-2021 by Theocharis Ledakis.