I currently have Ubuntu 16.04 Server installed on a machine with a small 96-GB SSD. That's no longer enough space for all of the users on the server, so I'd like to add a 1-TB HDD and move the /home
folder to a new partition on this 1-TB drive explicitly.
Originally, I had planned on doing this using the instructions here. However, on closer review of the system, I discovered that LVM is enabled:
Filesystem Size Used Avail Use% Mounted on
udev 63G 0 63G 0% /dev
tmpfs 13G 9.5M 13G 1% /run
/dev/mapper/ubuntu--vg-root 98G 76G 18G 82% /
tmpfs 63G 0 63G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 63G 0 63G 0% /sys/fs/cgroup
/dev/sda2 473M 111M 338M 25% /boot
/dev/sda1 512M 136K 512M 1% /boot/efi
tmpfs 13G 0 13G 0% /run/user/1001
Based on what I've read so far, I need to add the new drive to the ubuntu-vg
volume group (as in steps 2-3 of this answer). But I'm unsure of how to proceed after this — should I continue with steps 4-5? Or is there another way of explicitly moving just /home
to the 1-TB HDD and leaving /
on the SSD?
Best Answer
There are quite a few ways to do what you want, but the way I'd recommend is:
pvcreate
command, as insudo pvcreate /dev/sdb1
.vgextend
, as insudo vgextend ubuntu--vg /dev/sdb1
.sudo pvdisplay
to show statistics on your PVs, including their sizes.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
).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.sudo mkfs -t ext4 /dev/mapper/ubuntu--vg-home
.sudo mount /dev/mapper/ubuntu--vg-home /mnt
./home
directory withtar
,cp
,rsync
, or whatever tool you prefer./etc/fstab
to mount the new LV at/home
./home
to some other name (say,/home-orig
) and create a new empty/home
directory to serve as a mount point./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.