Ubuntu: Slow boot or no boot at all - how did i mess up my ubuntu installation this time?

Question:

UPDATE 2018-03-23

So, i finally identified the problem. Its all about mounting NTFS paritions on startup on a dual boot setup. So if you want to share data between windows and linux, you might want to use FAT32 over NTFS. It seems windows sometimes unmounts the filesystem in a way, that causes linux to have troubles mounting it again. To fix the boot-problem, you can go into emergency console and type

ntfsfix /dev/sdXX

where sdXX is the identifier of the ntfs partition. You can look that up in your /etc/fstab or by typing df. After runnung ntfsfix you are able to login by exiting the emergency console (simply type exit)

ORIGINAL POST

I recently decided to upgrade my pc and re-install ubuntu as well as windows. I must have made some terrible mistake because booting into ubuntu is working only every second attempt.

When the boot fails a emergency terminal will show up. I exported the log with the suggested journalctl -xb and uploaded the output for you (see link below)

The mainboard has no boot-from-pcie support, so i could not install windows or ubuntu directly to the NVME drive. I figured it might be okay to simply install the bootloader to the SSD (/dev/sda), place the /boot mount on a primary partition on the ssd too (/dev/sda3) and mount everything else onto the nvme.

To avoid configuring grub i decided to first install windows 10 and then install ubuntu, so ubuntu will automatically write grub into the MBR of /dev/sda. That allways worked perfectly...

Additionally i created a ntfs-3g mount for the ssd to share data between my operating systems. I created only one ext4 partition on the hdd and mounted it on some user-folder (within /media)

What i tried so far

At first i noticed that i had no sound. Because i bought the mainboard second-hand i assumed the ac97 chip is broken and bought a second-hand soundcard (see above). I thought that might caused the boot-troubles, but that wasnt the case. I do have sound now but still the boot problems.

Then i read something about UUID issues in /etc/fstab because of multiple installation attempts and i checked all uuids and they were same as in /etc/fstab.

Then i read something about a wrongly mounted swap partition, so i ummounted, swapoff and swapon the partition on /dev/nvme0n1p6. No success.

Then i found some post, that it might be better to remove the uuids from /etc/fstab and simply insert the partitions directly. So i did - no success.

Like always lightdm made lots of problems, so i installed gdm instead.

After copying all files to /var i checked if the structure seems the same by running a few commands.

checking by folder-size

du -hs /var vs. du -hs /media/var

checking by number of symbolic links

find /var -type l | wc -l vs. find /media/var -type l | wc -l

I made several attempts, cp always fucked up something, either the permissions were wrong and services started to block the boot or links were created where none had been in the source. Dont ask me why - as i understand cp -a it should work perfectly - but it didnt. rsync -a did though

important: dont forget the trailing slash in the rsync command

UPDATE

So NOW it becomes more clear. After configuring my /dev/sda5 to directly mount /var/www instead of /var (for historical reasons i am used to host my web-projects in that location) the boot was not successful again. So i assumed it has to be apache that blocks my boot.

My solution for this

boot into recoverymode

run mount -a -orw,remount to have read/write access to the file system

run systemctl disable apache2.service to prevent apache from starting automatically on boot

And now it works again.

For some reason it seems apache is loading BEFORE all disks have been mounted. So this could be some NASTY bug in systemd.

I am going to reboot 5 times now to be sure :-)

UPDATE 2

OKAY - it seems more than 1 problem affected me at once

I finally (at least for the moment lookingfrustrated) got my setup working by:

moving all optional mounts (except /, /boot and swap) from /etc/fstab to manual mount in /etc/rc.local

running ntfsfix before mounting the partition that is mounted in both - windows and linux

So in detail:

Ubuntu seems to mount all drives parallel and not one-by-one, thats the reason for the random nature of this problem.

When windows shuts down it may not leave a "clean" filesystem behind because of some internal windows thing.