Как настроить LVM для всего диска и удалить все созданные разделы после установки Debian?

749
static

У меня есть выделенный сервер. Я мог только установить Debian . Он был установлен как скрытый автоматизированный процесс. Я хотел бы сейчас использовать LVM и фактически разделить весь диск по другой схеме. Возможно ли и хорошая идея сделать это в уже установленном Debian или лучше установить новый Debian с debootstrap, а затем создать LVM и разделы?

Проблема с debootstrap заключается в том, что во всех руководствах говорится, что мне нужно разбить диск по новой схеме (можно ли это сделать из уже установленного Debian на этом диске?)

0

1 ответ на вопрос

0
Brian.D.Myers

This sounds very similar to what I had to do to recover my server at home after an incorrectly migrated fstab caused rsync to fill my root file system.

First off, understand my experience is with Ubuntu so that's the distro I'm speaking about. Never the less, they should be pretty similar.

The desktop distro of Ubuntu does not come with LVM, so I had to install it.

sudo apt-get install lvm2 

Now when you reboot (or insmod lvm) the kernel module will be loaded, but your disks are not LVM enabled yet. To do this, you can use gparted to create a partition out of your free space. It must be big enough to hold a copy of your installation. Then enable LVM on this volume:

sudo pvcreate /dev/sd[new partition letter & number] 

Create your volume group,

sudo vgcreate vg1 /dev/sd[same as above] 

Now you can begin creating logical volumes in your new partition.

sudo lvcreate -n lvroot -L 20G vg1 

This is a very simplified example, but it has the basics. You can indeed install LVM into an existing Linux install, but if you want your system to run from it, you'll have to migrate the install. I did so by using fsarchiver to do a backup, wipe of existing install, setup new LVs to match my partition scheme, then a restore, chroot and update-grub.

There are other ways to do it, and it was lot of work, but that worked well for me.