How to install Ubuntu using a smart phone as the installation media?
A virus has corrupted my desktop's hard drive. How can I remove the remnants of Windows and install Ubuntu on it?
I have only a working mobile phone and one 4GB USB drive. The 4GB drive has vacation photos on it. I have no friends to borrow things from. What to do? Step by step please, any terminal commands should be familiar to a Ubuntu user.
This question is loosely based on Is extracting a ISO file to USB the same method as creating a bootable USB? which was deemed off topic by the DPP.
Solution 1:
Yes, it's possible
Using only an Android phone with internet, root and a USB Cable, you can emulate a flash drive with your Android phone using an app called DriveDroid. However, this is not officially supported and you may be better off asking a local Linux enthusiast (or anyone else who has a working computer) to burn a LiveCD for you.
If you still want to use DriveDroid though, here is a tutorial:
- Open the app and choose the + on the lower bar
- Choose to download an image and to download Ubuntu and go through any additional steps
- Go to the image list and choose the new Ubuntu option
- If asked for emulation mode, choose read-only USB
- Connect phone to PC if you haven't already and boot from the USB (depends on PC manufacturer)
- (optional) When Ubuntu boots, choose to try Ubuntu, mount the Windows partition and move any files you want to rescue to the flash drive (if possible). If the partition is corrupted, look up a way to recover partitions in Linux
- If you chose to skip 6, choose to Install ubuntu and follow the instructions on screen. If you followed 6, open the Install Ubuntu app on desktop and follow instructions on screen Note: While installing Ubuntu, you may want to remove the physical USB (so that you don't accidentally install on it)
- Reboot, unplug your phone when asked to and enjoy!
The app DriveDroid is available on Google Play with searching or this link: https://play.google.com/store/apps/details?id=com.softwarebakery.drivedroid
Solution 2:
*There are a bunch of methods you could use to resolve your issue. You just have to be creative and resourceful enough to pull it off. You also have to do your research. There are plenty of online resources (tutorials) that can walk you through each process. You'll have to know your Linux stuff to get through the rest.
To view your mount points, mount paths, and partitions... Android handles this differently because it doesn't use a GNU OS. It uses a proprietary OS called Android. Google uses the Linux kernel as the base of the OS, but it won't function the way a normal GNU/Linux OS will typically function.*
Your most common operations for listing device information is:
uname - print system information (lets you know your kernel version and os name)
df - report file system disk space usage (df -h prints human readable info)
mount - mount a filesystem (mount on its own will print similar info)
fdisk - manipulate disk partition table (fdisk -l will list local partitions according to the device)
lsblk - view partition information - this was recently added in past years (and is a god send IMHO).
I highly suggest reading some type of book on bash
which is the most commonly used TTY aside from ksh
and sh
. The Linux Documentation Project website can help you out there. This takes some time though and won't immediately help you.
The Unobtrusive Method
If you have a working Ubuntu partition on your machine, boot into Ubuntu, and unmount any partitions related to Windows.
Using lsblk
and mount
can help to determine the drives and partition tables.
Delete those partitions and then create a new filesystem (ext4 is probably a good choice).
Windows is now gone and you have a Linux partition available to you where Windows once was.
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 931.5G 0 disk
├─sda1 8:1 0 450M 0 part
├─sda2 8:2 0 100M 0 part /boot/efi
├─sda3 8:3 0 16M 0 part
├─sda4 8:4 0 466.6G 0 part
├─sda5 8:5 0 456.4G 0 part /
└─sda6 8:6 0 8G 0 part [SWAP]
sdb 8:16 0 1.8T 0 disk
└─sdb1 8:17 0 1.8T 0 part /media/user/somedrive1
sdc 8:32 0 1.8T 0 disk
├─sdc1 8:33 0 931.5G 0 part
└─sdc2 8:34 0 931.5G 0 part /media/user/somedrive2
/
, /boot/efi
, and [SWAP]
are all Linux partitions. Which means that sda1, sda3, and sda4 are my Windows partitions. I can use GParted (a Linux GUI for GNU parted) to modify and edit any required partitions.
Grub will still boot and you'll have to edit the EFI table so that only Linux shows up instead of looking for a missing Windows Boot Loader. I'm sure there are articles on Ask Ubuntu and the Arch Linux Wiki that explain this in greater detail.
The Hacker Method
You're most likely better off going to your local electronics store (or library), downloading the ISO, and dd
it to your USB drive from there. You can create a local running instance of the applications you need so that they execute directly from the USB.
The employees won't understand what you're doing, so don't bother asking them for assistance. Most of the time, I just start doing what I need to do and nobody bothers me or even looks twice. I've actually taught a few employees basic things like how to access msconfig
and how to tell what components are inside of the machine.
Worst case scenario, they can ask you to leave since you're not actually breaking any laws by doing this. If you feel uncomfortable, go as far as asking for permission (never hurts to ask and the worst they can do is say no).
The DIY Method
Assuming you want to MacGyver the hell out of this, the only method I can think of would require an Android phone with a minimum of Android Lollipop OS (5.0), and which is USB OTG compatible (not all mobile devices are).
From there, you can download the Termux app from the Play Store. Once it's downloaded and installed, you can run
apt update
apt upgrade -y
termux-setup-storage
termux-setup-storage
will create a storage directory in your termux home path that will allow you to access your internal SD storage without root access. (Typically, you would need to be root to access anything outside of termux from within the termux environ. The OS apps are typically encapsulated by design.)
Then install anything you need from there to get the job done. This is a rootless app (meaning you do not need to be root).
Download the ISO. Follow the steps you would normally follow and wait. It will take your little mobile device some time. Quite a bit of time actually. It depends on the MicroSD read/write speed.
The Local Method
There is one last method I cant forget to mention and that's Linux Deploy. This is a tricky app to configure and use if you have zero experience with it.
Once it's installed, you can use an app like JuiceSSH for a headless session. If you have a device that's capable of running a GUI, you can always activate it and use it using VNC Viewer.
Linux Deploy, JuiceSSH, and VNC Viewer can be used to locally connect to your running instance. I usually install something lightweight like XFCE, LXDE, or the like. There are enough GUI's to choose from to get what you might like. People typically prefer this setup because it gives them the ability to use Kali Linux OTG.
What's great about this is that any Android version over 2.2.x (I believe, feel free to correct me if I'm wrong) is capable of doing this. It can be very slow on older devices (speaking from experience).
From there, once youre logged in, you can do a lsblk, you should see your USB OTG drive pop up as a /dev/sda device and you can do your thing. This has access to your local partitions and what not as well as having access to all of your normal GNU applications instead of solely relying on busybox, Terminal Emulator, or Termux.
To ssh in to your local install, your address will be localhost:5900
.
Making a bootable USB
You can use lsblk
and if not, use df -h
to list the loaded mount points with human readable output.
If you don't know how to make a bootable USB via the command line, there are some great posts here on Ask Ubuntu. This is my favorite go to:
sudo dd if=/path/to/ubuntu.iso of=/dev/sdX bs=4M && sync
Source