3

I suspect I have multiple Ubuntu installations on different partitions on my PC. But how do I find out about them? Which command to use?

Output of

 sudo lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL

is

NAME   FSTYPE   SIZE MOUNTPOINT            LABEL
sda           931.5G                       
├─sda1 ext4     660G /home/sda1_mountpoint 709G
├─sda2            1K                       
├─sda5 swap     7.7G [SWAP]                
├─sda6 vfat   123.4G /data124G             132G
├─sda7 ext4    74.3G /data73G              80G
└─sda8 ext4    66.1G /                     
sdb    ext4   931.5G                       
└─sdb1 ext4   931.5G /data1T               data1T
sr0            1024M

and Output of

sudo parted -l

is

Model: ATA TOSHIBA DT01ACA1 (scsi)
Disk /dev/sda: 1000GB
Sector size (logical/physical): 512B/4096B
Partition Table: msdos
Disk Flags: 

Number  Start   End     Size    Type      File system     Flags
 1      32.3kB  709GB   709GB   primary   ext4
 2      709GB   1000GB  291GB   extended
 7      709GB   788GB   79.7GB  logical   ext4
 6      788GB   921GB   132GB   logical   fat32
 8      921GB   992GB   71.0GB  logical   ext4
 5      992GB   1000GB  8266MB  logical   linux-swap(v1)


Model: ATA ST1000DM003-1ER1 (scsi)
Disk /dev/sdb: 1000GB
Sector size (logical/physical): 512B/4096B
Partition Table: msdos
Disk Flags: 

Number  Start   End     Size    Type     File system  Flags
 1      1049kB  1000GB  1000GB  primary  ext4

Background info - Some problem occurred when PC was not restarting. It was stuck in login loop and similar error to this was occuring. I did ctrl-alt-f1 . I found that user's home directory was missing i.e/ /home/ was empty! I did mkdir /home/user and copied an old backuped home directory there and restarted. It started fine. Later I mounted sda1 at /home/sda1_mountpoint. It gave missing superblock error. I had to do fsck, then it mounted. the missing home directory was found in sda1 .

So I think problem is with multiple installations. Also notice that none of the output of lsblk is /home.

EDIT After reading comments, I mounted sda1 to /home instead of /home/sda1_mountpoint

Output of etc/fstab is

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sda8 during installation
UUID=10138724-bb55-4d41-b8f8-81fc42ec1a84 /               ext4    errors=remount-ro 0       1
# swap was on /dev/sda5 during installation
UUID=7d10a86a-3139-45af-bfc5-3dbb26a3e767 none            swap    sw              0       0
# sda1
UUID=b50f72de-3b8b-4453-a743-cc37f06055a5 /home           ext4   defaults    0    2 
# sda6
UUID=DBA5-EDA5 /data124G                                    vfat   defaults 0 0  
# sda7
UUID=01e6d118-230d-4f22-a528-3e7ff06aef39 /data73G          ext4 defaults 0 0
# sdb1
UUID=a92ea8c4-c810-4c06-8586-285bed30ea3f /data1T          ext4 defaults 0 0 

Output of mount command is

sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
udev on /dev type devtmpfs (rw,nosuid,relatime,size=12301796k,nr_inodes=3075449,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=2464372k,mode=755)
/dev/sda8 on / type ext4 (rw,relatime,errors=remount-ro,data=ordered)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,mode=755)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd)
pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)
cgroup on /sys/fs/cgroup/net_cls,net_prio type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls,net_prio)
cgroup on /sys/fs/cgroup/pids type cgroup (rw,nosuid,nodev,noexec,relatime,pids)
cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
cgroup on /sys/fs/cgroup/hugetlb type cgroup (rw,nosuid,nodev,noexec,relatime,hugetlb)
cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpu,cpuacct)
cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=26,pgrp=1,timeout=0,minproto=5,maxproto=5,direct)
mqueue on /dev/mqueue type mqueue (rw,relatime)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime)
fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)
tracefs on /sys/kernel/debug/tracing type tracefs (rw,relatime)
/dev/sdb1 on /data1T type ext4 (rw,relatime,data=ordered)
/dev/sda6 on /data124G type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)
/dev/sda7 on /data73G type ext4 (rw,relatime,data=ordered)
/dev/sda1 on /home type ext4 (rw,relatime,data=ordered)
tmpfs on /run/user/108 type tmpfs (rw,nosuid,nodev,relatime,size=2464372k,mode=700,uid=108,gid=114)
gvfsd-fuse on /run/user/108/gvfs type fuse.gvfsd-fuse (rw,nosuid,nodev,relatime,user_id=108,group_id=114)
tmpfs on /run/user/1000 type tmpfs (rw,nosuid,nodev,relatime,size=2464372k,mode=700,uid=1000,gid=1000)
Melebius
  • 11,431
  • 9
  • 52
  • 78
user13107
  • 778
  • I would try to search for some basic files like fstab (normally located in /etc) whether they appear twice (or more): find / -name fstab 2> /dev/null – Melebius Apr 25 '18 at 06:29
  • @Melebius sudo find / -type f -name fstab outputs /lib/init/fstab; /usr/share/doc/mount/examples/fstab; /usr/share/doc/util-linux/examples/fstab; /etc/fstab – user13107 Apr 25 '18 at 06:32
  • Same result here. That’s why I haven’t posted my advice as an answer, I hadn’t checked it before. However, this suggests the OS is installed only once in your case, too. What makes you think there are multiple instances? – Melebius Apr 25 '18 at 06:36
  • @Melebius some problem occurred when PC was not restarting. I did ctrl-alt-f1 . I found that user's home directory was missing. I did mkdir /home/user and copied an old backuped home directory there and restarted. Later I mounted sda1 at /home/sda1_mountpoint. It gave missing superblock error. I had to do fsck, then it mounted. the missing home directory was found in sda1 .

    So I think problem is with multiple installations. Also notice that none of the output of lsblk is /home. What is your output of lsblk?

    – user13107 Apr 25 '18 at 06:40
  • IMHO posting my lsblk would be useless, I have much different partition setup. I am still not understanding where could the other installation come from. Have you created another /home partition? Well, that’s not another OS installation, just another copy of user data. “notice that none of the output of lsblk is /home You don’t need a separate home partition, I don’t have one, too. – Melebius Apr 25 '18 at 07:03
  • @Melebius you may be right. Note that my sda8 is mounted on /. Does that mean /home/user should be kept inside sda8? I am very confused by my partitions. I think my old /home/user was in sda1 which is why when sda1 was not mounted the users home directory was missing. – user13107 Apr 25 '18 at 07:08
  • Yes, if you created it using mkdir inside the root partition, which is sda8 in your case. You should also post the output of plain mount command (without parameters) and the contents of the file /etc/fstab. – Melebius Apr 25 '18 at 07:46
  • @Melebius Thanks. I added output of these two files/commands in OP – user13107 Apr 25 '18 at 07:57

1 Answers1

4

There is no sign that you have two Ubuntu installations on your hard drive. If there were multiple Linux installation and you had all meaningful partitions mounted (as you indeed have according to the lsblk output), you would get duplicate results if you tried to find essential system files like shadow (normally located in /etc/).

find / -type f -name shadow 2> /dev/null

Restoring the original /home contents

The only thing you may have duplicated is the home folder:

I found that user's home directory was missing i.e/ /home/ was empty! I did mkdir /home/user and copied an old backuped home directory there and restarted.

However, you seem to have discovered the correct solution already:

Later I mounted sda1 at /home/sda1_mountpoint. It gave missing superblock error. I had to do fsck, then it mounted. the missing home directory was found in sda1.

Since the mount is still present in your /etc/fstab,

# sda1
UUID=b50f72de-3b8b-4453-a743-cc37f06055a5 /home           ext4   defaults    0    2

it should mount automatically on next reboot. If not, the UUID has probably changed, so you should update it in this file. You can get the current UUID using blkid:

sudo blkid /dev/sda1

Removing the duplicated /home contents

The only remaining task is to get rid of the duplicate home folder contents. The contents of /home on the root partition are still present on the disk, although it’s overlaid using mount. This is not necessary but the data are still occupying your disk space… To access them, mount the original contents elsewhere, e.g. to /mnt:

sudo mount --bind /home /mnt

Then open the /mnt directory, you should see the contents of your temporary /home there. Delete or move them and unmount it:

sudo umount /mnt

References

Melebius
  • 11,431
  • 9
  • 52
  • 78