Skip to contentSkip to conversation

is it possible to use LVM AFTER system installation?

DISCUSSION Frédéric Baldit 3 participants 3 messages Feb 21

lore
Share & tools
lore
#0 lore raw

Hi everybody,

I'm a debian 12 user, running it on a system which was initially installed without LVM (on a thinkpad laptop)n with classical netinst. My system is totally installed on a unique nvme disk, with distinct partitions, among which a /home partition for all my personal data.

I recently installed a second nvme disk (512G capacity). I would like to extend my /home ext4 partition (which is now exclusively on /dev/nvme0n1p6, 436G) so that I can keep my old data but have the possibility to split /home on the initial disk and the second recently added disk.

This seems to be possible with LVM but only when decided at the beginning of the installation. Right or wrong?

Or would it possible to:

0) install lvm2 on my system
1) create a new ext4 partition (512G size) on the new nvme disk (using all available space, 512G, on it)
2) create a new PV with this partition
3) create a new VG containing this unique PV
4) create a new LV on this VG
5) format this LV as an ext4 filesystem with mkfs.ext4
6) mount this LV on a new system directory, say /home1
7) migrate all the data on my old /home to the new /home1
8) modify the VG created before in order to add to it the /dev/nvme0n1p6 PV
9) resize the LV so that it can use the new PV added
10) rename /home1 to /home

Is this globally correct??? Step 7 if crucial, as I really don't want any loss or corruption of personal data during the transfer.

Thank's in advance for any help to my two questions,

F. Baldit.

--
Frédéric Baldit

#1 lore raw

That seems pretty close to right. Step 1 I would label the
partition as LVM, not that it really matters since the labels seem to not be actively used in Linux) I did not look at every last step in detail, but that is pretty close to what should work if executed correctly.

On step 7 you probably need to execute it with the primary user logged out and from a non-gui login(or a root login assuming root's home is /root and not in /home) to get a clean copy.

You may need to make sure your initramfs has lvm built into it, it may not really matter for home given it can mount much later than say / (if using lvm for /).

Quoted 46 lines · Frédéric Baldit

Hi everybody,

I'm a debian 12 user, running it on a system which was initially installed without LVM (on a thinkpad laptop)n with classical netinst. My system is totally installed on a unique nvme disk, with distinct partitions, among which a /home partition for all my personal data.

I recently installed a second nvme disk (512G capacity). I would like to extend my /home ext4 partition (which is now exclusively on /dev/nvme0n1p6, 436G) so that I can keep my old data but have the possibility to split /home on the initial disk and the second recently added disk.

This seems to be possible with LVM but only when decided at the beginning of the installation. Right or wrong?

Or would it possible to:

0) install lvm2 on my system
1) create a new ext4 partition (512G size) on the new nvme disk (using all available space, 512G, on it)
2) create a new PV with this partition
3) create a new VG containing this unique PV
4) create a new LV on this VG
5) format this LV as an ext4 filesystem with mkfs.ext4
6) mount this LV on a new system directory, say /home1
7) migrate all the data on my old /home to the new /home1
8) modify the VG created before in order to add to it the /dev/nvme0n1p6 PV
9) resize the LV so that it can use the new PV added
10) rename /home1 to /home

Is this globally correct??? Step 7 if crucial, as I really don't want any loss or corruption of personal data during the transfer.

Thank's in advance for any help to my two questions,

F. Baldit.

--
Frédéric Baldit

#2 lore raw
In reply to Frédéric Baldit
Quoted 14 lines · Frédéric Baldit

Hi everybody,

I'm a debian 12 user, running it on a system which was initially installed without LVM (on a thinkpad laptop)n with classical netinst. My system is totally installed on a unique nvme disk, with distinct partitions, among which a /home partition for all my personal data.

I recently installed a second nvme disk (512G capacity). I would like to extend my /home ext4 partition (which is now exclusively on /dev/nvme0n1p6, 436G) so that I can keep my old data but have the possibility to split /home on the initial disk and the second recently added disk.

Quoted 4 lines

This seems to be possible with LVM but only when decided at the beginning of the installation. Right or wrong?

Or would it possible to:

create 3 partitions:
1MB for boot loader (grub)
500B for UEFI
rest: LVM PV

Something like:
VG=vg01
LVN=lvhome
DRV=/dev/nvme....
PART2=/dev/nvme....
PART3=/dev/nvme....

SZ=...G # slightly larger (like 1GB) than your current /home

parted $DRV mklabel gpt

  # those values are crucial:
  parted -s $DRV unit s mkpart primary      34     2047 set 1 bios_grub on
  parted -s $DRV unit s mkpart primary    2048  1050623 set 2 esp on
  parted -s $DRV unit s mkpart primary 1050624 100%FREE set 3 lvm on
  partprobe $DRV

mkfs.fat -F32 $PART2
pvcreate $PART3
vgcreate $VG $PART3
lvcreate $VG -n $LVN -L $SZ

umount /home
dd if=$OLDHOME of=/dev/$VG/$LVN bs=10M
resize2fs /dev/$VG/$LVN
fsck -f /dev/$VG/$LVN
$EDITOR /etc/fstab
mount /home

live happily ever after...

cherry on top:
- mount partition 2 somewhere
copy the contents of your existing efi boot partition there umount partition 2
- run grub to install on the new drive
Y? If you ever come across replacing the smaller disk the preparations to get the new disk bootable are already done

Signature · 2 lines
Christian Recktenwald      : voice +49 711 601 2091  : Böblinger Strasse 189
[email protected]            : mobil +49 172 711 8104  : D-70199 Stuttgart