1

I screwed up my Ubuntu system, so now I need to format and reinstall Ubuntu, but I don't have any USB drives or CD/DVDs

enter image description here

It looks like this now. I only have Ubuntu, so I don't have dualboot of any kind.

I was thinking about creating a new partition from the unused space in /dev/sda2 for my backup stuff and then create another partition to install a bootable Ubuntu on, then I'll boot into that bootable partition and then format and install Ubuntu on /dev/sda2 again.

Is it possible for me to achieve something like this?

Jeggy
  • 3,062

2 Answers2

2

I found a way which requires an rooted Android device.

You need to download this app: DriveDroid - Google Play. And move a Ubuntu iso file to your Android device and use the app to make Android bootable with that iso and then use your computer to boot from it.

enter image description here

I had issues with I couldn't do anything with my /dev/sda2 partition even when booting from Android. So I downloaded GParted live iso and used GParted to shrinken my root partition and make a backup partition, then I used Ubuntu to move my files from my root partition to the new backup partition.

Then set Android to be a Ubuntu bootable again and install ubuntu from there. Then copy my files and used gparted again to make my new ubuntu use the old backup partition.

Jeggy
  • 3,062
1

Based on comments, you must have a wired internet connection to use netboot.

Download the appropriate initrd.gz file and the appropriate linux file for your architecture and distribution from here.

Save them inside /boot. (These files are quite small, under 10MB for either architecture.)

Reboot your computer and enter the grub menu. Now we will get grub to boot from the files you just downloaded.

Press c to get a grub command prompt. Type each of the following lines:

root=(hd0,1)

Replace hd0,1 with the drive and partition on which your /boot is located. You can look at and copy the root line of any existing boot menu entry if you are at all unsure what this is, or you can try tab-completing after root ( or root (hd0,.

Now type

linux /boot/linux

Then

initrd /boot/initrd.gz

Finally type

boot

Your system should now boot into the Ubuntu installer. Follow the instructions from there.

Here is the official documentation for netboot.

Mark Kirby
  • 18,529
  • 19
  • 78
  • 114
  • when you say "appropriate initrd.gz and linux files" what is it? http://archive.ubuntu.com/ubuntu/dists/wily/main/installer-amd64/current/images/netboot/ubuntu-installer/amd64/ I downloaded the initrd.gz from there something else I need to download? – Jeggy Dec 04 '15 at 18:49
  • 1
    The one called linux too. Hopefully my edit addresses this issue for you. – Mark Kirby Dec 04 '15 at 18:50
  • I need internet connection, i only have wifi. How do i connect to wifi in this netboot? – Jeggy Dec 04 '15 at 19:09
  • What do you see ? A terminal or an error ? What ? Documentation just says it will run an installer. – Mark Kirby Dec 04 '15 at 19:21
  • After i have choose keyboard layout it does a configure network with dhcp and fails "network autoconfiguration failed" but i never gave my wifi info. I only have android phone hotspot so i dont any router or ethernet cable connection. I can do a "Configure network manually" but i think thats for manual local ip setup instead of using dhcp(so i cant do it through wifi??) – Jeggy Dec 04 '15 at 19:29
  • If it was possible to shrinken my root partition(dev/sda2) i would be able to use this solution: http://askubuntu.com/a/555901/34385 – Jeggy Dec 04 '15 at 19:34
  • You can't shrink the boot partition if you are using it, don't know what to tell you, usb tether maybe ? without access to a router this can't be done on wifi it seems. There is one more way debootstrap but this is complex, read the without cd section at https://help.ubuntu.com/community/Installation/FromLinux – Mark Kirby Dec 04 '15 at 19:39
  • I'll just give up and go out and buy a usb drive :P – Jeggy Dec 04 '15 at 19:42
  • If you can add to the answer that it cant be done without a ethernet cable, i'll mark your answer as accepted :) – Jeggy Dec 04 '15 at 19:44
  • Looking at debootstrap, I too would wait to buy a USB :) – Mark Kirby Dec 04 '15 at 19:44
  • I found something completly else: https://play.google.com/store/apps/details?id=com.softwarebakery.drivedroid i used this and booted gparted iso, cause ubuntu mounted my root partition so i couldnt shrink it but i can on gparted livecd. I needed an rooted android device and a usb cable :) – Jeggy Dec 04 '15 at 22:16
  • @Jeggy Nice find :) I always thought, an Android phone would have issues being mounted at boot but I guess not. You should write and accept your own answer for this, it is good, useful information. – Mark Kirby Dec 05 '15 at 08:47