51

Following Linode's guide to Copy a Disk Over SSH:

ssh root@xx.xx.xxx.xx "dd if=/dev/sdX " | dd of=/PathToLocalLocation/server.img

Where xx.xx.xxx.xx is your server's IP, sdX - X stands for your drive's assigned letter, and also you must state the image's name = server.img

I ran into this issue (on my local computer):

bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)

I conducted a long search with many results which none of worked for Lish nor were they a complete solution.

I couldn't set locales on the Lish command line no matter what I did.... All the answers out there are regarding command-line on local or servers, not rescue-mode.... Ideas?

CC BY-SA 4.0
4
  • 2
    Try LC_ALL=C which should work everywhere. It effectively disables any Unicode support and various other locale-dependent behaviors but time travel back to the previous millennium is probably acceptable for this particular use case.
    – tripleee
    Commented Mar 9, 2019 at 12:53
  • doesn't work....got the same error bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
    – Jadeye
    Commented Mar 9, 2019 at 13:03
  • Then the cange didn't take. You need to make sure the variable is set and exported in the shell where you run the command. It's not clear from your question whether the error is local or remote, but ssh is unsuallytconfigurel to "transport" your local locale settings to the remote, too.
    – tripleee
    Commented Mar 9, 2019 at 13:49
  • Then issue is with remote as Lish mounts a rescue partition Finnix based and does not have locales installed, hence sending LC_ALL=C via ssh would not help. This fix, coming from linode guide resolves this issue
    – Jadeye
    Commented Mar 9, 2019 at 14:46

5 Answers 5

71

Trial & error with different answers, I came up with this solution (on Lish while server is in rescue-mode):

echo "LC_ALL=en_US.UTF-8" >> /etc/environment
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
echo "LANG=en_US.UTF-8" > /etc/locale.conf
locale-gen en_US.UTF-8

Last command resulted in the following error:

locale-gen: command not found

Here's what you need to do (still on Lish):

apt-get clean && apt-get update
apt-get install locales
locale-gen en_US.UTF-8
Generating locales (this might take a while)...
  en_US.UTF-8... done
Generation complete

You're good to go...copy your server's disk over to your local machine.

CC BY-SA 4.0
4
54

for anyone coming across this post on Debian11 - but should also work on earlier versions - and on similar flavours like Ubuntu. The error indicates that your locales are not generated.

To resolve:

 sudo dpkg-reconfigure locales

Select the desired locales - or all of them. Next you will be asked if you wish to set a default system locale. Select the desired option - for example en_US.UTF-8 and use TAB to go to OK and press enter.

All done.

CC BY-SA 4.0
4
7

To fix the warning follow the following steps:

Open the environment file in the etc folder with your preferred editor.

vi /etc/environment

Press i key to enter edit mode, add the following lines to the file.

LANG=en_US.utf-8
LC_ALL=en_US.utf-8

Pressing Esc key and type :wq to "write/save" the file and exit the editor. Run source /etc/environment

The warning is now fixed and should be gone from the terminal.

CC BY-SA 4.0
0
7

I'm not 100% sure but you could simply be missing the en_US.UTF-8 locale on your local computer, you can try generating it with sudo locale-gen en_US.UTF-8 (on your local computer).

CC BY-SA 4.0
2
  • 3
    This was exactly the case in my chrooted environment. locale -a showed only C and POSIX. I have uncommented en_US.UTF-8 UTF-8 in /etc/locale.gen and run locale-gen. Now locale -a shows en_US.utf8 as well. Thank you for the answer!
    – igor
    Commented Sep 7, 2023 at 20:55
  • 1
    I got this after installing bash_it scripts locally. I tried editing the /etc/environment file first but that didn't work. This was the 2nd thing I tried and it worked for me.
    – Francis
    Commented Feb 19, 2024 at 7:11
4

You probably do not have a package installed. This package may be missing in some Docker containers. At least, this was an issue that I encountered.

glibc-langpack-en
CC BY-SA 4.0
1
  • Amazing, thank you. This was an obscure fix for a nodejs package @pdftron/pdfnet-node, running in the AWS provided Lambda image public.ecr.aws/lambda/nodejs:20. It may be required for other npm packages that are addons.
    – glimmbo
    Commented Apr 8, 2024 at 17:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.