Move root filesystem on a logical volume to a different disk

5,130

pvmove will move your LVs within a VG from the existing PVs to another PV.

That may solve your problem...

Share:
5,130

Related videos on Youtube

lvm_headaches
Author by

lvm_headaches

Updated on September 18, 2022

Comments

  • lvm_headaches
    lvm_headaches over 1 year

    I'm trying to move my root LV to a new VG on my brand new SSD and it's driving me crazy. I think I pulled it off with rsync, but now grub is refusing to register the new boot option off of /dev/vg_ssd/lv_root. Why doesn't linux have cplv or lvmove like AIX?

    I want to use vg_ssd/root to mount to / instead of vg_dopey/lv00. /boot is separate. Grub2/FC17. Linux dopey 3.6.2-4.fc17.x86_64 #1 SMP Wed Oct 17 02:43:21 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

    lvdisplay

    --- Logical volume ---
      LV Path                /dev/vg_ssd/root
      LV Name                root
      VG Name                vg_ssd
      LV UUID                oDms4t-cKve-Eg27-jdcW-H3Wu-kvhs-qHhJQm
      LV Write Access        read/write
      LV Creation host, time dopey, 2012-10-22 20:25:31 -0400
      LV Status              available
      # open                 0
      LV Size                32.00 GiB
      Current LE             8191
      Segments               1
      Allocation             inherit
      Read ahead sectors     auto
      - currently set to     256
      Block device           253:1
    
      --- Logical volume ---
      LV Path                /dev/vg_dopey/lv01
      LV Name                lv01
      VG Name                vg_dopey
      LV UUID                2tSy4L-kPnC-8rSE-jXX8-Dad4-9F4v-TPVmQz
      LV Write Access        read/write
      LV Creation host, time dopey, 2012-10-01 22:50:49 -0400
      LV Status              available
      # open                 1
      LV Size                468.69 GiB
      Current LE             14998
      Segments               2
      Allocation             inherit
      Read ahead sectors     auto
      - currently set to     256
      Block device           253:2
    
      --- Logical volume ---
      LV Path                /dev/vg_dopey/lv00
      LV Name                lv00
      VG Name                vg_dopey
      LV UUID                SYe9Ze-XFUb-kIcu-UxEO-dhMd-ubaf-oAphsk
      LV Write Access        read/write
      LV Creation host, time dopey, 2012-10-01 22:50:53 -0400
      LV Status              available
      # open                 1
      LV Size                19.53 GiB
      Current LE             625
      Segments               1
      Allocation             inherit
      Read ahead sectors     auto
      - currently set to     256
      Block device           253:0
    

    /etc/fstab, both on new and old root lvs

    #/dev/mapper/vg_dopey-lv00 /                       ext4    defaults        1 1
    UUID=587081f1-e607-43bd-85f5-7632d833726e /boot                   ext4    defaults        1 2
    /dev/vg_dopey/lv01      /home       ext4    defaults    1 2
    UUID=8dec0c61-6593-4e1d-a7b1-86de1816a601 /opt/media              ext4    defaults        1 2
    UUID=910763ef-317b-4c48-b92f-8f24a729ffb8 swap                    swap    defaults        0 0
    #/dev/mapper/vg_ssd-root
    UUID=f7ada493-298d-4c09-8260-a8988ede1cfe / ext4 discard,noatime,errors=remount-ro 0 1
    

    /boot/grub2/grub.cfg

    #
    # DO NOT EDIT THIS FILE
    #
    # It is automatically generated by grub2-mkconfig using templates
    # from /etc/grub.d and settings from /etc/default/grub
    #
    
    ### BEGIN /etc/grub.d/00_header ###
    if [ -s $prefix/grubenv ]; then
      load_env
    fi
    set default="${saved_entry}"
    
    if [ x"${feature_menuentry_id}" = xy ]; then
      menuentry_id_option="--id"
    else
      menuentry_id_option=""
    fi
    
    export menuentry_id_option
    
    if [ "${prev_saved_entry}" ]; then
      set saved_entry="${prev_saved_entry}"
      save_env saved_entry
      set prev_saved_entry=
      save_env prev_saved_entry
      set boot_once=true
    fi
    
    function savedefault {
      if [ -z "${boot_once}" ]; then
        saved_entry="${chosen}"
        save_env saved_entry
      fi
    }
    
    function load_video {
      if [ x$feature_all_video_module = xy ]; then
        insmod all_video
      else
        insmod efi_gop
        insmod efi_uga
        insmod ieee1275_fb
        insmod vbe
        insmod vga
        insmod video_bochs
        insmod video_cirrus
      fi
    }
    
    if [ x$feature_default_font_path = xy ] ; then
       font=unicode
    else
    insmod part_msdos
    insmod part_msdos
    insmod lvm
    insmod ext2
    set root='lvm/vg_dopey-lv00'
    if [ x$feature_platform_search_hint = xy ]; then
      search --no-floppy --fs-uuid --set=root --hint='lvm/vg_dopey-lv00'  67deba56-4839-41c3-8c51-46185c8efd0e
    else
      search --no-floppy --fs-uuid --set=root 67deba56-4839-41c3-8c51-46185c8efd0e
    fi
        font="/usr/share/grub/unicode.pf2"
    fi
    
    if loadfont $font ; then
      set gfxmode=auto
      load_video
      insmod gfxterm
      set locale_dir=$prefix/locale
      set lang=en_US
      insmod gettext
    fi
    terminal_output gfxterm
    set timeout=5
    ### END /etc/grub.d/00_header ###
    
    ### BEGIN /etc/grub.d/10_linux ###
    menuentry 'Fedora' --class fedora --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-67deba56-4839-41c3-8c51-46185c8efd0e' {
        load_video
        set gfxpayload=keep
        insmod gzio
        insmod part_msdos
        insmod ext2
        set root='hd0,msdos6'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos6 --hint-efi=hd0,msdos6 --hint-baremetal=ahci0,msdos6 --hint='hd0,msdos6'  587081f1-e607-43bd-85f5-7632d833726e
        else
          search --no-floppy --fs-uuid --set=root 587081f1-e607-43bd-85f5-7632d833726e
        fi
        echo    'Loading Linux 3.6.2-4.fc17.x86_64 ...'
        linux   /vmlinuz-3.6.2-4.fc17.x86_64 root=/dev/mapper/vg_dopey-lv00 ro rd.md=0 rd.dm=0  KEYTABLE=us SYSFONT=True rd.luks=0 LANG=en_US.UTF-8 rd.lvm.lv=vg_dopey/lv00 rhgb quiet 
        echo    'Loading initial ramdisk ...'
        initrd  /initramfs-3.6.2-4.fc17.x86_64.img
    }
    submenu 'Advanced options for Fedora' $menuentry_id_option 'gnulinux-advanced-67deba56-4839-41c3-8c51-46185c8efd0e' {
        menuentry 'Fedora, with Linux 3.6.2-4.fc17.x86_64' --class fedora --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.6.2-4.fc17.x86_64-advanced-67deba56-4839-41c3-8c51-46185c8efd0e' {
            load_video
            set gfxpayload=keep
            insmod gzio
            insmod part_msdos
            insmod ext2
            set root='hd0,msdos6'
            if [ x$feature_platform_search_hint = xy ]; then
              search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos6 --hint-efi=hd0,msdos6 --hint-baremetal=ahci0,msdos6 --hint='hd0,msdos6'  587081f1-e607-43bd-85f5-7632d833726e
            else
              search --no-floppy --fs-uuid --set=root 587081f1-e607-43bd-85f5-7632d833726e
            fi
            echo    'Loading Linux 3.6.2-4.fc17.x86_64 ...'
            linux   /vmlinuz-3.6.2-4.fc17.x86_64 root=/dev/mapper/vg_dopey-lv00 ro rd.md=0 rd.dm=0  KEYTABLE=us SYSFONT=True rd.luks=0 LANG=en_US.UTF-8 rd.lvm.lv=vg_dopey/lv00 rhgb quiet 
            echo    'Loading initial ramdisk ...'
            initrd  /initramfs-3.6.2-4.fc17.x86_64.img
        }
        menuentry 'Fedora, with Linux 3.6.2-4.fc17.x86_64 (recovery mode)' --class fedora --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.6.2-4.fc17.x86_64-recovery-67deba56-4839-41c3-8c51-46185c8efd0e' {
            load_video
            set gfxpayload=keep
            insmod gzio
            insmod part_msdos
            insmod ext2
            set root='hd0,msdos6'
            if [ x$feature_platform_search_hint = xy ]; then
              search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos6 --hint-efi=hd0,msdos6 --hint-baremetal=ahci0,msdos6 --hint='hd0,msdos6'  587081f1-e607-43bd-85f5-7632d833726e
            else
              search --no-floppy --fs-uuid --set=root 587081f1-e607-43bd-85f5-7632d833726e
            fi
            echo    'Loading Linux 3.6.2-4.fc17.x86_64 ...'
            linux   /vmlinuz-3.6.2-4.fc17.x86_64 root=/dev/mapper/vg_dopey-lv00 ro single rd.md=0 rd.dm=0  KEYTABLE=us SYSFONT=True rd.luks=0 LANG=en_US.UTF-8 rd.lvm.lv=vg_dopey/lv00 rhgb quiet
            echo    'Loading initial ramdisk ...'
            initrd  /initramfs-3.6.2-4.fc17.x86_64.img
        }
        menuentry 'Fedora, with Linux 3.6.1-1.fc17.x86_64' --class fedora --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.6.1-1.fc17.x86_64-advanced-67deba56-4839-41c3-8c51-46185c8efd0e' {
            load_video
            set gfxpayload=keep
            insmod gzio
            insmod part_msdos
            insmod ext2
            set root='hd0,msdos6'
            if [ x$feature_platform_search_hint = xy ]; then
              search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos6 --hint-efi=hd0,msdos6 --hint-baremetal=ahci0,msdos6 --hint='hd0,msdos6'  587081f1-e607-43bd-85f5-7632d833726e
            else
              search --no-floppy --fs-uuid --set=root 587081f1-e607-43bd-85f5-7632d833726e
            fi
            echo    'Loading Linux 3.6.1-1.fc17.x86_64 ...'
            linux   /vmlinuz-3.6.1-1.fc17.x86_64 root=/dev/mapper/vg_dopey-lv00 ro rd.md=0 rd.dm=0  KEYTABLE=us SYSFONT=True rd.luks=0 LANG=en_US.UTF-8 rd.lvm.lv=vg_dopey/lv00 rhgb quiet 
            echo    'Loading initial ramdisk ...'
            initrd  /initramfs-3.6.1-1.fc17.x86_64.img
        }
        menuentry 'Fedora, with Linux 3.6.1-1.fc17.x86_64 (recovery mode)' --class fedora --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.6.1-1.fc17.x86_64-recovery-67deba56-4839-41c3-8c51-46185c8efd0e' {
            load_video
            set gfxpayload=keep
            insmod gzio
            insmod part_msdos
            insmod ext2
            set root='hd0,msdos6'
            if [ x$feature_platform_search_hint = xy ]; then
              search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos6 --hint-efi=hd0,msdos6 --hint-baremetal=ahci0,msdos6 --hint='hd0,msdos6'  587081f1-e607-43bd-85f5-7632d833726e
            else
              search --no-floppy --fs-uuid --set=root 587081f1-e607-43bd-85f5-7632d833726e
            fi
            echo    'Loading Linux 3.6.1-1.fc17.x86_64 ...'
            linux   /vmlinuz-3.6.1-1.fc17.x86_64 root=/dev/mapper/vg_dopey-lv00 ro single rd.md=0 rd.dm=0  KEYTABLE=us SYSFONT=True rd.luks=0 LANG=en_US.UTF-8 rd.lvm.lv=vg_dopey/lv00 rhgb quiet
            echo    'Loading initial ramdisk ...'
            initrd  /initramfs-3.6.1-1.fc17.x86_64.img
        }
        menuentry 'Fedora, with Linux 3.5.6-1.fc17.x86_64' --class fedora --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.5.6-1.fc17.x86_64-advanced-67deba56-4839-41c3-8c51-46185c8efd0e' {
            load_video
            set gfxpayload=keep
            insmod gzio
            insmod part_msdos
            insmod ext2
            set root='hd0,msdos6'
            if [ x$feature_platform_search_hint = xy ]; then
              search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos6 --hint-efi=hd0,msdos6 --hint-baremetal=ahci0,msdos6 --hint='hd0,msdos6'  587081f1-e607-43bd-85f5-7632d833726e
            else
              search --no-floppy --fs-uuid --set=root 587081f1-e607-43bd-85f5-7632d833726e
            fi
            echo    'Loading Linux 3.5.6-1.fc17.x86_64 ...'
            linux   /vmlinuz-3.5.6-1.fc17.x86_64 root=/dev/mapper/vg_dopey-lv00 ro rd.md=0 rd.dm=0  KEYTABLE=us SYSFONT=True rd.luks=0 LANG=en_US.UTF-8 rd.lvm.lv=vg_dopey/lv00 rhgb quiet 
            echo    'Loading initial ramdisk ...'
            initrd  /initramfs-3.5.6-1.fc17.x86_64.img
        }
        menuentry 'Fedora, with Linux 3.5.6-1.fc17.x86_64 (recovery mode)' --class fedora --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.5.6-1.fc17.x86_64-recovery-67deba56-4839-41c3-8c51-46185c8efd0e' {
            load_video
            set gfxpayload=keep
            insmod gzio
            insmod part_msdos
            insmod ext2
            set root='hd0,msdos6'
            if [ x$feature_platform_search_hint = xy ]; then
              search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos6 --hint-efi=hd0,msdos6 --hint-baremetal=ahci0,msdos6 --hint='hd0,msdos6'  587081f1-e607-43bd-85f5-7632d833726e
            else
              search --no-floppy --fs-uuid --set=root 587081f1-e607-43bd-85f5-7632d833726e
            fi
            echo    'Loading Linux 3.5.6-1.fc17.x86_64 ...'
            linux   /vmlinuz-3.5.6-1.fc17.x86_64 root=/dev/mapper/vg_dopey-lv00 ro single rd.md=0 rd.dm=0  KEYTABLE=us SYSFONT=True rd.luks=0 LANG=en_US.UTF-8 rd.lvm.lv=vg_dopey/lv00 rhgb quiet
            echo    'Loading initial ramdisk ...'
            initrd  /initramfs-3.5.6-1.fc17.x86_64.img
        }
    }
    
    ### END /etc/grub.d/10_linux ###
    
    ### BEGIN /etc/grub.d/20_linux_xen ###
    
    ### END /etc/grub.d/20_linux_xen ###
    
    ### BEGIN /etc/grub.d/20_ppc_terminfo ###
    ### END /etc/grub.d/20_ppc_terminfo ###
    
    ### BEGIN /etc/grub.d/30_os-prober ###
    menuentry 'Microsoft Windows XP Professional (on /dev/sda1)' --class windows --class os $menuentry_id_option 'osprober-chain-AA0C2EE80C2EAF6F' {
        insmod part_msdos
        insmod ntfs
        set root='hd0,msdos1'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1'  AA0C2EE80C2EAF6F
        else
          search --no-floppy --fs-uuid --set=root AA0C2EE80C2EAF6F
        fi
        drivemap -s (hd0) ${root}
        chainloader +1
    }
    ### END /etc/grub.d/30_os-prober ###
    
    ### BEGIN /etc/grub.d/40_custom ###
    # This file provides an easy way to add custom menu entries.  Simply type the
    # menu entries you want to add after this comment.  Be careful not to change
    # the 'exec tail' line above.
    ### END /etc/grub.d/40_custom ###
    
    ### BEGIN /etc/grub.d/41_custom ###
    if [ -f  ${config_directory}/custom.cfg ]; then
      source ${config_directory}/custom.cfg
    elif [ -z "${config_directory}" -a -f  $prefix/custom.cfg ]; then
      source $prefix/custom.cfg;
    fi
    ### END /etc/grub.d/41_custom ###
    

    mount

    proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
    sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime,seclabel)
    devtmpfs on /dev type devtmpfs (rw,nosuid,seclabel,size=2013244k,nr_inodes=503311,mode=755)
    devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,seclabel,gid=5,mode=620,ptmxmode=000)
    tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev,seclabel)
    tmpfs on /run type tmpfs (rw,nosuid,nodev,seclabel,mode=755)
    /dev/mapper/vg_dopey-lv00 on / type ext4 (rw,noatime,seclabel,discard,errors=remount-ro,data=ordered)
    securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
    selinuxfs on /sys/fs/selinux type selinuxfs (rw,relatime)
    tmpfs on /sys/fs/cgroup type tmpfs (rw,nosuid,nodev,noexec,seclabel,mode=755)
    cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd)
    cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)
    cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpuacct,cpu)
    cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)
    cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
    cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
    cgroup on /sys/fs/cgroup/net_cls type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls)
    cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
    cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event)
    systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=27,pgrp=1,timeout=300,minproto=5,maxproto=5,direct)
    mqueue on /dev/mqueue type mqueue (rw,relatime,seclabel)
    tmpfs on /media type tmpfs (rw,nosuid,nodev,noexec,relatime,seclabel,mode=755)
    debugfs on /sys/kernel/debug type debugfs (rw,relatime)
    configfs on /sys/kernel/config type configfs (rw,relatime)
    hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime,seclabel)
    /dev/sdc1 on /opt/media type ext4 (rw,relatime,seclabel,data=ordered)
    /dev/sda6 on /boot type ext4 (rw,relatime,seclabel,data=ordered)
    /dev/mapper/vg_dopey-lv01 on /home type ext4 (rw,relatime,seclabel,data=ordered)
    gvfs-fuse-daemon on /run/user/me/gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev,relatime,user_id=1000,group_id=1000)
    fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)
    
    • daisy
      daisy over 11 years
      What you trying to archive? Duplicate existing LVs to the SSD?
    • lvm_headaches
      lvm_headaches over 11 years
      Exactly. I managed to do it by following [link]void.gr/kargig/blog/2012/01/11/… but I can't seem to get grub to go for the root fs on the ssd instead of the old one on the hdd. /boot is a regular old logical partition.
    • daisy
      daisy over 11 years
      Using grub1.9X?
    • lvm_headaches
      lvm_headaches over 11 years
      grub2. ran grub2-install /dev/sda. My boot-flagged partition is on sda (the hdd). ssd is /dev/sdb.
    • Alen Milakovic
      Alen Milakovic almost 7 years
  • lvm_headaches
    lvm_headaches over 11 years
    My fstab is fine, I think. See above. The issue is that grub.cfg is still pointing to the old root fs and causing all kinds of havoc. and grub2-install isn't picking up the new root fs on the ssd. The current setup causes errors, the old root fs mounts ro, stopping x/gdm, I remount to rw and x/gdm starts.
  • lvm_headaches
    lvm_headaches over 11 years
    I appreciate the help you're giving me. =]
  • lvm_headaches
    lvm_headaches over 11 years
    Right, still broken. grub2-mkconfig output is still pointing at lv00 (old hdd root fs), not lvroot (new ssd)
  • daisy
    daisy over 11 years
    @lvm_headaches show the output of mount ? Also check the update
  • lvm_headaches
    lvm_headaches over 11 years
    Updated grub.cfg with UUID and /dev/mapper for new root, rebooted. Failed to dracut. Posted mount above.
  • lvm_headaches
    lvm_headaches over 11 years
    I thought about that, but I want to remake the filesystem from scratch to match the block size. mkfs.ext4 -O extent -b 4096 -E stride=128,stripe-width=128 /dev/mapper/ssd-debian
  • Bratchley
    Bratchley over 10 years
    If you insist on modifying block size, you might be able to do the right combination of lvcreate and lvrename calls so that you create the LV on the SSD and then rename the LV's such that te new one has the same name as the old.