0

I am new to LVM. I am Ubuntu user. This is my disk

sda      8:0    0 465,8G  0 disk 
├─sda1   8:1    0   512M  0 part /boot/efi
└─sda2   8:2    0 465,3G  0 part /
sdb      8:16   0 931,5G  0 disk 
sdc      8:32   0 111,8G  0 disk 
└─sdc1   8:33   0 111,8G  0 part /media/miki/main
sr0     11:0    1  1024M  0 rom 

My pvs

sudo pvs
  PV         VG Fmt  Attr PSize   PFree  
  /dev/sdb      lvm2 ---  931,51g 931,51g

If I go for

sudo pvcreate /dev/sda

then add volume to volumes group. Last step would be to create logical volumes from the volume group. Will my disk content be deleted or not? How to protect my data? All the examples I have found start from unformatted disks,some others mention migrations and so on... EDIT

/dev/mapper/volgroup-projects   9,8G   37M  9,3G   1% /mnt/projects
/dev/mapper/volgroup-db         9,8G   37M  9,3G   1% /mnt/db
/dev/mapper/volgroup-workspace  897G   77M  851G   1% /mnt/workspace

I created logical volume,group and formatted and mounted volumes.

blkid
/dev/sda1: UUId="BBAE-8B0A" TYPE="vfat" PARTLABEL="EFI Systed Partition" PARTUUId="cf95d195-8e88-4303-9e0a-f6e0f1e69efa"
/dev/sda2: UUId="1df8cd45-1846-4e4b-a6da-182f020b6bc2" TYPE="ext4" PARTUUId="99d2b32e-0ae8-422a-baca-04fff9ed8428"
/dev/sdb: UUId="3ZT2RB-k5G1-d3dg-ANGP-Q909-rEr0-jgQnt4" TYPE="LVd2_member"
/dev/sdc1: LABEL="main" UUId="883abc03-348b-4166-8e84-85c110c3983b" TYPE="ext4" PARTLABEL="main" PARTUUId="e05af8bf-62c0-4d14-92a0-c4c6b32d5eb8"

How to migrate data from sdc to my workspace?

Richard Rublev
  • 145
  • 1
  • 2
  • 9

1 Answers1

2

First, backup and restore test any data you care about from the system.

Creating PVs will format a disk.

/dev/sda contains your root and boot partitions. Formatting these will make your system unable to boot or function. Reduce the file system and the partition is annoying: requires unmount in a rescue system, and will not be possible to reduce XFS file system. So don't reduce / if you can avoid it. When installing systems from scratch, make it small to begin with.


Develop a plan about how you are going to lay out storage and mounts on this system.

Currently, sdb is an empty PV of 931 GB, and sdc has a partition sdc1 of 112 GB containing file system /media/miki/main.

I suggest migrating to an all LVM setup for everything but / and /boot.

  • Create a VG on sdb.
  • Create LV and file system on it.
  • Restore from backup /media/miki/main to the new LV.
  • Create a different VG on sdc (no need to partition).
  • Create additional LVs as required.

There are other ways you can design this. For example, its also possible to add both sdb and sdc into the same VG, then pvmove --name to migrate the volume back to the smaller disk.

John Mahowald
  • 32,050
  • 2
  • 19
  • 34