Skip to main content
added 415 characters in body
Source Link
cas
  • 84.7k
  • 9
  • 138
  • 206

Here's one way of doing it:

As root, while no other users are logged in, no user processes are running, and user cron jobs and systemd timers (if any) are disabled (in short, when there's no chance of user files/dirs being modified while the mv operation is in progress):

mkdir /home.new shopt -s dotglob nullglob # make sure dot files match the /home/* glob mv /home/* /home.new/ umount /home rmdir /home mv /home.new /home 

(you can use mv -v if you want verbose output so you have something to watch while the files are being moved - but note that verbose output will cause the move to be significantly slower).

Then modify /etc/fstab so that it doesn't mount the old home partition. You can do that manually with your favourite text editor, or with a program like sed, e.g.:

sed -i 's/^UUID=6397f416-fe69-4a90-9336-7497d42df184/#&/' /etc/fstab 

Note: a safer alternative would be to use rsync to copy all the files from /home to /home.new rather than mv them. That eliminates the risk of losing any files if something unfortunate happens (e.g. sudden crash or power loss). Then either delete all files in the old /home or reformat the partition after everything has been copied.

Using rsync also reduces, if not eliminates, the risk of problems caused by user files/dirs being modified during the procedure, as you can re-run the rsync command as many times as you like and only new/modified files will be synced. Do the initial rsync at any time, and then do a final rsync when nobody else is logged in. The final rsync will be very fast, so that will minimise downtime for users.

Here's one way of doing it:

As root, while no other users are logged in, no user processes are running, and user cron jobs and systemd timers (if any) are disabled (in short, when there's no chance of user files/dirs being modified while the mv operation is in progress):

mkdir /home.new shopt -s dotglob nullglob # make sure dot files match the /home/* glob mv /home/* /home.new/ umount /home rmdir /home mv /home.new /home 

(you can use mv -v if you want verbose output so you have something to watch while the files are being moved - but note that verbose output will cause the move to be significantly slower).

Then modify /etc/fstab so that it doesn't mount the old home partition. You can do that manually with your favourite text editor, or with a program like sed, e.g.:

sed -i 's/^UUID=6397f416-fe69-4a90-9336-7497d42df184/#&/' /etc/fstab 

Note: a safer alternative would be to use rsync to copy all the files from /home to /home.new rather than mv them. That eliminates the risk of losing any files if something unfortunate happens (e.g. sudden crash or power loss). Then either delete all files in the old /home or reformat the partition after everything has been copied.

Here's one way of doing it:

As root, while no other users are logged in, no user processes are running, and user cron jobs and systemd timers (if any) are disabled (in short, when there's no chance of user files/dirs being modified while the mv operation is in progress):

mkdir /home.new shopt -s dotglob nullglob # make sure dot files match the /home/* glob mv /home/* /home.new/ umount /home rmdir /home mv /home.new /home 

(you can use mv -v if you want verbose output so you have something to watch while the files are being moved - but note that verbose output will cause the move to be significantly slower).

Then modify /etc/fstab so that it doesn't mount the old home partition. You can do that manually with your favourite text editor, or with a program like sed, e.g.:

sed -i 's/^UUID=6397f416-fe69-4a90-9336-7497d42df184/#&/' /etc/fstab 

Note: a safer alternative would be to use rsync to copy all the files from /home to /home.new rather than mv them. That eliminates the risk of losing any files if something unfortunate happens (e.g. sudden crash or power loss). Then either delete all files in the old /home or reformat the partition after everything has been copied.

Using rsync also reduces, if not eliminates, the risk of problems caused by user files/dirs being modified during the procedure, as you can re-run the rsync command as many times as you like and only new/modified files will be synced. Do the initial rsync at any time, and then do a final rsync when nobody else is logged in. The final rsync will be very fast, so that will minimise downtime for users.

Source Link
cas
  • 84.7k
  • 9
  • 138
  • 206

Here's one way of doing it:

As root, while no other users are logged in, no user processes are running, and user cron jobs and systemd timers (if any) are disabled (in short, when there's no chance of user files/dirs being modified while the mv operation is in progress):

mkdir /home.new shopt -s dotglob nullglob # make sure dot files match the /home/* glob mv /home/* /home.new/ umount /home rmdir /home mv /home.new /home 

(you can use mv -v if you want verbose output so you have something to watch while the files are being moved - but note that verbose output will cause the move to be significantly slower).

Then modify /etc/fstab so that it doesn't mount the old home partition. You can do that manually with your favourite text editor, or with a program like sed, e.g.:

sed -i 's/^UUID=6397f416-fe69-4a90-9336-7497d42df184/#&/' /etc/fstab 

Note: a safer alternative would be to use rsync to copy all the files from /home to /home.new rather than mv them. That eliminates the risk of losing any files if something unfortunate happens (e.g. sudden crash or power loss). Then either delete all files in the old /home or reformat the partition after everything has been copied.