Tervetuloa virtuaalipalvelinten esittelyyn!

Nyt virtuaalipalvelin vain 40 €/vuosi - Tilaa! Vai shell-tunnus vain 5 €/vuosi? - Tutustu!

Virtuaalipalvelimen levytilan optimointi

Ohje perustuu Ubuntu 20.04 LTS -versioon. Ennen näitä toimenpiteitä käyttöjärjestelmä vei noin 3 GB ja näiden toimenpiteiden jälkeen enää 1.8 GB. Sendanorin mini-virtuaalissa on näin ollen vapaata tilaa noin 4.7 GB heti asennuksen jälkeen. Luonnollisesti tämä tila vähenee ajan kanssa lokitiedostojen ja muun datan ja ohjelmien asentamisen myötä.

Sendanorin virtuaalipalvelimissa on tavallisesti Ubuntun vakiopaketit mukana. Nämä vievät kuitenkin usein tarpeetonta levytilaa tuotantoympäristöstä, joten monet niistä voi huoletta poistaa. Näin teemme asiakkaiden puolesta valmiiksi myös mini-virtuaalipalvelimissamme.

Ensiksi muutetaan lokituksen kierrätys kolmeen päivään:

sudo journalctl --vacuum-time=3d

Seuraavaksi poistetaan snap -paketit ja kokonaan itse snapd:

sudo snap remove --purge lxd

sudo snap remove --purge core18

sudo apt-get remove --purge snapd

sudo apt-get install linux-virtual

Seuraavaksi poistetaan tarpeettomia graafisen ympäristön paketteja:

sudo apt-get remove --purge x11-common x11-utils x11-xserver-utils libx11-xcb1:amd64 libx11-protocol-perl libx11-data libx11-6:amd64

Seuraavaksi poistetaan tarpeettomia ääneen liittyviä paketteja:

sudo apt-get remove --purge alsa-ucm-conf alsa-topology-conf

Seuraavaksi poistetaan tarpeettomia kryptoon liittyviä paketteja:

sudo apt-get remove --purge cryptsetup cryptsetup-bin cryptsetup-initramfs cryptsetup-run

Seuraavaksi poistetaan tarpeettomia paketteja liittyen ohjelmistojen kääntämiseen:

sudo apt-get remove --purge cpp cpp-9 build-essential dpkg-dev g++ g++-9 gcc gcc-9 make

Seuraavaksi poistetaan tarpeettomia paketteja liittyen dynaamisesti IP-osoitteiden asettamiseen:

sudo apt-get remove --purge isc-dhcp-client isc-dhcp-common

Seuraavaksi poistetaan tarpeettomia paketteja liittyen man-sivuihin ja dokumentaatioon:

sudo apt-get remove --purge man-db manpages manpages-dev

Seuraavaksi poistetaan tarpeettomia paketteja liittyen langattomiin yhteyksiin:

sudo apt-get remove --purge wireless-tools wireless-regdb

Seuraavaksi poistetaan tarpeettomia paketteja liittyen Node.js-ympäristöön:

sudo apt-get remove --purge \
node-abbrev node-ajv node-ansi node-ansi-align node-ansi-regex \
node-ansi-styles node-ansistyles node-aproba node-archy node-are-we-there-yet node-asap \
node-asn1 node-assert-plus node-asynckit node-aws-sign2 node-aws4 node-balanced-match \
node-bcrypt-pbkdf node-bl node-bluebird node-boxen node-brace-expansion node-builtin-modules \
node-builtins node-cacache node-call-limit node-camelcase node-caseless node-chalk node-chownr \
node-ci-info node-cli-boxes node-cliui node-clone node-co node-color-convert node-color-name \
node-colors node-columnify node-combined-stream node-concat-map node-concat-stream \
node-config-chain node-configstore node-console-control-strings node-copy-concurrently \
node-core-util-is node-cross-spawn node-crypto-random-string node-cyclist node-dashdash \
node-debug node-decamelize node-decompress-response node-deep-extend node-defaults \
node-define-properties node-delayed-stream node-delegates node-detect-indent \
node-detect-newline node-dot-prop node-duplexer3 node-duplexify node-ecc-jsbn \
node-editor node-encoding node-end-of-stream node-err-code node-errno node-es6-promise \
node-escape-string-regexp node-execa node-extend node-extsprintf node-fast-deep-equal \
node-find-up node-flush-write-stream node-forever-agent node-form-data node-from2 \
node-fs-vacuum node-fs-write-stream-atomic node-fs.realpath node-function-bind \
node-gauge node-genfun node-get-caller-file node-get-stream node-getpass node-glob \
node-got node-graceful-fs node-gyp node-har-schema node-har-validator node-has-flag \
node-has-symbol-support-x node-has-to-string-tag-x node-has-unicode node-hosted-git-info \
node-http-signature node-iconv-lite node-iferr node-import-lazy node-imurmurhash node-inflight \
node-inherits node-ini node-invert-kv node-ip node-ip-regex node-is-npm node-is-obj node-is-object \
node-is-path-inside node-is-plain-obj node-is-retry-allowed node-is-stream node-is-typedarray \
node-isarray node-isexe node-isstream node-isurl node-jsbn node-json-parse-better-errors \
node-json-schema node-json-schema-traverse node-json-stable-stringify node-json-stringify-safe \
node-jsonify node-jsonparse node-jsonstream node-jsprim node-latest-version node-lazy-property \
node-lcid node-libnpx node-locate-path node-lockfile node-lodash node-lodash-packages node-lowercase-keys \
node-lru-cache node-make-dir node-mem node-mime node-mime-types node-mimic-fn node-mimic-response \
node-minimatch node-minimist node-mississippi node-mkdirp node-move-concurrently node-ms node-mute-stream \
node-nopt node-normalize-package-data node-npm-bundled node-npm-package-arg node-npm-run-path node-npmlog \
node-number-is-nan node-oauth-sign node-object-assign node-once node-opener node-os-locale node-os-tmpdir \
node-osenv node-p-cancelable node-p-finally node-p-is-promise node-p-limit node-p-locate node-p-timeout \
node-package-json node-parallel-transform node-path-exists node-path-is-absolute node-path-is-inside \
node-performance-now node-pify node-prepend-http node-process-nextick-args node-promise-inflight \
node-promise-retry node-promzard node-proto-list node-prr node-pseudomap node-psl node-pump \
node-pumpify node-punycode node-qs node-qw node-rc node-read node-read-package-json \
node-readable-stream node-registry-auth-token node-registry-url node-request \
node-require-directory node-require-main-filename node-resolve node-resolve-from node-retry \
node-rimraf node-run-queue node-safe-buffer node-semver node-semver-diff node-set-blocking \
node-sha node-shebang-command node-shebang-regex node-signal-exit node-slash node-slide \
node-sorted-object node-spdx-correct node-spdx-exceptions node-spdx-expression-parse \
node-spdx-license-ids node-sshpk node-ssri node-stream-each node-stream-iterate \
node-stream-shift node-strict-uri-encode node-string-decoder node-string-width \
node-strip-ansi node-strip-eof node-strip-json-comments node-supports-color \
node-tar node-term-size node-text-table node-through node-through2 node-timed-out \
node-tough-cookie node-tunnel-agent node-tweetnacl node-typedarray node-typedarray-to-buffer \
node-uid-number node-unique-filename node-unique-string node-unpipe node-uri-js node-url-parse-lax \
node-url-to-options node-util-deprecate node-uuid node-validate-npm-package-license \
node-validate-npm-package-name node-verror node-wcwidth.js node-which node-which-module \
node-wide-align node-widest-line node-wrap-ansi node-wrappy node-write-file-atomic node-xdg-basedir node-xtend \
node-y18n node-yallist node-yargs node-yargs-parser nodejs nodejs-doc npm

Seuraavaksi poistetaan paketit, jotka eivät ole enää tarpeen:

sudo apt-get autoremove

sudo apt-get autoclean

sudo apt-get clean

Seuraavaksi varmistetaan poistetuksi seuraavien riippuvuuksina olleiden pakettien sisältö:

sudo dpkg -P amd64-microcode intel-microcode fontconfig-config \
fonts-dejavu-core javascript-common libfakeroot:amd64 \
libgl1-mesa-dri:amd64 libpython2.7-minimal:amd64 libsensors-config \
python2.7-minimal python3-json-pointer python3-jsonpatch \
python3-jsonschema thermald upower usbmuxd

Seuraavaksi poistetaan ylimääräinen swap-osio (poista jos sellainen löytyy!)

sudo swapoff /swap.img

sudo rm /swap.img

Tässä vaiheessa kannattaa käynnistää virtuaalipalvelin uusiksi, jotta mikään poistettu ohjelmisto ei varmasti ole enää käytössä tai välimuistissa.

reboot

Operaatioiden jälkeen levytilaa on seuraavasti käytössä:

# df -h /
Filesystem Size Used Avail Use% Mounted on
/dev/vda2 6.8G 1.8G 4.7G 28% /

Optimoitu ympäristö vie suunnilleen tämän verran muistia:

# free -m
total used free shared buff/cache available
Mem: 461 100 237 0 123 340
Swap: 1021 0 1021