How big is a clean install of Ubuntu Jammy Jellyfish (22.04)?
Because curiosity killed the cat, not because it’s useful! 😀
Start with a clean install in a virtual machine
I start with a simple Vagrantfile
:
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/jammy64"
config.vm.provision "ansible" do |ansible|
ansible.playbook = "playbook.yml"
end
end
This Ansible playbook updates all packages to the latest version and removes unused packages.
- name: Update all packages to the latest version
hosts: all
remote_user: ubuntu
become: yes
tasks:
- name: Update apt cache
apt:
update_cache: yes
cache_valid_time: 3600
force_apt_get: yes
- name: Upgrade all apt packages
apt:
force_apt_get: yes
upgrade: dist
- name: Check if a reboot is needed for Ubuntu boxes
register: reboot_required_file
stat: path=/var/run/reboot-required get_md5=no
- name: Reboot the Ubuntu box
reboot:
msg: "Reboot initiated by Ansible due to kernel updates"
connect_timeout: 5
reboot_timeout: 300
pre_reboot_delay: 0
post_reboot_delay: 30
test_command: uptime
when: reboot_required_file.stat.exists
- name: Remove unused packages
apt:
autoremove: yes
purge: yes
force_apt_get: yes
Then bring up the virtual machine with vagrant up --provision
.
Get the installation size
I ssh into the box (vagrant ssh
) and run a couple of commands to get some numbers.
Number of installed packages:
$ dpkg-query --show | wc --lines
592
Size of the installed packages:
$ dpkg-query --show --showformat '${Installed-size}\n' | awk '{s+=$1*1024} END {print s}' | numfmt --to=iec-i --format='%.2fB'
1.14GiB
I need to multiply the package size with 1024 because dpkg-query
outputs size in kilobytes.
Total size:
$ sudo du --summarize --human-readable --one-file-system /
1.9G /
Get the installation size using Ansible
Of course, I can also add this to my Ansible playbook, and then I don’t have to ssh into the virtual machine.
- name: Get the number of installed packages
shell: dpkg-query --show | wc --lines
register: package_count
changed_when: false
failed_when: false
- debug: msg="{{ package_count.stdout }}"
- name: Get the size of installed packages
shell: >
dpkg-query --show --showformat '${Installed-size}\n'
| awk '{s+=$1*1024} END {print s}'
| numfmt --to=iec-i --format='%.2fB'
register: package_size
changed_when: false
failed_when: false
- debug: msg="{{ package_size.stdout }}"
- name: Get the disk size with du
shell: >
du --summarize --one-file-system /
| numfmt --to=iec-i --format='%.2fB'
register: du_used
changed_when: false
failed_when: false
- debug: msg="{{ du_used.stdout }}"
The output is then:
TASK [Get the number of installed packages] ************************************
ok: [default]
TASK [debug] *******************************************************************
ok: [default] => {
"msg": "592"
}
TASK [Get the size of installed packages] **************************************
ok: [default]
TASK [debug] *******************************************************************
ok: [default] => {
"msg": "1.14GiB"
}
TASK [Get the disk size with du] ***********************************************
ok: [default]
TASK [debug] *******************************************************************
ok: [default] => {
"msg": "1.82MiB /"
}