I have a hd of 150GB and other of 300GB, both partitioned, the former with a root partition and the latter with some unused space.
How can I use the unused space of the second to extend the root partition of the first?
I have a hd of 150GB and other of 300GB, both partitioned, the former with a root partition and the latter with some unused space.
How can I use the unused space of the second to extend the root partition of the first?
If you're not using LVM (or btrfs or ZFS), then "move and symlink" is the best you can do.
Format the partition if it isn't already formatted, and mount it somewhere "generic", like /exra
. Put the mount in /etc/fstab
so it'll be mounted on every reboot. Then move and symlink large directories from the root filesystem to the /extra
filesystem.
For example, to move /usr/share/doc
to /extra/usr/share/doc
:
# uncomment if not already mounted
# mkdir -p /extra
# mount /extra
mkdir /extra/usr/share/
mv /usr/share/doc/ /extra/usr/share/
ln -s /extra/usr/share/doc/ /usr/share/
All of this has to be done as root, of course, so sudo -i
first to get a root shell.
Note: you can't safely move directories which have files currently in use by other processes...so if you want to move, say, /var/lib/mysql
to /extra/var/lib/mysql
you'll have to do it while mysql is temporarily shut down, or while rebooted into recovery mode.
You also can't move files/dirs that are needed early in the boot process. That means don't move /etc
, /bin
, /sbin
, /lib
(or any subdirectories thereof).
/extra/var/lib/mysql
in /var/lib/mysql
.
– Luca Citi
Jan 27 '21 at 15:45