0

I would like some help moving the root partition from an existing hard drive across to a newly installed SSD.

The PC is an i7 (Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz) with 32GB ram and 2 x 2TB 5400rpm sata drives. It is running Fedora 29 linux.

New M.2 SSD is:- Samsung SSD 970 EVO Plus 500GB at /dev/nvme0n1.

Existing Partitions on /dev/sda

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048          411647   200.0 MiB   EF00  EFI System Partition
   2          411648         2508799   1024.0 MiB  8300  Linux filesystem
   3         2508800      3907028991   1.8 TiB     8E00  Linux LVM

# /etc/fstab

UUID=486b1d3d-c426-4ce6-a5ac-0f7109e4d463 /boot    ext4    defaults        1 2
UUID=ACA0-FA79                          /boot/efi  vfat    umask=0077,shortname=winnt 0 2
/dev/mapper/fedora_localhost--live-root /          ext4    defaults        1 1
/dev/mapper/fedora_localhost--live-home /home      ext4    defaults        1 2
/dev/mapper/fedora_localhost--live-swap swap       swap    defaults        0 0

# df -h output (minus some tmpfs entries)

Filesystem                               Size  Used Avail Use% Mounted on
/dev/mapper/fedora_localhost--live-root   49G   16G   32G  34% /
/dev/sda2                                976M  202M  708M  23% /boot
/dev/sda1                                200M   18M  182M   9% /boot/efi
/dev/mapper/fedora_localhost--live-home  1.8T   88G  1.6T   6% /home
tmpfs                                     16G   80K   16G   1% /tmp

Proposed Setup

From my research to date, the following partition scheme seems to be the go.

ssd     /           200G    (New LVM volume or partition)
sda1    /boot/efi   200M    (existing partition)
sda2    /boot       976M    (existing partition)
LVM     /home       1.8T    (existing volume on hdd - may shrink this a bit)
LVM     /var         49G    (re-use old root LVM volume on hdd)

My Questions

Is it best to use LVM commands? If so, please suggest the commands and switches. I have never done any LVM operations before.

And seeing as I am not using all the SSD, should the LVM partition consume the entire SSD or not?

If LVM commands are not the best, then would a standard formatted partition then use cp -a??? or rsync to copy the files across be appropriate, and how to keep permissions and devices intact?

Notes

I realise that /etc/fstab will need the new entry for the root volume.

I have (and plan to use) a knoppix live system dvd to do the work while the host filesystem is offline.

If you feel that one approach is better for SSD life span, please add your comments.

Thanks

0

I am answering my own question because, after much research into LVM and moving the root partition with various approaches, I decided on using LVM to do the job. It turns out it is quite simple using LVM (on Fedora 29). Here's what I did.

Create an LVM physical volume on the SSD.

$ sudo pvcreate /dev/nvme0n1 -v
  Wiping signatures on new PV /dev/nvme0n1.
  Set up physical volume for "/dev/nvme0n1" with 976773168 available sectors.
  Zeroing start of device /dev/nvme0n1.
  Writing physical volume data to disk "/dev/nvme0n1".
Physical volume "/dev/nvme0n1" successfully created.

Now join the new PV into the volume group (VG).

$ sudo vgextend fedora_localhost-live /dev/nvme0n1
    *(sorry missed the output of this one)*

Then reboot the PC with a SystemRescueCd (I used v6.0.3) on USB flash drive. I could have done the above pvcreate and vgextend from this rescue disk as well, I don't think it matters.

All that needs to be done now is move the partition with LVM and check it.

# pvmove -n root /dev/sda3 /dev/nvme0n1
  Daemon lvmpolld returned error 104
  WARNING: Failed to connect to lvmpolld. Proceeding with polling without using lvmpolld.
  WARNING: Check global/use_lvmpolld in lvm.conf or the lvmpolld daemon state.
  /dev/sda3: Moved: 100.00%

(Not sure what the warnings were about, but did not affect anything that I could see.)

# lvs -o+devices
  LV   VG                    Attr       LSize  Pool ...... Devices
  home fedora_localhost-live -wi-a-----  1.75t             /dev/sda3(4027)
  root fedora_localhost-live -wi-a----- 50.00g             /dev/nvme0n1(0)
  swap fedora_localhost-live -wi-a----- 15.73g             /dev/sda3(0)

So root partition is on the SSD now.

Just checking the physical to logical relationships...

# lsblk
NAME                            MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
sda                               8:0    0   1.8T  0 disk
├─sda1                            8:1    0   200M  0 part
├─sda2                            8:2    0     1G  0 part
└─sda3                            8:3    0   1.8T  0 part
  ├─fedora_localhost--live-swap 253:0    0  15.7G  0 lvm
  └─fedora_localhost--live-home 253:1    0   1.8T  0 lvm
nvme0n1                         259:0    0 465.8G  0 disk
└─fedora_localhost--live-root   253:2    0    50G  0 lvm   /mnt/fedoraRoot

Now its time to reboot into Fedora and check the structure again. BTW, I used the following commands while researching this issue and found them quite useful.

$ sudo pvdisplay -m
  --- Physical volume ---
  PV Name               /dev/sda3
  VG Name               fedora_localhost-live
  PV Size               <1.82 TiB / not usable 4.00 MiB
  Allocatable           yes
  PE Size               4.00 MiB
  Total PE              476625
  Free PE               12800
  Allocated PE          463825
  PV UUID               OktYlV-PYVx-A5AW-8TEs-Nz84-KDGz-F03Qz0

  --- Physical Segments ---
  Physical extent 0 to 4026:
    Logical volume  /dev/fedora_localhost-live/swap
    Logical extents 0 to 4026
  Physical extent 4027 to 463824:
    Logical volume  /dev/fedora_localhost-live/home
    Logical extents 0 to 459797
  Physical extent 463825 to 476624:
    FREE

  --- Physical volume ---
  PV Name               /dev/nvme0n1
  VG Name               fedora_localhost-live
  PV Size               465.76 GiB / not usable 4.02 MiB
  Allocatable           yes
  PE Size               4.00 MiB
  Total PE              119234
  Free PE               106434
  Allocated PE          12800
  PV UUID               02mg6I-sXK9-eRL9-X1ho-AYx3-xKOW-GwdSDO

  --- Physical Segments ---
  Physical extent 0 to 12799:
    Logical volume  /dev/fedora_localhost-live/root
    Logical extents 0 to 12799
  Physical extent 12800 to 119233:
    FREE

And logical volumes.

$ sudo lvdisplay -m
  --- Logical volume ---
  LV Path                /dev/fedora_localhost-live/swap
  LV Name                swap
  VG Name                fedora_localhost-live
  LV UUID                K1N4iT-2pRA-w4af-MUNC-NkLt-Fzo3-AWOMkt
  LV Write Access        read/write
  LV Creation host, time localhost-live, 2018-07-25 08:39:49 +1000
  LV Status              available
  # open                 2
  LV Size                15.73 GiB
  Current LE             4027
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1

  --- Segments ---
  Logical extents 0 to 4026:
    Type        linear
    Physical volume /dev/sda3
    Physical extents    0 to 4026

  --- Logical volume ---
  LV Path                /dev/fedora_localhost-live/home
  LV Name                home
  VG Name                fedora_localhost-live
  LV UUID                RLqeX2-lrMJ-Mcce-q9k0-VJ4P-oy7H-MMUuWV
  LV Write Access        read/write
  LV Creation host, time localhost-live, 2018-07-25 08:39:49 +1000
  LV Status              available
  # open                 1
  LV Size                1.75 TiB
  Current LE             459798
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:2

  --- Segments ---
  Logical extents 0 to 459797:
    Type        linear
    Physical volume /dev/sda3
    Physical extents    4027 to 463824

  --- Logical volume ---
  LV Path                /dev/fedora_localhost-live/root
  LV Name                root
  VG Name                fedora_localhost-live
  LV UUID                SOseFb-5VaZ-kTxx-jgyM-0Z7E-Q9zF-RSXFOA
  LV Write Access        read/write
  LV Creation host, time localhost-live, 2018-07-25 08:40:05 +1000
  LV Status              available
  # open                 1
  LV Size                50.00 GiB
  Current LE             12800
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

  --- Segments ---
  Logical extents 0 to 12799:
    Type        linear
    Physical volume /dev/nvme0n1
    Physical extents    0 to 12799

And that seems to be it. All good and the machine is much faster at booting and program loading.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.