I've 3 partitions sdb1 sdb2 and sdb3.
I wanna to create a volume group and lvms in the sdb3 which is the mounted linux partition where is located my root folder.
I'm typing:
pvcreate /dev/sdb3
but i get:
Can't open /dev/sdb3 exclusively. Mounted filesystem.
So well, I know that my partition is mounted in fact I'm just working on it. Is there a way to create the volume group without asking my provider to reformat my partitions. I mean through SSH ?
Best Answer
You can do that, but it is hard.
The steps are essentially the following:
pivot_root
. This syscall/tool can change the root partition of your currently running system.pivot_root /mnt/rescuesys
, where your chrooted ramfs rescue system is running. If it succedded, from this point your original system will run in chroot, and your rescue system will run as the real root system.telinit q
command restart the init (the process 1) to run also from your real (now ramfs) system and not from the sdb3-based one. Maybetelinit Q
,telinit u
ortelinit U
could be also needed for that, it depends on your init system, too.lsof -n|grep /mnt/<oldsysroot>
command you can check, if there is any existing open fiedescriptor to your old system. If yes, kill, stop them one by one.pvcreate
, etc. commands, create the lvs, mount them, and copy your root system back.pivot_root
. From this point, your real root system is soon the logical volume, which you originally wanted to have./etc/fstab
, reconfigure/reinstall grub, and any similar.