4

I'm on a server with Ubuntu 18.04LTS with single disk in LVM partition. Boot partition is ext2 , root partition is ext4 in volume group beta-root (as show below)

Filesystem             Size  Used Avail Use% Mounted on
udev                   3.9G     0  3.9G   0% /dev
tmpfs                  798M  3.3M  795M   1% /run
/dev/mapper/beta-root  293G  129G  152G  46% /
tmpfs                  3.9G     0  3.9G   0% /dev/shm
tmpfs                  5.0M     0  5.0M   0% /run/lock
tmpfs                  3.9G     0  3.9G   0% /sys/fs/cgroup
tmpfs                  512M     0  512M   0% /clam-tmp
/dev/sda1              228M  111M  106M  52% /boot
tmpfs                  798M     0  798M   0% /run/user/1001
tmpfs                  798M     0  798M   0% /run/user/0


Disk /dev/sda: 300 GiB, 322122547200 bytes, 629145600 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x000456c7

Device     Boot     Start       End   Sectors  Size Id Type
/dev/sda1  *         2048    499711    497664  243M 83 Linux
/dev/sda2          501758 125827071 125325314 59.8G  5 Extended
/dev/sda3       125827072 629145599 503318528  240G 8e Linux LVM
/dev/sda5          501760 125827071 125325312 59.8G 8e Linux LVM

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    nodev,noexec,nosuid 0       0
/dev/mapper/beta-root /               ext4    errors=remount-ro,acl 0       1
# /boot was on /dev/sda1 during installation
UUID=9b35bbcc-61f6-410a-bc43-f06516bfedd6 /boot           ext2    defaults        0       2
/dev/mapper/beta-swap_1 none            swap    sw              0       0

tmpfs   /dev/shm        tmpfs   defaults,noexec,nosuid  0       0

tmpfs /clam-tmp tmpfs defaults,noatime,nosuid,nodev,noexec,mode=1777,size=512M 0 0

There's an understandable method to migrate full system from a mixed environment (LVM and non-LVM) to a new hard disk (let's say /dev/sdb) with same layout but with no LVM at all?

Thanks for support!

  • have you tried rsync or cp to move the data? man rsync... if all your data is mounted and accessible syncing it to another drive should be trivial... even something as simple as cp -R /mnt/LVM/* /mnt/SDB/ then rsync the rest of your data to /mnt/SDB (I don't know how to do this off of the top of my head.. I need to look) then you could use something like boot-repair to make that drive bootable... anyone have any other thoughts on this? – Joshua Besneatte Aug 8 '19 at 19:05
  • Oh, and welcome to AskUbuntu! Nice first question! – Joshua Besneatte Aug 8 '19 at 19:09
  • 2
    rsyncing while system is live is not a good idea I suppose (MySQL, Apache, ...) write on system, even logs do the same... I suppose that could be done if you run to a lower init level like init 1 , but don't know if that is enough. – Andrea Biancalani Aug 8 '19 at 19:10
  • ah, thx for welcome ^^ – Andrea Biancalani Aug 8 '19 at 19:10
  • 1
    You could get around this by booting to a LiveUSB... Then you could run the boot-repair from the liveusb environment so set up your new drive for booting... – Joshua Besneatte Aug 8 '19 at 19:13
4

The steps I would follow, in a nutshell, are as thus:

  1. Boot from a liveUSB
  2. Install Boot-Repair:

    sudo add-apt-repository ppa:yannubuntu/boot-repair
    sudo apt-get update
    sudo apt-get install -y boot-repair
    
  3. Install and mount LVM drives as described here

    sudo apt-get install software-properties-common
    sudo apt-get install lvm2   #This step may or may not be required.
    sudo pvscan                 #Use this to verify your LVM partition(s) is/are detected.
    sudo vgscan                 #Scans for LVM Volume Group(s)
    sudo vgchange -ay           #Activates LVM Volume Group(s)
    sudo lvscan                 #Scans for available Logical Volumes
    sudo mount /dev/YourVolGroup00/YourLogVol00 /YourMountPoint
    
  4. Mount the drive where you are moving the data

  5. Copy data from the old to the new drive:

    Copy the boot partition:

    sudo dd if=/dev/sda1 of=/dev/sdb1 bs=4096 
    

    Copy the root partition:¹

    sudo dd if=/dev/beta/root | pv -s 300G | dd of=/dev/sdb2 bs=4096
    
  6. Run Boot-Repair on the new drive:

    sudo boot-repair
    
  7. Reboot

Note 1: This could take a very long time.

| improve this answer | |
  • 1
    you've anticipated me ;) I've wrote something similar below, but it seems we're on the same wave of ideas. I've cloned that server (is a vmware esx machine, not a problem) , tomorrow I'll give a shot on that clone doing something similar and I'll report some feedback! – Andrea Biancalani Aug 8 '19 at 19:25
  • 1
    excellent! glad things are going! anyway, I added info from your comment to the answer.. feel free to edit the answer to add any relevant info (it will earn you rep points too) – Joshua Besneatte Aug 8 '19 at 21:01
  • 1
    I just realized you will also need to edit your /etc/fstab to point to your new drives as well as deleting the old ones... can you post a copy of your /etc/fstab to your question so we can make a new one to put into the answer? thanks :) – Joshua Besneatte Aug 9 '19 at 0:55
  • 1
    Hi there Joshua, done some arrangement to previous post adding some notes and edited first post adding fstab output. Yesterday night maybe I was a little bit tired.. tried to dd a 300GB partition on a 150GB destination... lol. Started new process this morning with a similar destination layout. DD is ongoing... – Andrea Biancalani Aug 9 '19 at 7:39
  • 1
    An edit and an upvote! ;-) Please review my edits and also review the editing help to improve the readability of your answers in the future... ;-) (E.G. when numbering and providing code, use 8 spaces to indent) 0:-) – Fabby Aug 10 '19 at 19:43

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.