10

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.

12
  • 2
    What is the cell phone? What brand, OS, etc. It might be (without other resources) impossible. Jun 14, 2017 at 17:31
  • 2
    Does the phone have root access? Does it have internet? Jun 14, 2017 at 17:45
  • 2
    Also, do you have a USB OTG or/and a normal PC-Phone cable? Jun 14, 2017 at 17:48
  • 2
    I don't think you can use a smartphone to create bootable USB drives unless you have root access, in which case that part of your question would be better suited for Android Enthusiasts. This question is at its core a duplicate of Is extracting a ISO file to USB the same method as creating a bootable USB? despite your efforts to make it on topic. Jun 14, 2017 at 19:08
  • 2
    How so different than asking how to use Windows or OSX to make a Ubuntu boot device? If we are not allowed to discuss using other OS's to install Ubuntu how will anyone install Ubuntu? I'm pretty sure Microsoft is not going to tell me how to install Ubuntu. Jun 14, 2017 at 19:48

2 Answers 2

7

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:

  1. Open the app and choose the + on the lower bar
  2. Choose to download an image and to download Ubuntu and go through any additional steps
  3. Go to the image list and choose the new Ubuntu option
  4. If asked for emulation mode, choose read-only USB
  5. Connect phone to PC if you haven't already and boot from the USB (depends on PC manufacturer)
  6. (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
  7. 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)
  8. 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

9
  • It should be rather easy to follow this tutorial :-) Maybe the most difficult part is the prerequisite to root the phone :-P
    – sudodus
    Jun 15, 2017 at 7:33
  • @sudodus True... however, the asker said (in comments on the question) that the solution may include having a rooted phone. Jun 15, 2017 at 7:36
  • Yes, that's part of the deal.
    – sudodus
    Jun 15, 2017 at 12:14
  • I managed to root the phone last night using KingoRoot. There is a version for Windows and an Android version that runs right off the phone. Very quick and simple. Jun 15, 2017 at 15:12
  • I was expecting an answer a little more complicated than jargonjunkies, like maybe getting Sudodus to port mkusb to Android. I can not dispute that you fully answered my question. DriveDroid sounds too good to be true, I tried it, it's true, it's amazing. And I even get to save my vacation photos. I love the way a thread can go from being impossible to green dot so quickly. Jun 15, 2017 at 17:01
5

*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

16
  • Interesting :-) 1) Have you used the Termux app yourself? 2) Will Termux help with dd too, or do you need sudo (root permissions) for the command line with dd?
    – sudodus
    Jun 14, 2017 at 19:34
  • 1
    @C.S.Cameron JackPal is the dev. Terminal Emulator for Android is his app.
    – wjandrea
    Jun 14, 2017 at 20:13
  • 1
    I know, I'm often warning people to be very careful (or avoid) dd, nicknamed 'disk destroyer' or 'data destroyer' :-P
    – sudodus
    Jun 14, 2017 at 20:36
  • 2
    Sudodus: A page on burning Raspberry uSD's from Android, ( raspberrypi.org/forums/viewtopic.php?f=91&t=12098 ), uses: dd if=filenameof.img of=mmcblkX Jun 14, 2017 at 21:02
  • 1
    i've been looking for the tutorial i used for linux deploy and no luck. i did find this guide though: arachnoid.com/android/LinuxOnAndroid
    – user383919
    Jun 14, 2017 at 21:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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