Moving /home with LVM
There are quite a few ways to do what you want, but the way I'd recommend is:
- Partition the new disk. It can be one big LVM partition or you can set aside one or more non-LVM partitions for other purposes. I sometimes create multiple LVM partitions (aka physical volumes, or PVs) so that I can remove one or more of them from the LVM configuration in the future, should the need arise. Note that I do not recommend putting PV data structures directly on the disk without partitions, as shown in the LVM answer you reference. Although this is legal, it can lead to confusion because hard disks are usually partitioned.
- Prepare the PV(s) for use by LVM with the
pvcreate
command, as insudo pvcreate /dev/sdb1
. - Add the new PV(s) to your existing volume group (VG) with
vgextend
, as insudo vgextend ubuntu--vg /dev/sdb1
. - Type
sudo pvdisplay
to show statistics on your PVs, including their sizes. - Create a new logical volume (LV) with
lvcreate
, as insudo lvcreate -L 900G -n home ubuntu--vg /dev/sdb1
. Note that I've specified a syntax that enables you to set a size (via-L
) and the PV on which the LV will be created (/dev/sdb1
). - Type
sudo pvdisplay
again to verify that you've created an LV that's an appropriate size. If not, you can resize it withlvresize
or delete it withlvremove
and try again. - Create a filesystem on your LV, as in
sudo mkfs -t ext4 /dev/mapper/ubuntu--vg-home
. - Mount the new LV somewhere convenient, as in
sudo mount /dev/mapper/ubuntu--vg-home /mnt
. - Copy your
/home
directory withtar
,cp
,rsync
, or whatever tool you prefer. - Edit
/etc/fstab
to mount the new LV at/home
. - Rename your current
/home
to some other name (say,/home-orig
) and create a new empty/home
directory to serve as a mount point. - Reboot and hope it works.
- If it all looks good, delete the old
/home-orig
directory.
Steps 8-11 are very similar to equivalent steps in the procedure outlined in the wiki page you reference, so I've gone light on the details for those steps.
Note that, although I've done this sort of thing myself many times, the example commands I've shown are based on my reading of the relevant man pages, so I may have missed some detail. I recommend you review the man pages and, if you get an error, adjust once you figure out what's wrong. Also, I find Ubuntu's default LVM naming confusing, so I may have misinterpreted that detail, and you may need to adjust.
Once you're done with this, you'll have unused space in your PV on your SSD. You can expand your root (/
) LV into this space, expand the /home
LV to span both disks, create another LV for some special purpose, etc.
A variant of this procedure might be to leave your current /home
LV where it is, create a new LV on the new disk, and begin using the new LV as spillover space. You note that your computer is a multi-user server, so this might be awkward, but there might be reasons to do this -- for instance, if just one or two users are consuming the lion's share of the disk space, you could move just their home directories to the new space or give them directories on the new space (with mount points or symbolic links to make access easier) and instruct them to move their big files to the new space. This approach would have the advantage of not negatively impacting other users, since the new hard disk storage space is likely to be noticeably slower than the old SSD storage space.