У меня есть диск / dev / sda1, который имеет объем 60 ГБ и мне нужно его увеличить. Есть другой диск / dev / sdb, который составляет 500 ГБ, и я хочу увеличить объем диска, Есть ли способ использовать / dev / sdb для увеличения объема диска / dev / sda1?
Suppose /dev/sda1 is mounted as /
but it is getting too small. Let's say you have a huge directory /data
on that disk. You want to move that out of the way, to another partition, say /dev/sdb1
, but still be able to access that as if it were still on your /dev/sda1
. Suppose there is an EXT4 filesystem on /dev/sdb1
.
Mount /dev/sdb1
onto a mount point in your filesystem (I use diskb1
here, but call it what you want):
sudo mkdir /mnt/diskb1
sudo mount /dev/sdb1 /mnt/diskb1
sudo chown youruser:youruser /mnt/diskb1
Последняя команда меняет владельца раздела на вашего пользователя. Замените youruser
на ваше имя пользователя.
Скопируйте каталог / data
на другой диск. Я рекомендую rsync
, но cp
с правильными флагами также будет работать.
rsync -alz / data / mnt / diskb1 /
Если во время этой копии что-то пойдет не так, просто введите ту же команду. Фактически, в любом случае, сделайте это дважды, чтобы убедиться, что все скопировано.
Удалите старые / data
. На данный момент вы правильно скопировали его, так что это не повредит. Это шаг, который освобождает хранилище на диске /dev/sda1.
sudo rm -r / data
Создайте символическую ссылку под названием / data
, которая указывает на копию данных на диске b:
sudo ln -s / mnt / diskb1 / data / data
That's it. All the data that used to be available on /data
is still there, only it's now stored on disk b. You will want to enter a line into /etc/fstab
that causes the data
partition to be mounted after every reboot, but there are plenty examples of that on this site.
Make sure you replace sdb1
, youruser
and /data
by what is necessary on your system. Don't try this with system directories like /bin
or /lib
, those should remain on the root partition. And before you begin, backup your data.
Unless you are wanting to deal with the complexity of an additional layer, RAID, you cannot combine the space of multiple disks to form one storage volume. For "ordinary" users (i.e., no server), there is a lot of flexibility to seamlessly access storage on another location using symbolic links.
You may want to explore RAID, but do not greatly count on it to enlarge a single volume, unless you invest in additional hard drive space. A robust raid requires you to opt for data mirroring, so you need double the space.