2

Edit: Ubuntu version is 20.04 LTS

Sorry for the bad Title, I don't know actually how to say it or what terms to use .

So I broke my ubuntu while just playing around. I was unable to boot.

Then I installed Ubuntu in side of previous Ubuntu by making another partition in my hard drive.

So my main Question is How can I use my newly installed Ubuntu to access files in my previous Ubuntu. When I tried opening that home folder it was showing empty. Because other users don't have permission to access files.

How can I give myself permission to access and edit files.

I can login in my first Ubuntu using CLI.

Please help me

Edit: I have two Ubuntus 20.04 LTS installed in same hard drive in different partition, just like people use windows and linux side by side together.

1 Answers1

5

If you can determine the partition number using lsblk you could mount the drive and directly access it there. Example:

$ lsblk
NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda         259:0    0 476.9G  0 disk 
├─sda1      259:1    0   512M  0 part /boot/efi
└─sda2      259:2    0 476.4G  0 part
└─sda3      259:3    0 476.4G  0 part /
$ udisksctl mount -b /dev/sda2

In this (hypothetical) example, sda2 is a partition that currently is not mounted. It could thus be your system partition of the previous Ubuntu installation. Partitions on internal drives are not automounted, unless they are explicitly configured to be so. This will mount your drive in a folder under /media/<your user name>, so navigating there and clicking the folder where the partition is there will show its contents.

You can also use the the "traditional" mount command, but then you need to be root:

$ sudo mount /dev/sda2 /mnt

This mounts the partition under the /mnt folder.

vanadium
  • 88,010
  • That will not work. Only root can mount by default. – vanadium Oct 03 '21 at 11:23
  • Yeah I can access it now, thanks – adumbProgrammer Oct 03 '21 at 11:25
  • "Then I installed Ubuntu in side of previous Ubuntu by making another partition in my hard drive." This sounds like they have one working distro with root access, you can just modify the above and prepend root to any command needing privilege escalation.

    Log in on second Ubuntu install, elevate privileges, check for drive partition then mount the drive.

    – ned300889 Oct 03 '21 at 11:25
  • @vanadium I am the root on my second partition, I am not a second standard user, its completely different Ubuntu – adumbProgrammer Oct 03 '21 at 11:28
  • You are not root. You are a user with root permissions. root account is not active in a default Ubuntu install. So precede the "mount" command with "sudo" to execute it with root permissions. – vanadium Oct 03 '21 at 11:40
  • @vanadium updated the answer to reflect this, i didn't feel the need to expand the scope of the answer however felt it was best to clarify and update commands to ensure they're quick copy and paste for anyone in the future. – ned300889 Oct 03 '21 at 11:46
  • 1
    There is an option to mount a drive without root - udisksctl mount -b /dev/sda2 should work (and automatically create a mountpoint) cc @vanadium – Zanna Oct 03 '21 at 15:28
  • 1
    @Zanna Thank you! I will add that to the answer! – vanadium Oct 03 '21 at 15:32
  • @ned300889 added some more substantial info on how to "recognize" the lacking partition. If you do not agree, feel free to not accept the edit. – vanadium Oct 03 '21 at 15:44