1

I tried to transfer /usr to a different drive using various methods but none seem to be working with Ubuntu (18.04.3 LTS).

What I'm trying to do is move some of the system directories that are on HDD to an SSD drive (PCI Express so connect with NVME driver). The system was installed on HDD and I don't really want to reinstall it...

Edit: Important! The problem only occurs for /usr dir. I also did exactly the same for /var dir and everything works fine.

I tried doing this from Rescue CD like so:

# mount root (hdd, source)
mkdir /mnt/root
mount /dev/sda2 /mnt/root
# mount faster drive (ssd, destination)
mkdir /mnt/ssd500pci
mount /dev/nvme0n1p1 /mnt/ssd500pci

# move old
mv /mnt/root/usr /mnt/root/usr.old

# copy to new location
rsync -aH --info=progress2 /mnt/root/usr.old/ /mnt/ssd500pci/usr

# create mount point
mkdir -p /mnt/root/usr

Then in fstab I have something like this:

UUID=abcdef-1 / ext4 defaults,noatime 0 0
UUID=abcdef-2 /boot/efi vfat defaults 0 0

# my ssd
UUID=abcdef-3 /mnt/ssd500pci ext4 defaults,noatime 0 0

# swap
/mnt/ssd500pci/swap.img none swap sw 0 0

# bindings
/mnt/ssd500pci/usr /usr none bind 0 0

And after reboot I get a message that makes no sense to me: "Unexpected reschedule of offline CPU#7" (see photo).

Note that when I move usr.old back to usr (and remove binding in fstab) then everything works fine.

Ubuntu panic: Unexpected reschedule of offline CPU#7

PS: At first I actually tried doing this on a working system (which was supposed to work according to this answer: https://serverfault.com/a/597780/62024). The result was basically the same.

Also note that on each attempt I remove /mnt/ssd500pci/usr and try to copy again (to make sure there are no problem with hard links or stale files).

Nux
  • 81
  • 9
  • One point is not clear: Does the system refuse to boot after the change or is it only the message which gives you the headache? – mook765 Aug 22 '19 at 19:47
  • It shows the stack and won't continue. Have to boot to RescueCD to fix it. – Nux Aug 22 '19 at 22:16
  • This might lead you to the solution. – mook765 Aug 22 '19 at 23:39
  • That didn't help unfortunately. But thanks :-). Seems like /usr/lib is required at boot (which seems like a Ubuntu bug to me). If I keep /usr/lib folder then everything works even if I actually mount a usr lib over it. Go figure... – Nux Aug 23 '19 at 17:22
  • One difference to the normal procedure is that you don't use a seperate partition dedicated only for the contents of /usr, maybe this makes a difference. At least I can confirm that on my system I have the same result when using your method with the bind-mount, system refuses to boot. I'm on 18.04.3 with 5.0.0-25 kernel. – mook765 Aug 23 '19 at 17:30
  • I also tried with a soft link (ln -s /mnt/ssd500pci/usr/lib lib) but that didn't help either. – Nux Aug 23 '19 at 17:34

1 Answers1

0

I had same situation about Ubuntu 20.04 LTS does not boot because I had changed the /usr directory but it was from SDD to HDD instead your situation, I got the same problem while boot it though.

My scenario was moving /usr from / to other partition, such as /home partition in HDD. Unfortunately, many forums that I had searched about "how to move your directory" did not solve my problem: most of their methods give partition mount fail or kernel fatal error.

The one or two of good answers was in this question and this question but as I said they did not solve to me.

Symbolic link does not work in Boot, it will fail if the directory is symbolic.

Possible Explanation

I don't have a precise answer as to why this happens, but I do have some deductions that make the OS not turn on:

  • It is "Status Quo". You can not boot without /usr. Booting without /usr is Broken and LinuxQuestion
  • /usr contains the majority of user utilities and applications but it has some folders that are important to "follow" the booting, such as /usr/sbin and /usr/lib. If you move /usr it will occur error in kernel...
  • The initrd might be one of the reasons that cause errors, and maybe it should be changed too or not. Comment in this question

I'm open to better explanations and corrections, but that's what I was able to deduce after many days of testing and solving this problem.

Possible Solution

Two solutions I found but I selected the second:

  1. You can even try the solutions exposed on this page Booting without /usr is Broken which explains the "Status Quo" argument.

  2. Make new partitions, install your Ubuntu and select directories for each desired partition by using a Bootable USB.

Yes, you didn't want to reinstall your OS, but that's what I found after so much headache and wasted hours.

  1. Make backup your files.
  2. Make sure you have space to make new partitions and then create your desired partitions.
  3. Have a Bootable USB with Ubuntu.
  4. Re-install your Ubuntu.
  5. While you install Ubuntu, you will be in the Installation Type step and select Something elseoption.
  6. Next step is what we want, you can define which partitions will load the /usr, /opt or /var directories. You can also change partition settings on selection.*
  7. Proceed the installation.

*I'm not sure if it's possible to install Ubuntu without having to format the specific partitions to keep files saved, such as the /home partition. I also don't know if not formatting the specific partition can cause problems in the future. In my case, I formatted all my desired partitions.

Of course it took a while, but I hope it's resolved and this can help you and others.