Skip to content

Image disk space reduction#10172

Merged
saiarcot895 merged 3 commits intosonic-net:masterfrom
saiarcot895:disk-space-reduction
Mar 16, 2022
Merged

Image disk space reduction#10172
saiarcot895 merged 3 commits intosonic-net:masterfrom
saiarcot895:disk-space-reduction

Conversation

@saiarcot895
Copy link
Contributor

Why I did it

Reduce the disk space taken up during bootup and runtime.

How I did it

  1. Remove python package cache from the base image and from the containers.
  2. During bootup, if logs are to be stored in memory, then don't create the var-log.ext4 file just to delete it later during bootup.
  3. For the partition containing /host, don't reserve any blocks for just the root user. This just makes sure all disk space is available for all users, if needed during upgrades (for example).

How to verify it

Which release branch to backport (provide reason below if selected)

  • 201811
  • 201911
  • 202006
  • 202012
  • 202106
  • 202111

Description for the changelog

Link to config_db schema for YANG module changes

A picture of a cute animal (not mandatory but encouraged)

Only containers which appeared to have a significant pip cache size are
included here.

Signed-off-by: Saikrishna Arcot <[email protected]>
@saiarcot895 saiarcot895 force-pushed the disk-space-reduction branch from 9989477 to 45071d7 Compare March 14, 2022 05:37
@saiarcot895 saiarcot895 requested review from xumia and yxieca March 14, 2022 15:40
@saiarcot895 saiarcot895 force-pushed the disk-space-reduction branch 2 times, most recently from cb651aa to 385c7fd Compare March 14, 2022 19:02
…for just the root user

Signed-off-by: Saikrishna Arcot <[email protected]>
@saiarcot895 saiarcot895 force-pushed the disk-space-reduction branch from 385c7fd to 5d1fecf Compare March 15, 2022 00:28

# If logs are being stored in memory, then don't bother
# creating the log file just to have it deleted afterwards.
$logs_inram && exit 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've seen this syntax causing trouble when -x was used. Something related to newer version of sh treat unmatched condition as failure. It would be safer to use if statement.
I can see that this syntax was used at line 29 as well.

Not making this issue blocking.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah true, I was a bit surprised that it was working here, but for now, I matched the syntax on line 29.

@saiarcot895 saiarcot895 merged commit 5617b1a into sonic-net:master Mar 16, 2022
@saiarcot895 saiarcot895 deleted the disk-space-reduction branch March 17, 2022 00:35
@qiluo-msft
Copy link
Collaborator

This commit could not be cleanly cherry-picked to 202012. Please submit another PR.

@judyjoseph
Copy link
Contributor

@saiarcot895, commit could not be cleanly cherry-picked to 202111. Please submit another PR.

@judyjoseph judyjoseph removed Request for 202012 Branch Request for 202111 Branch For PRs being requested for 202111 branch labels Mar 28, 2022
saiarcot895 added a commit to saiarcot895/sonic-buildimage that referenced this pull request Mar 28, 2022
Reduce the disk space taken up during bootup and runtime.

1. Remove python package cache from the base image and from the containers.
2. During bootup, if logs are to be stored in memory, then don't create the `var-log.ext4` file just to delete it later during bootup.
3. For the partition containing `/host`, don't reserve any blocks for just the root user. This just makes sure all disk space is available for all users, if needed during upgrades (for example).

* Remove pip2 and pip3 caches from some containers

Only containers which appeared to have a significant pip cache size are
included here.

Signed-off-by: Saikrishna Arcot <[email protected]>

* Don't create var-log.ext4 if we're storing logs in memory

Signed-off-by: Saikrishna Arcot <[email protected]>

* Run tune2fs on the device containing /host to not reserve any blocks for just the root user

Signed-off-by: Saikrishna Arcot <[email protected]>
(cherry picked from commit 5617b1a)
saiarcot895 added a commit that referenced this pull request Mar 29, 2022
Reduce the disk space taken up during bootup and runtime.

1. Remove python package cache from the base image and from the containers.
2. During bootup, if logs are to be stored in memory, then don't create the `var-log.ext4` file just to delete it later during bootup.
3. For the partition containing `/host`, don't reserve any blocks for just the root user. This just makes sure all disk space is available for all users, if needed during upgrades (for example).

* Remove pip2 and pip3 caches from some containers

Only containers which appeared to have a significant pip cache size are
included here.

Signed-off-by: Saikrishna Arcot <[email protected]>

* Don't create var-log.ext4 if we're storing logs in memory

Signed-off-by: Saikrishna Arcot <[email protected]>

* Run tune2fs on the device containing /host to not reserve any blocks for just the root user

Signed-off-by: Saikrishna Arcot <[email protected]>
(cherry picked from commit 5617b1a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants