25

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?

Jadeye
  • 3,551
  • 4
  • 47
  • 63
  • 1
    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 Mar 09 '19 at 12:53
  • doesn't work....got the same error `bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)` – Jadeye Mar 09 '19 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 Mar 09 '19 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 Mar 09 '19 at 14:46

5 Answers5

40

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.

Jadeye
  • 3,551
  • 4
  • 47
  • 63
24

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.

S.D.
  • 2,486
  • 1
  • 16
  • 23
5

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.

Ajeet Shah
  • 18,551
  • 8
  • 57
  • 87
user15925208
  • 69
  • 1
  • 1
0

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
t7e
  • 322
  • 1
  • 3
  • 9
0

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).

CreeLoPer27
  • 63
  • 1
  • 6