2

Long story short. I accidentally removed my GRUB, and my partition set with mount point '/'. I did remedy this by re-installing Ubuntu from a liveCD (USB), and set the mount point for the new partition (with 2nd version of Ubuntu) as '/', and the Ubuntu installer reinstalled GRUB. (I had tried using boot-repair, from liveCD but it was not working)

My question is: Is it possible for me to remove this old system to get back the used space, and re-assign my original Ubuntu to the mount point '/', without having to copy reformat et cetera?

Reasons why:

  • I do not have a mass storage device which would have the space, to hold everything on this partition (current/1st Ubuntu).

  • No optical drive.

  • Lots of settings, and other things I wish to save

  • Computer was pre-packaged with Ubuntu, making finding drivers un-needed (would rather not have to go through hassle of finding everything, because I know some did not work in liveCD)

LSBLK Below:


lsblk


df -h --total


df


(Edit: For more information) The netbook I have was pre-installed with Ubuntu, so it was not set up in the 'normal' way i.e. my OS was not set up on the same partition as the MBR, and GRUB. There is also a recovery partition which contains the Ubuntu recovery. The boot information was set at / for a mounting point.

sda1 -- FAT32 Partition

sda2 -- FAT32 Partition

sda3 -- 2nd Ubuntu Install root directory ' / '

sda4 -- encrypted swap

sda5 -- 1st Ubuntu Install home directory ' /home '

sda7 -- Other OS (Ubuntu 14.04)

sda8 -- Unused

zram0 and zram1 -- swap partitions for linux


Steps Taken:

  1. From liveCD- opened terminal to clone /sda5 -- sudo dd if /dev/sda5 of=/dev/sda7 conv=notrunc,noerror
  2. From new terminal did watch -n5 'sudo kill -USR1 $(pgredp ^dd) to see progress of dd (this took about 24 hours to finish)
  3. Tried to load from hard-drive. System loaded into grub command line (not bootloader).
  4. Ran liveCD again installed boot-fix, ran through repair.
  5. Default OS is now set to sda5 in GRUB, still have messed up partition mount points.

(Up to step 5 OS was intact)

  1. Formatted sda7.
  2. Resized sda5.

  3. One of these last 2 steps destroyed GRUB, and bootability of partitions (i.e. none of the 3 Ubuntus will load)

  4. liveCD, tried boot-repair 3 times, after 1st "fix" was unable to access GRUB options in advanced options of boot-repair (could not purge/reinstall GRUB)
  5. Mounted sda5, to see if I could get files off, but the disk was unreadable. (Guessing due to resize in step #7)
  6. Wiped everything and re-installed Ubuntu.
  7. Unfortunately I have to redo all my settings, fortunately I do keep backups of important data, but still lost some.
  8. Lesson to myself. Be careful when partitioning.

Although it looked like booting would work with sda3 intact, it seems as if some of the boot information may have been stretched across partitions. Cloning from sda5 to sda7 (with dd) did not work either. (sda7 would not boot after sda5 was cloned over, but probably because of size difference, and cloning needs exact size to duplicate). So i formatted sda7, and expanded sda5. This caused my sda5 information to get messed up. If I only had information (not full system tweaks) the answer below would most likely work.

The biggest problem I had is that when using the liveCD, I had to mount my drives manually (using terminal, mkdir /temporary/folder/ , mount /dev/sdXY/ /temporary/folder), but not always.. sometimes the system automatically mounted, so I would have to dismount, if I wanted to change anything. It was inconsistent.

  • Need more clarity on "accidentally removed my GRUB, and my partition set as '/'". How did you manage to remove GRUB ? What are you trying to say with the second clause? If you chose same root partition for the second install, its less likely that you will get back the old data. By default it formats the root ('/') partition – Jay Aurabind May 2 '14 at 17:26
  • @Jay Aurabind I formatted the partition it was on. 2nd clause: I am able to get into my old partition with my original OS (1st Ubuntu, which was mounted to '/home'). I can boot fine into my OS, but I want to get rid of the 2nd install, and am not sure if GRUB will go away (not sure where it is). I know it is at byte 392 in MBR on /dev/sda/, and my 1st Ubuntu is at dev/sda5, with /dev/sda3/ being my "root" ('/') mounting point. – No Time May 2 '14 at 17:41
  • Can you post the output of lsblk so we can see what your partition layout is? – Nattgew May 2 '14 at 18:10
  • @Nattgew Added lsblk into post. /sda7/ is the 2nd Ubuntu. – No Time May 2 '14 at 18:24
  • I'm not sure what you are wanting to do, could you explain based on what is shown from the lsblk output? – Nattgew May 2 '14 at 19:22
2

The easiest way will probably be to just move everything to /dev/sda3 since moving your / partition can be tricky (special files, grub, and stuff, see here)

You will need to boot from USB to use gparted to edit the partitions.

  1. Move all the files you need from /dev/sda5 to /dev/sda7, delete /dev/sda5
  2. You should be able to move /dev/sda4 and expand /dev/sda3 into the free space
  3. You can then copy the files you moved to /dev/sda7 to /dev/sda3
  4. Then you can delete /dev/sda7, move /dev/sda4 again, and finally expand /dev/sda3 to fill the space

You will also want to edit the /etc/fstab to remove the reference to /home on /dev/sda5

Since / remains on the same partition, hopefully grub will still boot fine. If not, you should be able to run Boot Repair to fix it.

FYI: grub is installed on the MBR of the drive (which doesn't show up on lsblk or df), and the information about partitions and all is stored in /boot, which in your case will be in the / directory (on /dev/sda3)

  • Updated a little. I needed to keep settings to my current Ubuntu, so I couldn't just copy the files. I am working getting everything to work correctly still. (Keeping a log) – No Time May 3 '14 at 15:41

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.