How can I switch a 32-bit installation to a 64-bit one?
I’ve got a 32-bit Ubuntu installation running on 64-bit hardware. Now that multi-arch has been implemented, I would like to switch to 64-bit without having to reinstall the OS. This is one of the user stories addressed by the spec: Shawn installed his system using the 32-bit version of Ubuntu, but his hardware is 64-bit and he wants to switch over. He manually installs the amd64 versions of dpkg and apt, replacing the i386 versions and changing which architecture is used as the default; then he installs the amd64 ubuntu-minimal package; then he installs the amd64 ubuntu-desktop package. Over time the remaining i386 packages are replaced automatically on upgrade. However, when trying to follow the instructions in there, I cannot find any 64-bit version of dpkg or apt. Did this user story got implemented in a different way in the final spec, or do I need to do something differently? In short, how can I switch my 32-bit installation to 64-bit?
I realise the question has already been asked on askubuntu.com/questions/5018/…, but that was before multi-arch was implemented, so the answer should be different.
12 Answers 12
Such an approach is very complicated, and is unlikely to ever result in all your packages being the amd64 version instead of the i386 version. Only packages that actually receive upgrades will likely be changed in architecture, and probably only if no other packages not being upgraded rely on their being of the i386 architecture. Since some packages will not receive any updates throughout the entire support cycle of your Ubuntu release, you will likely never have a fully amd64 system using such a technique. Furthermore, there is certainly no official support for such an approach.
You would be well-advised to instead replace your existing Ubuntu system with a new, 64-bit installation.
However, if you do wish to attempt this technique, you will have to manually download the .deb files for dpkg and apt . You can find them at the dpkg in Ubuntu and apt in Ubuntu pages on Launchpad—expand the latest version under «The Oneiric Ocelot» that is marked as release, security, and/or updates (but you probably don’t want a version marked only proposed and/or backports, if there ever is one). Then download the .deb files marked amd64 . Specifically, the files you’ll want are: this one for dpkg (and the others listed, too, if you have those packages installed) and this and this and this and this and this for apt .
Before you do anything with these files, you should make sure to back up all important documents in your installed Ubuntu system and any other important files (e.g., music, ebooks, videos), because it is rather likely that attempting this technique will backfire badly and leave your Ubuntu system completely unusable.
You can install all these packages by putting them in a folder that contains nothing else (suppose the folder is called debs and is inside your Downloads directory), and then running this command:
sudo dpkg -Ri ~/Downloads/debs
Of course, once you’ve installed them, they won’t actually run, because their executables are 64-bit and your 32-bit Ubuntu system is running a 32-bit kernel (which will only run 32-bit executables). In fact, they might not even finish installing, as they might have post-install scripts that invoke their unrunnable 64-bit executables.
There are various ways of attempting to install a 64-bit kernel onto a 32-bit system, but they are all extremely complicated, so instead I recommend that you boot from a 64-bit Oneiric live CD (which itself runs a 64-bit kernel), chroot into the installed Ubuntu system, and use the recently installed 64-bit apt and dpkg to install a 64-bit kernel.
Here are specific instructions for doing that. but please do not take this to mean that I’m saying it will work. I have not attempted this. (I have chrooted into installed Ubuntu systems from live CD’s and performed package management and other operations, but I have not attempted the cross-architecture operations suggested here.)
- In your installed Ubuntu system, open a Terminal window ( Ctrl + Alt + T ) and run mount | grep ‘ on / ‘ (by pasting it into the Terminal and pressing enter). You should see something like /dev/sda2 on / type ext4 (rw,errors=remount-ro,commit=0) . The part you’re interested is the device name before on (in this example, it’s /dev/sda2 ). Remember that, or write it down.
- Step 1 gave you the device name of the / partition. If you have a separate /boot partition, then you’ll need to know the device name for that as well. So in that case, run mount | grep ‘ on /boot ‘ . You’ll see something like /dev/sda1 on /boot type ext2 (rw) . Remember or write this down as well.
- Boot from an Oneiric amd64 (i.e., 64-bit) live CD and select «Try Ubuntu» rather than «Install Ubuntu».
- Go into a web browser and make sure that Internet connectivity is fully functional. If it isn’t, set it up.
- Open a Terminal window and run sudo mount /dev/sda2 /mnt (replace /dev/sda2 with the device name you got in step 1, if different).
- If your installed system has a separate /boot partition, run sudo mount /dev/sda1 /mnt/boot (replace /dev/sda1 with the device name you got in step 2, if different).
- Now, run these commands to chroot into your installed system:
sudo mount --bind /dev /mnt/dev sudo chroot /mnt mount -t proc none /proc mount -t sysfs none /sys mount -t devpts none /dev/pts
PING launchpad.net (91.189.89.223) 56(84) bytes of data. 64 bytes from launchpad-net.banana.canonical.com (91.189.89.223): icmp_req=1 ttl=41 time=141 ms 64 bytes from launchpad-net.banana.canonical.com (91.189.89.223): icmp_req=2 ttl=41 time=143 ms 64 bytes from launchpad-net.banana.canonical.com (91.189.89.223): icmp_req=3 ttl=41 time=142 ms 64 bytes from launchpad-net.banana.canonical.com (91.189.89.223): icmp_req=4 ttl=41 time=140 ms --- launchpad.net ping statistics --- 4 packets transmitted, 4 received, 0% packet loss, time 3003ms
sudo cp /mnt/etc/resolv.conf /mnt/etc/resolv.conf.old sudo cp /mnt/etc/hosts /mnt/etc/hosts.old sudo cp /etc/resolv.conf /mnt/etc/resolv.conf sudo cp /etc/hosts /mnt/etc/hosts
While generally you should stop this process if there is an error, don’t worry if the first and/or second of those four commands fail, provided that the specific way in which it fails is by telling you that /mnt/etc/resolv.conf (or /mnt/etc/hosts ) does not exist. The chroot back in and try again:
sudo chroot /mnt ping -c 4 launchpad.net
export HOME=/root export LC_ALL=C
update-grub umount /proc || umount -lf /proc umount /sys umount /dev/pts exit sudo umount mnt/dev
There might well be additional packages you need to install, such as ia32_libs and/or the 64-bit version of libc6 , for this to work. For some of them, you might be informed you need them when attempting to install the 64-bit version of dpkg and/or apt . For others, you might not be informed.
(The above instructions for chrooting and operating in the chrooted environment are based in significant part on this related but different procedure and also on some Launchpad Answers posts of mine, especially #6 here and #6 here. And special thanks to Caesium for pointing out that the 64-bit dpkg and apt executables won’t run on a system running a 32-bit kernel.)
Run 64-bit app on 32-bit Ubuntu system
All the questions I’ve seen refer to running a 32-bit app in a 64-bit system. I’m running 32-bit Ubuntu 12.04 (actually elementary OS Luna, which is based on it) and I’m trying to run a 64-bit app which refuses open. Running:
bash: ./64bit_app.run: no se puede ejecutar el fichero binario
which translates to «can’t execute/run/open binary file«. Should I be able to run it? Is it possible to run a 64-bit app in a 32-bit system? If so, how?
I have not tried this but have you attempted the solutions shown here, esoecially the answer explaining dpkg —add-architecture ? As far as I know, the same approach should work for 32 on 64 and for 64 on 32. Just change dpkg —add-architecture i386 to dpkg —add-architecture amd64 .
Please read the answers to the question I linked to, you need to run sudo dpkg —add-architecture amd64 first. That’s a separate command.
@terdon sorry, I did not understand that. Running that line results in: dpkg: error: opción —add-architecture desconocida where desconocida translates to unknown .
3 Answers 3
You can’t do that directly on Linux on x86_64 with a 32bit kernel. You need a 64bit kernel to be able to run 64bit code. (Note: kernel. You can have 32bit userland running on a 64bit kernel, and install support for 64bit binaries. How easy this is depends on the distribution. Example here for Debian.)
Some virtualization software is able to do that (with restrictions on the type of CPU you’re using), and emulators can do that too. But to run it natively you’ll need a 64bit kernel.
Since most 64bit distributions out there have 32bit support (either by default or installable), that’s what you should be using if you need to run both 64bit and 32bit binaries on the same OS.
Yes, some virtualization software can do it. The main obstacle to handle is that in a 32-bit environment, the 64-bit features of the CPU are not available, and also the features of a 64-bit kernel isn’t available. It is even so if your CPU has 64-bit support (since around 2003, all of them have).
Your question implicitly states that you want to run the 64-bit app in your own system environment. If it is really your intention, this excludes all virtual machine-based solutions. The only remaining which is known for me is the kernel-emulation of the qemu. So:
qemu-x86_64 ./your_64bit_app
It runs your app on your current system, with your current kernel, with your current environment variables. Of course it is not very fast, it has to emulate your cpu.
It can emulate only linux x86-64 apps.
Somewhere I’ve also read, as if also vmware could do that, but this is not enough sure info for an answer. Afaik recent vmware are 64bit-only on the host side.
Most 64-bit architectures are extensions to the 32-bit ones. They’re newer and completely different so obviously a 32-bit architecture has no idea what the 64-bit counterpart is. They don’t know what the new features are, what new registers there are. Even if they know, they have no access to the new registers and features. As a result a 32-bit kernel can’t save 64-bit contexts. All of that makes running 64-bit apps on a 32-bit system impossible.
A carefully crafted 64-bit-aware 32-bit kernel can run 64-bit apps but it still needs some 64-bit code to do the context savings, which makes it not a pure 32-bit kernel anymore.
You can run a 64-bit OS inside an emulator, or a 64-bit guest virtual machine inside 32-bit host with VT-x. But technically you’re running in a different 64-bit system. It’s still not possible to run 64-bit code directly on 32-bit Linux kernel
You must log in to answer this question.
Linked
Related
Hot Network Questions
Subscribe to RSS
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.
Site design / logo © 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2023.7.14.43533
Linux is a registered trademark of Linus Torvalds. UNIX is a registered trademark of The Open Group.
This site is not affiliated with Linus Torvalds or The Open Group in any way.
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.