How do I reduce the size of locale-archive?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












16















I have a need to reduce the size of the locale-archive file on some of my RHEL6 systems.



Here is that file on my system:



[root@-dev-007 locale]# ls -l
total 96800
-rw-r--r--. 1 root root 99158704 Sep 9 15:22 locale-archive
-rw-r--r--. 1 root root 0 Jun 20 2012 locale-archive.tmpl


So I did this ...



[root@-dev-007 locale]# localedef --list | grep zh_CN
zh_CN
zh_CN.gb18030
zh_CN.gb2312
zh_CN.gbk
zh_CN.utf8


... so I figured I could get rid of zh_CN like so ...



[root@-dev-007 locale]# localedef --delete-from-archive zh_CN


... and I can see zh_CN does not get listed anymore like so ...



[root@-dev-007 locale]# localedef --list | grep zh_CN
zh_CN.gb18030
zh_CN.gb2312
zh_CN.gbk
zh_CN.utf8


... but the size of the locale-archive does not get smaller ...



[root@-dev-007 locale]# ls -l 
total 96800
-rw-r--r--. 1 root root 99158704 Sep 9 17:16 locale-archive
-rw-r--r--. 1 root root 0 Jun 20 2012 locale-archive.tmpl


... is there something else I need to do?










share|improve this question




























    16















    I have a need to reduce the size of the locale-archive file on some of my RHEL6 systems.



    Here is that file on my system:



    [root@-dev-007 locale]# ls -l
    total 96800
    -rw-r--r--. 1 root root 99158704 Sep 9 15:22 locale-archive
    -rw-r--r--. 1 root root 0 Jun 20 2012 locale-archive.tmpl


    So I did this ...



    [root@-dev-007 locale]# localedef --list | grep zh_CN
    zh_CN
    zh_CN.gb18030
    zh_CN.gb2312
    zh_CN.gbk
    zh_CN.utf8


    ... so I figured I could get rid of zh_CN like so ...



    [root@-dev-007 locale]# localedef --delete-from-archive zh_CN


    ... and I can see zh_CN does not get listed anymore like so ...



    [root@-dev-007 locale]# localedef --list | grep zh_CN
    zh_CN.gb18030
    zh_CN.gb2312
    zh_CN.gbk
    zh_CN.utf8


    ... but the size of the locale-archive does not get smaller ...



    [root@-dev-007 locale]# ls -l 
    total 96800
    -rw-r--r--. 1 root root 99158704 Sep 9 17:16 locale-archive
    -rw-r--r--. 1 root root 0 Jun 20 2012 locale-archive.tmpl


    ... is there something else I need to do?










    share|improve this question


























      16












      16








      16


      7






      I have a need to reduce the size of the locale-archive file on some of my RHEL6 systems.



      Here is that file on my system:



      [root@-dev-007 locale]# ls -l
      total 96800
      -rw-r--r--. 1 root root 99158704 Sep 9 15:22 locale-archive
      -rw-r--r--. 1 root root 0 Jun 20 2012 locale-archive.tmpl


      So I did this ...



      [root@-dev-007 locale]# localedef --list | grep zh_CN
      zh_CN
      zh_CN.gb18030
      zh_CN.gb2312
      zh_CN.gbk
      zh_CN.utf8


      ... so I figured I could get rid of zh_CN like so ...



      [root@-dev-007 locale]# localedef --delete-from-archive zh_CN


      ... and I can see zh_CN does not get listed anymore like so ...



      [root@-dev-007 locale]# localedef --list | grep zh_CN
      zh_CN.gb18030
      zh_CN.gb2312
      zh_CN.gbk
      zh_CN.utf8


      ... but the size of the locale-archive does not get smaller ...



      [root@-dev-007 locale]# ls -l 
      total 96800
      -rw-r--r--. 1 root root 99158704 Sep 9 17:16 locale-archive
      -rw-r--r--. 1 root root 0 Jun 20 2012 locale-archive.tmpl


      ... is there something else I need to do?










      share|improve this question
















      I have a need to reduce the size of the locale-archive file on some of my RHEL6 systems.



      Here is that file on my system:



      [root@-dev-007 locale]# ls -l
      total 96800
      -rw-r--r--. 1 root root 99158704 Sep 9 15:22 locale-archive
      -rw-r--r--. 1 root root 0 Jun 20 2012 locale-archive.tmpl


      So I did this ...



      [root@-dev-007 locale]# localedef --list | grep zh_CN
      zh_CN
      zh_CN.gb18030
      zh_CN.gb2312
      zh_CN.gbk
      zh_CN.utf8


      ... so I figured I could get rid of zh_CN like so ...



      [root@-dev-007 locale]# localedef --delete-from-archive zh_CN


      ... and I can see zh_CN does not get listed anymore like so ...



      [root@-dev-007 locale]# localedef --list | grep zh_CN
      zh_CN.gb18030
      zh_CN.gb2312
      zh_CN.gbk
      zh_CN.utf8


      ... but the size of the locale-archive does not get smaller ...



      [root@-dev-007 locale]# ls -l 
      total 96800
      -rw-r--r--. 1 root root 99158704 Sep 9 17:16 locale-archive
      -rw-r--r--. 1 root root 0 Jun 20 2012 locale-archive.tmpl


      ... is there something else I need to do?







      rhel disk-usage locale






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Sep 10 '13 at 17:05









      Joel Taylor

      743413




      743413










      asked Sep 9 '13 at 21:22









      Red CricketRed Cricket

      1,21431833




      1,21431833




















          2 Answers
          2






          active

          oldest

          votes


















          21














          You can first remove all unneeded locales by doing:



          $localedef --list-archive | grep -v -i ^en | xargs localedef --delete-from-archive


          Where ^en can be replaced by the locale you wish to keep



          Then



          $build-locale-archive


          If this gives you an error similar to



          $build-locale-archive
          /usr/sbin/build-locale-archive: cannot read archive header


          Then try this



          $mv /usr/lib/locale/locale-archive /usr/lib/locale/locale-archive.tmpl
          $build-locale-archive


          If that still fails, check your version. According to this page newer versions don't have the necessary files to rebuild the archive in order to save space. You'll need to run



          yum reinstall glibc-common


          In later releases of Red Hat Enterprise Linux, you may use dnf, a similar application.






          share|improve this answer




















          • 3





            I noticed though that I loss my ssh connection to the host when I execute build-locale-archive ... any way of preventing this?

            – Red Cricket
            Sep 10 '13 at 22:23






          • 2





            I'd be careful attempting this. Broke my CentOS server and took me 30 mins to figure out a solution. unix.stackexchange.com/questions/246705/…

            – PJ Brunet
            Dec 1 '15 at 23:02












          • dnf in rhel??? Surely you mean yum ;-)

            – Dani_l
            May 7 '16 at 13:53


















          0














          On Amazon Linux




          1. Delete the unused archives from the locale-archive. This command deletes all except the ones beginning with en.



            localedef --delete-from-archive $(localedef --list-archive | grep -v -i ^en | xargs)



          2. Copy the locale-archive (with removed locales) file to be the new locale-archive.tmpl file



            cp /usr/lib/locale/locale-archive /usr/lib/locale/locale-archive.tmpl



          3. Run build-locale-archive



            build-locale-archive


          Note: If you run build-locale-archive it zeros out the .tmpl file after each run and when you run it again you will see the error:



          build-locale-archive: cannot read archive header


          You can get a copy of the locale-archive.tmpl file either by copying the current locale-archive to locale-archive.tmpl or by downloading and unpacking glibc-common. If you use the default locale-archive.tmpl file from the glibc-common RPM and run build-locale-archive against it, it will create a full (~102MB) locale-archive. You need to repeat the above steps to get the smaller size archive.



          In the above case deleting all locales except the en_* ones my locale-archive went from 102MB down to 3.4MB






          share|improve this answer






















            Your Answer








            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "106"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f90006%2fhow-do-i-reduce-the-size-of-locale-archive%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            21














            You can first remove all unneeded locales by doing:



            $localedef --list-archive | grep -v -i ^en | xargs localedef --delete-from-archive


            Where ^en can be replaced by the locale you wish to keep



            Then



            $build-locale-archive


            If this gives you an error similar to



            $build-locale-archive
            /usr/sbin/build-locale-archive: cannot read archive header


            Then try this



            $mv /usr/lib/locale/locale-archive /usr/lib/locale/locale-archive.tmpl
            $build-locale-archive


            If that still fails, check your version. According to this page newer versions don't have the necessary files to rebuild the archive in order to save space. You'll need to run



            yum reinstall glibc-common


            In later releases of Red Hat Enterprise Linux, you may use dnf, a similar application.






            share|improve this answer




















            • 3





              I noticed though that I loss my ssh connection to the host when I execute build-locale-archive ... any way of preventing this?

              – Red Cricket
              Sep 10 '13 at 22:23






            • 2





              I'd be careful attempting this. Broke my CentOS server and took me 30 mins to figure out a solution. unix.stackexchange.com/questions/246705/…

              – PJ Brunet
              Dec 1 '15 at 23:02












            • dnf in rhel??? Surely you mean yum ;-)

              – Dani_l
              May 7 '16 at 13:53















            21














            You can first remove all unneeded locales by doing:



            $localedef --list-archive | grep -v -i ^en | xargs localedef --delete-from-archive


            Where ^en can be replaced by the locale you wish to keep



            Then



            $build-locale-archive


            If this gives you an error similar to



            $build-locale-archive
            /usr/sbin/build-locale-archive: cannot read archive header


            Then try this



            $mv /usr/lib/locale/locale-archive /usr/lib/locale/locale-archive.tmpl
            $build-locale-archive


            If that still fails, check your version. According to this page newer versions don't have the necessary files to rebuild the archive in order to save space. You'll need to run



            yum reinstall glibc-common


            In later releases of Red Hat Enterprise Linux, you may use dnf, a similar application.






            share|improve this answer




















            • 3





              I noticed though that I loss my ssh connection to the host when I execute build-locale-archive ... any way of preventing this?

              – Red Cricket
              Sep 10 '13 at 22:23






            • 2





              I'd be careful attempting this. Broke my CentOS server and took me 30 mins to figure out a solution. unix.stackexchange.com/questions/246705/…

              – PJ Brunet
              Dec 1 '15 at 23:02












            • dnf in rhel??? Surely you mean yum ;-)

              – Dani_l
              May 7 '16 at 13:53













            21












            21








            21







            You can first remove all unneeded locales by doing:



            $localedef --list-archive | grep -v -i ^en | xargs localedef --delete-from-archive


            Where ^en can be replaced by the locale you wish to keep



            Then



            $build-locale-archive


            If this gives you an error similar to



            $build-locale-archive
            /usr/sbin/build-locale-archive: cannot read archive header


            Then try this



            $mv /usr/lib/locale/locale-archive /usr/lib/locale/locale-archive.tmpl
            $build-locale-archive


            If that still fails, check your version. According to this page newer versions don't have the necessary files to rebuild the archive in order to save space. You'll need to run



            yum reinstall glibc-common


            In later releases of Red Hat Enterprise Linux, you may use dnf, a similar application.






            share|improve this answer















            You can first remove all unneeded locales by doing:



            $localedef --list-archive | grep -v -i ^en | xargs localedef --delete-from-archive


            Where ^en can be replaced by the locale you wish to keep



            Then



            $build-locale-archive


            If this gives you an error similar to



            $build-locale-archive
            /usr/sbin/build-locale-archive: cannot read archive header


            Then try this



            $mv /usr/lib/locale/locale-archive /usr/lib/locale/locale-archive.tmpl
            $build-locale-archive


            If that still fails, check your version. According to this page newer versions don't have the necessary files to rebuild the archive in order to save space. You'll need to run



            yum reinstall glibc-common


            In later releases of Red Hat Enterprise Linux, you may use dnf, a similar application.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited May 9 '16 at 23:32









            Thomas Dickey

            53.4k5101174




            53.4k5101174










            answered Sep 9 '13 at 23:06









            Joel TaylorJoel Taylor

            743413




            743413







            • 3





              I noticed though that I loss my ssh connection to the host when I execute build-locale-archive ... any way of preventing this?

              – Red Cricket
              Sep 10 '13 at 22:23






            • 2





              I'd be careful attempting this. Broke my CentOS server and took me 30 mins to figure out a solution. unix.stackexchange.com/questions/246705/…

              – PJ Brunet
              Dec 1 '15 at 23:02












            • dnf in rhel??? Surely you mean yum ;-)

              – Dani_l
              May 7 '16 at 13:53












            • 3





              I noticed though that I loss my ssh connection to the host when I execute build-locale-archive ... any way of preventing this?

              – Red Cricket
              Sep 10 '13 at 22:23






            • 2





              I'd be careful attempting this. Broke my CentOS server and took me 30 mins to figure out a solution. unix.stackexchange.com/questions/246705/…

              – PJ Brunet
              Dec 1 '15 at 23:02












            • dnf in rhel??? Surely you mean yum ;-)

              – Dani_l
              May 7 '16 at 13:53







            3




            3





            I noticed though that I loss my ssh connection to the host when I execute build-locale-archive ... any way of preventing this?

            – Red Cricket
            Sep 10 '13 at 22:23





            I noticed though that I loss my ssh connection to the host when I execute build-locale-archive ... any way of preventing this?

            – Red Cricket
            Sep 10 '13 at 22:23




            2




            2





            I'd be careful attempting this. Broke my CentOS server and took me 30 mins to figure out a solution. unix.stackexchange.com/questions/246705/…

            – PJ Brunet
            Dec 1 '15 at 23:02






            I'd be careful attempting this. Broke my CentOS server and took me 30 mins to figure out a solution. unix.stackexchange.com/questions/246705/…

            – PJ Brunet
            Dec 1 '15 at 23:02














            dnf in rhel??? Surely you mean yum ;-)

            – Dani_l
            May 7 '16 at 13:53





            dnf in rhel??? Surely you mean yum ;-)

            – Dani_l
            May 7 '16 at 13:53













            0














            On Amazon Linux




            1. Delete the unused archives from the locale-archive. This command deletes all except the ones beginning with en.



              localedef --delete-from-archive $(localedef --list-archive | grep -v -i ^en | xargs)



            2. Copy the locale-archive (with removed locales) file to be the new locale-archive.tmpl file



              cp /usr/lib/locale/locale-archive /usr/lib/locale/locale-archive.tmpl



            3. Run build-locale-archive



              build-locale-archive


            Note: If you run build-locale-archive it zeros out the .tmpl file after each run and when you run it again you will see the error:



            build-locale-archive: cannot read archive header


            You can get a copy of the locale-archive.tmpl file either by copying the current locale-archive to locale-archive.tmpl or by downloading and unpacking glibc-common. If you use the default locale-archive.tmpl file from the glibc-common RPM and run build-locale-archive against it, it will create a full (~102MB) locale-archive. You need to repeat the above steps to get the smaller size archive.



            In the above case deleting all locales except the en_* ones my locale-archive went from 102MB down to 3.4MB






            share|improve this answer



























              0














              On Amazon Linux




              1. Delete the unused archives from the locale-archive. This command deletes all except the ones beginning with en.



                localedef --delete-from-archive $(localedef --list-archive | grep -v -i ^en | xargs)



              2. Copy the locale-archive (with removed locales) file to be the new locale-archive.tmpl file



                cp /usr/lib/locale/locale-archive /usr/lib/locale/locale-archive.tmpl



              3. Run build-locale-archive



                build-locale-archive


              Note: If you run build-locale-archive it zeros out the .tmpl file after each run and when you run it again you will see the error:



              build-locale-archive: cannot read archive header


              You can get a copy of the locale-archive.tmpl file either by copying the current locale-archive to locale-archive.tmpl or by downloading and unpacking glibc-common. If you use the default locale-archive.tmpl file from the glibc-common RPM and run build-locale-archive against it, it will create a full (~102MB) locale-archive. You need to repeat the above steps to get the smaller size archive.



              In the above case deleting all locales except the en_* ones my locale-archive went from 102MB down to 3.4MB






              share|improve this answer

























                0












                0








                0







                On Amazon Linux




                1. Delete the unused archives from the locale-archive. This command deletes all except the ones beginning with en.



                  localedef --delete-from-archive $(localedef --list-archive | grep -v -i ^en | xargs)



                2. Copy the locale-archive (with removed locales) file to be the new locale-archive.tmpl file



                  cp /usr/lib/locale/locale-archive /usr/lib/locale/locale-archive.tmpl



                3. Run build-locale-archive



                  build-locale-archive


                Note: If you run build-locale-archive it zeros out the .tmpl file after each run and when you run it again you will see the error:



                build-locale-archive: cannot read archive header


                You can get a copy of the locale-archive.tmpl file either by copying the current locale-archive to locale-archive.tmpl or by downloading and unpacking glibc-common. If you use the default locale-archive.tmpl file from the glibc-common RPM and run build-locale-archive against it, it will create a full (~102MB) locale-archive. You need to repeat the above steps to get the smaller size archive.



                In the above case deleting all locales except the en_* ones my locale-archive went from 102MB down to 3.4MB






                share|improve this answer













                On Amazon Linux




                1. Delete the unused archives from the locale-archive. This command deletes all except the ones beginning with en.



                  localedef --delete-from-archive $(localedef --list-archive | grep -v -i ^en | xargs)



                2. Copy the locale-archive (with removed locales) file to be the new locale-archive.tmpl file



                  cp /usr/lib/locale/locale-archive /usr/lib/locale/locale-archive.tmpl



                3. Run build-locale-archive



                  build-locale-archive


                Note: If you run build-locale-archive it zeros out the .tmpl file after each run and when you run it again you will see the error:



                build-locale-archive: cannot read archive header


                You can get a copy of the locale-archive.tmpl file either by copying the current locale-archive to locale-archive.tmpl or by downloading and unpacking glibc-common. If you use the default locale-archive.tmpl file from the glibc-common RPM and run build-locale-archive against it, it will create a full (~102MB) locale-archive. You need to repeat the above steps to get the smaller size archive.



                In the above case deleting all locales except the en_* ones my locale-archive went from 102MB down to 3.4MB







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Feb 4 at 4:37









                James McDonaldJames McDonald

                1




                1



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Unix & Linux Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f90006%2fhow-do-i-reduce-the-size-of-locale-archive%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown






                    Popular posts from this blog

                    How to check contact read email or not when send email to Individual?

                    Bahrain

                    Postfix configuration issue with fips on centos 7; mailgun relay