Saving Space mini-HOWTO <!-- <author>Guido Gonzato <url url="mailto:guido@ibogeo.df.unibo.it"> --> <author>Guido Gonzato(guido@ibogeo.df.unibo.it) <date>v1.0.1, 7 April 1999 <trans>山下 義之 <tdate>20 April 2000 <abstract> <!-- This mini-HOWTO gives you directions for squeezing your Linux installation into the least possible space. It's particularly aimed at notebook users. --> この mini-HOWTO はお使いの Linux システムをぎりぎりまでスリムにするための手引きです。 とりわけノートパソコンのユーザーを念頭に置いて書かれています。 </abstract> <toc> <sect> <!-- Introduction --> はじめに <p> <!-- I've got a notebook I installed Linux on, beside Windows 95 that was pre-installed. I squeezed the Windows partition to 500 Mb, making space for a 240 Mb Linux one. Small though the latter may seem, I've managed to install a fairly complete Linux system on it, based on Red Hat 4.1 and some magic to save as much space as possible. --> 筆者の手持ちのノートパソコンでは、もともとインストールされていた Windows 95 と あとからインストールした Linux が共存しています。Windows のパーティションを 500MB まで切り詰めた結果、Linux のパーティションとしては 240MB のスペースを 確保できました。後者は小さく感じられるかもしれませんが、RedHat 4.1 にちょっ とした細工をほどこすことで、なるべく多くのスペースを節約し、それなりに充実 した Linux システムを導入できています。 <!-- If you're in need for space, the indications you'll find in the following sections will free up a considerable chunk of hard disk. The only caveat I'm giving you is: don't blame me if something goes wrong! We'll be using a couple of programs that worked fine for me, but are inherently dangerous. You've been warned. --> 空きスペースが不足しているという方も、以下の各章に記されたアイデアを実行すれば、 ハードディスクの空き容量をかなり増やせることでしょう。ただし、ひとつだけお断り を――トラブルが発生してもわたしのせいにはしないように! これから使用するプロ グラムは、いずれも筆者の環境においてうまく機能しましたが、そもそも危険性の伴う ものばかりです。確かに警告しましたからね。 <sect> <!-- Software requirements --> 用意すべきソフトウェア <p> <!-- You need: --> 必要なものは以下のとおり。 <itemize> <item> <!-- a fully working Linux system (any version should be OK); --> きちんと動作する Linux システム(どのバージョンでもよいはず)。 <item> <!-- the common <tt/gzip/ compression utility, or alternatively <tt/bzip2/ that you find on <url url="ftp://sunsite.unc.edu:/pub/Linux/utils/compress">; this tool compresses better than <tt/gzip/, but it's also a wee bit slower and consumes a lot of memory; --> おなじみの圧縮プログラム gzip。さもなくば、 <url url="ftp://sunsite.unc.edu:/pub/Linux/utils/compress"> で bzip2 を入手してもよい。 こちらは gzip に勝る圧縮率を誇るものの、やや処理が遅く、メモリの消費量も多い。 <item> <!-- the <tt/upx/ executable compressor, whose home page is at <url url="http://cdata.tvnet.hu/~ml/upx.html"> and <url url="http://wildsau.idv.uni-linz.ac.at/mfx/upx.html">; --> 圧縮ツール upx。ホームページは <url url="http://cdata.tvnet.hu/~ml/upx.html"> と <url url="http://wildsau.idv.uni-linz.ac.at/mfx/upx.html"> 。 <item> <!-- the <tt/zlibc/ package, available on <url url="ftp://sunsite.unc.edu:/pub/Linux/libs/compression">. It's called <tt/zlibc-X.X.tar.gz/, where <tt/X.X/ is the latest version. --> zlibc パッケージ。これは <url url="ftp://sunsite.unc.edu:/pub/Linux/libs/compression"> で手に入る。 ファイル名は zlibc-X.X.tar.gz で、X.X の部分は最新のバージョン番号。 </itemize> <!-- There are other executable compressors. One is <tt/gzexe/ (forget it), while <tt/tcx/ was probably the best before <tt/upx/ became available; yet another is <tt/tzx/, in theory better than <tt/tcx/. The thing is, it screwed everything up when I tried it on a spare PC, though I'm not sure if I did something wrong. You had better stick with <tt/upx/: it's reliable, efficient, and very handy. --> 圧縮ツールはほかにもあります。gzexe もそのひとつですが(無視)、upx が出回る以前の 最上品といえば tcx でしょう。また、理論上は tcx より tzx のほうがさらに優れているは ずです。もっとも、操作に手落ちがあったのか、遊んでいたパソコンで筆者が tzx を使って みたときは大失敗に終わりました。ここはやはり upx でしょう。信頼の置ける優秀なソフト ですし、扱いもごく簡単です。 <!-- There are kernel patches that provide transparent file system compression a la Stacker, but as of this writing none of them has yet a reputation for stability and reliability. For safety's sake, steer clear. --> Stacker よろしく、ファイルシステムの透過的な圧縮を実現するカーネルパッチもいくつか ありますが、本稿の執筆時点では、安定性および信頼性の面で定評を確立するまでに至って いません。手を出さないほうが無難でしょう。 <sect> <!-- The procedure --> 手順 <p> <sect1> <!-- Removing the Kernel Sources --> カーネルソースの削除 <p> <!-- The kernel sources take up more than 20 Mb, and you may want to remove them. If so, I suggest that you compile a new kernel that is tailored to your machine once and for all, then get rid of the sources. Take care, though. --> カーネルソースは 20MB 以上もありますから、削除したくなるところでしょう。 そうとなったら、ご自分のマシンに合った新しいカーネルをコンパイルしてし まい、しかるのちにソースを処分することです。ただし、作業は慎重にどうぞ。 <!-- I <em/don't/ recommend that you remove the kernel sources unless you are sure that your machine is properly configured. Besides, you need the kernel #includes to compile C programs. Think twice! --> マシンの設定がきちんとできているかどうか心もとないのなら、カーネルソースの 削除は決してお勧めできません。また、カーネルのインクルードファイルは C のプ ログラムをコンパイルする際に欠かせません。事前にじっくり考えましょう! <!-- If you do decide so, <em/do not/ remove the <file>include/linux</file> tree unless you know you'll never compile applications on your machine. --> 削除することにした場合も、以後そのマシンでアプリケーションをコンパイルする 可能性がゼロでなければ、include/linux 以下のディレクトリツリーはぜひ残して おきましょう。 <sect1> <!-- Pruning Out Applications --> アプリケーションの整理 <p> <!-- Now, decide which applications you <em/really/ need. Some may prove redundant: for instance, are you sure you can't live without <tt/emacs/? You could use <tt/jed/ instead. --> さて、どうしても必要なアプリケーションを選別してください。考えてみれば余計な ものもあるはずです。たとえば、本当に Emacs なしではやっていけませんか? 代わ りに jed を使う手もありますよ。 <!-- It's up to you to decide what you want to keep. Some general points: --> どれを残すべきか判断するのはあなた自身です。以下は一般論になります。 <itemize> <item> <!-- <tt/gcc/ is a fairly large package. It's needed to recompile the kernel and all the applications for which there are no pre-built Linux binaries. It's also needed, of course, if you write your own C or Fortran (with <tt/f2c/ or <tt/g77/) programs; consider your needs before removing it. Other compilers like <tt/lcc/ are fine, but not up to <tt/gcc/ level. I suggest that you keep it; --> gcc はかなり大きなパッケージです。が、カーネルを再構築するときや、Linux 向けの バイナリが用意されていないアプリケーションを再コンパイルするときには欠かせません。 また、言うまでもありませんが、自分の手で C や( f2c ないし g77 を使って)Fortran のプログラムを書くときも入り用になります。自分には何が必要なのか、削除する前によ く考えてください。lcc など、ほかのコンパイラも悪くはありませんが、gcc にはおよび ません。残しておいてはどうでしょう。 <item> <!-- X11 is awfully large, but it's a nice thing to have. If you decide you can't give it up, at least try to make do with as little as necessary: only the right X server, one simple window manager, only one <tt/xterm/, no 100 dpi fonts, and so on; --> X11 はどうしようもなく大きいのですが、あったほうがありがたいものです。手放せない となったら、せめて必要最小限の構成で間に合わせるよう努めましょう。X サーバは使う ものだけ、ウィンドウマネージャはシンプルなものをひとつだけ、xterm もひとつだけ、 100 dpi のフォントはすっかり削除、という具合に。 <item> <!-- TeX and accompanying packages are very large indeed. Giving up LaTeX and sticking to plain TeX saves a lot of space; giving up X11 previewers like <tt/xdvi/ and <tt/ghostview/ is possible if you use <tt/dvitty/, <tt/dvivga/ and some such. Eliminating the need for X11 dviware could even make X11 redundant; --> TeX および付随するパッケージの大きさたるや相当なものです。LaTeX をお払い箱にして、 ひたすら plain TeX を利用すれば、おおいにスペースを節約できます。また、dvi2tty や dvivga を使うことにすれば、xdvi や ghostview といった X11 のプレビュー用プロ グラムも処分できます。X11 の DVI プログラムが不要となったら、X11 そのものすら 無用の長物になるかもしれません。 <item> <!-- games are never ``necessary''. --> ゲームが「必要」ということはありませんよね。 </itemize> <sect1> <!-- Stripping Binaries --> バイナリのシェイプアップ <p> <!-- Let's start reducing the size of binaries. Move to <file>/usr/bin</file> and issue the command --> ここではバイナリファイルのサイズを縮小していきましょう。/usr/bin に移動してから、 <!-- <tscreen><verb> machine:/usr/bin# strip * </verb></tscreen> --> <tscreen><verb> # strip * </verb></tscreen> <!-- which will do away with symbols embedded in binaries. Repeat this step in <file>/usr/X11R6/bin/</file> and other directories containing executables you may have (don't forget to locate TeX's and <tt/gcc/'s binaries), but <em/do not/ run it under <file>/sbin</file>, <file>/bin</file>, or <file>/usr/sbin/</file> if you value your installation! --> とコマンドを入力すれば、バイナリに埋めこまれているシンボルが除去されます。 /usr/X11R6/bin/ など、実行ファイルが置いてあるディレクトリで同じ作業をく りかえしてください( TeX と gcc のバイナリも抜かりなく探しだしましょう)。 ただし、ご自分のシステムが大事なら、絶対に /sbin や /bin 、/usr/sbin/ で 実行してはいけませんよ! <sect1> <!-- Compressing with <tt/upx/ --> upx による圧縮 <p> <!-- First, install <tt/upx/ and read its documentation. Then go to <file>/usr/bin</file> and run it with the command <tt>upx *</tt>; it will compress all executables, including suid ones (<tt/tcx/ wouldn't). Repeat this step in other directories as seen above. --> まずは upx をインストールして、付属の文書に目を通します。それから /usr/bin に 移動し、upx * を実行します。これで実行ファイルはすべて、それも( tcx とは違って) suid されたものまで圧縮できるはずです。この作業も前述の各ディレクトリでくりか えしてください。 <!-- Remember to compress the executables whenever you install a new package! --> 新たにパッケージをインストールするときは、各種実行ファイルの圧縮をお忘れなく! <sect1> <!-- Gzipping around --> かたっぱしから gzip <p> <!-- There are lots of other files that can be compressed once and for all. Let's start with <file>/usr/doc/</file>; move to this directory and issue the command --> 圧縮してしまえるファイルはまだまだあります。まずは /usr/doc/ に取りかかりましょう。 このディレクトリに移動したら、次のコマンドを入力してください。 <!-- <tscreen><verb> machine:/usr/doc# find . -type f -exec gzip -9 {} \; 2> /dev/null </verb></tscreen> --> <tscreen><verb> # find . -type f -exec gzip -9 {} \; 2> /dev/null </verb></tscreen> <!-- Remember to compress the docs whenever you install a new package! --> 新たにパッケージをインストールするときは、各種文書ファイルの圧縮をお忘れなく! <!-- Repeat this step in the directory containing the documentation for TeX (on my system, <file>/usr/lib/texmf/texmf/doc/</file>. If you're <em/really sure/, remove these directories altogether. --> この作業は TeX の関連文書があるディレクトリ(筆者の場合は /usr/lib/texmf/texmf/doc/) でもくりかえします。また、本当にかまわないと言い切れる方は、こうしたディレクトリを すっかり削除してください。 <!-- Now, install <tt/zlibc/ and compile it. If your system is like mine, the compilation process will abort complaining about a missing (static) libc. Never mind; you'll find a file called <tt/uncompress.o/ that is what's needed. Move it to <file>/usr/local/lib/</file> and add this line to your <file>/etc/profile</file>: --> さて、つづいては zlibc のインストールとコンパイルです。お使いのシステムが筆者の環境 と似通っているなら、コンパイラは(static な)libc がないという趣旨のメッセージを出し、 途中で止まってしまうでしょう。それでも心配はいりません。uncompress.o という 名のファイルがありますね? 必要なのはこいつです。これを /usr/local/lib/ に移動し てやり、/etc/profile に次の一行を追記してください。 <tscreen><verb> export LD_ELF_PRELOAD=/usr/local/lib/uncompress.o </verb></tscreen> <!-- Now, you can compress with <tt/gzip/ not only documentation, but also data files: the applications that use them will be able to use them nonetheless. In theory, the trick should work with most applications, but in practice your degree of success may vary. Mine was rather unimpressive. --> さあ、これで文書ファイルばかりか、データファイルも gzip で圧縮できるようになりました。 アプリケーションが利用するデータファイルは、今や圧縮されていても利用できるのです。 この裏技は、理屈の上ではたいていのアプリケーションに通用するはずですが、実際の成果は まちまちでしょう。筆者の場合は今ひとつでした。 <sect> <!-- A Real Life Example --> 実際の一例 <p> <!-- This is what I got applying the above procedure to one of my machines. Before the treatment, <tt/df/ reported I used 398,798 1024-blocks: --> 以下は筆者が前述の手順を手持ちの一台で実践した結果です。処置をほどこす前のディスク 使用量は、df によると 398,798 ブロックでした。 <itemize> <item> <!-- I didn't remove the kernel sources and the kernel headers; --> カーネルソースとカーネルヘッダーは削除しないことにする。 <item> <!-- I uninstalled several applications and all of the games, but I left X11, X11 development, C and Fortran development, Tcl/Tk, networking tools, and a few other standard applications. <tt/df/ reported 244,668 used blocks; --> 数々のアプリとゲームすべてを削除。ただし、X11 および X11 の開発環境、C と Fortran の開発環境、Tcl/Tk 、ネットワーク関連ツール、そしてスタンダードなアプリ少々は残して おく。df の表示する使用量は 244,668 ブロックに。 <item> <!-- I ran <tt/upx/ on <file>/usr/bin</file>, <file>/usr/X11R6/bin</file>, <file>/usr/lib/texmf/bin/i586-linux</file>, and <file>/usr/lib/gcc-lib/i386-linux/2.7.2.1</file>. 226,270 used blocks; --> /usr/bin と /usr/X11R6/bin 、/usr/lib/texmf/bin/i586-linux 、 /usr/lib/gcc-lib/i386-linux/2.7.2.1 で upx を実行。使用量は 226,270 ブロックに。 <item> <!-- I compressed the documentation under <file>/usr/doc</file> and <file>/usr/lib/texmf/texmf/doc</file>: 198,745 used blocks. --> /usr/doc および /usr/lib/texmf/texmf/doc 以下の文書を圧縮。使用量は 198,745 ブロックに。 </itemize> <!-- To sum up, I started with 398,798 blocks and finished with 198,745. Think of the stuff you can shove in those 200,000 spared blocks! I would have saved even more if I had used <tt/bzip2/ instead of <tt/gzip/. --> 結論を述べると、398,798 ブロックからはじめて 198,745 ブロックにおちついたわけです。 空いた 200,000 ブロックにどれだけのものが押しこめることか! しかも、gzip の代わり に bzip2 を使っていたら、節約できるスペースはさらに増えていたはず。 <!-- On average, if you are careful from the beginning and install only the necessary applications, compressing executables and documents will save you some 20 Mb. On a notebook, this can be a lifesaver. --> はじめから必要なアプリケーションのみをインストールするように心がけていれば、実行 ファイルと文書を圧縮するだけで、平均して 20MB 程度のスペースが浮くものです。ノート パソコンをお使いなら、これで救われる場合もあることでしょう。 <sect> <!-- The End --> 最後に <p> <sect1> <!-- Copyright --> 著作権について <p> (訳注:参考までに訳文をつけておきますが、著作権に関しては原文の内容が優先されます) Unless otherwise stated, Linux HOWTO documents are copyrighted by their respective authors. Linux HOWTO documents may be reproduced and distributed in whole or in part, in any medium physical or electronic, as long as this copyright notice is retained on all copies. Commercial redistribution is allowed and encouraged; however, the author would like to be notified of any such distributions. 特に明記されていないかぎり、Linux HOWTO 文書の著作権はそれぞれの著者に属します。 この著作権条項さえ逐一きちんと記されていれば、Linux HOWTO 文書の複製ならびに配布は、 一括した形であれ個別の形であれ、印刷物や電子メディア等の媒体を問わず、自由に行って かまいません。商業目的の再配布も認められていますし、むしろ奨励されています。ただし、 配布の際には著者当人に連絡していただけると幸いです。 All translations, derivative works, or aggregate works incorporating any Linux HOWTO documents must be covered under this copyright notice. That is, you may not produce a derivative work from a HOWTO and impose additional restrictions on its distribution. Exceptions to these rules may be granted under certain conditions; please contact the Linux HOWTO coordinator at the address given below. Linux HOWTO 文書を翻訳・編集・集成したものには、この著作権条項が例外なく適用されます。 従って、HOWTO 文書を第三者が編集した場合でも、その配布に新たな制限をもうけることは許 されません。もっとも、事と次第によっては、こうした規定に例外が認められる場合もあります。 下記のアドレスまで、Linux HOWTO の世話役宛てにご連絡ください。 In short, we wish to promote dissemination of this information through as many channels as possible. However, we do wish to retain copyright on the HOWTO documents, and would like to be notified of any plans to redistribute the HOWTOs. 端的に言えば、なるべく多くのルートを通じて本稿が普及することを当方は望んでいます。 しかし、HOWTO 文書の著作権を保持しておきたいことも事実ですし、HOWTO 文書を再配布 する場合はぜひ事前に通知していただきたいのです。 If you have questions, please contact Tim Bynum, the Linux HOWTO coordinator, at tjbinum@sunsite.unc.edu via email. 質問があれば、Linux HOWTO の世話役 Tim Bynum までメールでどうぞ。 アドレスは tjbinum@sunsite.unc.edu です。 <sect1> <!-- Disclaimer --> 免責条項 <p> <!-- ``Saving Space mini-HOWTO''was written by Guido Gonzato, <url url="REMOVE_MEguido@ibogeo.df.unibo.it">. --> &dquot;Saving Space mini-HOWTO&dquot; は Guido Gonzato <url url="mailto:REMOVE_MEguido@ibogeo.df.unibo.it"> の手になる文書です。 <!-- This document is provided ``as is''. I put great effort into writing it as accurately as I could, but you use the information contained in it at your own risk. In no event shall I be liable for any damages resulting from the use of this work. --> 本稿は「無保証」の文書です。執筆に当たっては正確を期して少なからず努力しましたが、 内容を実践する際はご自分の責任でお願いします。本稿の利用から生じた損害に対して、筆 者はなんら責任を負いません。 <!-- Feedback is welcome. For any requests, suggestions, flames, etc., feel free to contact me. --> 読者の声は歓迎します。要望や提案、お叱りなどなど、お気軽にどうぞ。 <!-- Enjoy Linux and life, --> Linux と人生を楽しんでくださいね。 Guido <tt/=8-)/ </article>