Moving "/usr/bin" directory to other partition without switching off system


 * Possible descriptions of this task:
 * moving "/usr/bin" directory without switching off system
 * moving "/usr/bin" directory while keeping system online
 * moving "/usr/bin" directory system/machine/host online
 * moving "/usr/bin" directory to other file system without switching off system
 * moving "/usr/bin" directory to other file system while keeping system online
 * moving "/usr/bin" directory to other partition without switching off system
 * moving "/usr/bin" directory to other partition while keeping system online

How to do it
mkdir /mnt/partitionfourteen mount -t ext4 /dev/sda14 /mnt/pfourteen cp -R /usr/* /mnt/pfourteen ls -la /mnt/pfourteen
 * Make yourself root user in some way (su or sudo su).
 * Create a new partition with your favourite partition editor. For example use GParted. Or on the command line use fdisk followed by mkfs.ext4
 * Now mount the partition on a temporary spot, the  /mnt directory will do fine for that (or any other empty directory, in this example I'll use /mnt/partitionfourteen). mount [-t TYPE] SOMETHING SOMEWHERE ^__^
 * Use the cp command to copy everything in /usr/ and to the new partition temporarily mounted on in the directory you chose. If you make a mistake here you will be in big trouble later! Don't type /usr instead of /usr/* !
 * Do you really see what you expect to seein /mnt/partitionfourteen? Among other you should see bin, sbin, shared,


 * Next unmount the newly created partition from the temporary mount point /mnt/partitionfourteen.


 * You will mount the newly created partition at /usr


 * Check with cat /proc/mounts whether the partition is really mounted where it should be. Try a few commands like apt-get, firefox, bash, or whatever other command which is in /usr/bin according to which.

THIS STEP IS NOT WORKING, I GET THIS ERROR: mount: /usr: device is busy. (In some cases useful info about processes that use         the device is found by lsof(8) or fuser(1)) pkill X telinit 1 init 1
 * Unmount /dev/sda14 from /usr now, so you can remove everythin in /usr on the /-partition.
 * [No wonder. It is simply not possible to umount /usr when files on /usr are open.] [And the files on the original /-partition which are in /usr there are simply impossible to reach now.]
 * [So the task should be described as: with a minimal down time, not without switching off the system.]
 * Save all your documents. Close the graphical environment if you have that running. And go to runlevel 1.


 * Now the scariest step: AFTER unmounting the new partition you may remove everything in /usr on the /-partition. You should be sure your newly created /usr-partition is NOT MOUNTED.


 * Now try again a few commands like apt-get firefox, gedit, kwrite, kate, bash or whatever command which is in /usr/bin according to which. All commands wil fail.


 * Now use the command mount -a to mount the /etc/fstab you will use from now on.


 * Now try again a few commands like apt-get firefox, gedit, kwrite, kate, bash or whatever command which is in /usr/bin according to which. Hopefully all commands will work! If not you may be in the big trouble mentioned earlier.

What essential commands are in /bin and what essential commands are in /bin/usr
root@Sproet:/home/laudaka# which cp /bin/cp root@Sproet:/home/laudaka# which ls /bin/ls root@Sproet:/home/laudaka# which apt-get /usr/bin/apt-get root@Sproet:/home/laudaka# which mount /bin/mount

Aha so cp and ls are in both in /bin. And mount is in /bin as well, duh!

Some interesting web pages I stumbled upon
moving "/usr/bin" directory without switching off system
 * Using google search:
 * https://fedoraproject.org/wiki/Features/UsrMove Linux directory structure in Fedora (and deviations from FHS) For historic reasons, we split-off more and more tools from /usr and put them in /. ... There is no way to reliably bring up a modern system with an empty /usr, there ... mount /usr before it finally switches the root partition and executes /usr/bin/init. ... the following well-defined directories, which compose the base of the system:.