Assuming that the filesystem is directly on /dev/md3 (and you're not partitioning it or using LVM), yes, setting root=/dev/md3
is what you want. Things you should check though:
- Rebuild the initrd and check that it contains RAID support (you may need to coax it since the current root isn't on RAID, by adding
raid1
to /etc/initramfs-tools/modules
).
- Make sure that booting from a degraded array[0] is enabled (Ubuntu disables this by default: set
BOOT_DEGRADED=true
in /etc/initramfs-tools/conf.d/mdadm
)
- Duplicate the GRUB entry and set a fallback entry in GRUB so that it (hopefully) boots the non-RAID disk if the RAID disk fails to boot (add a
set fallback="2"
line to /etc/grub.d/40_custom
, where the number is the number of the menuentry counted from 0).
- Possibly also use
grub-set-default --once
instead of setting the default explicitly so that rebooting the machine is sufficient to boot the non-RAID disk.
[0]: Your array may actually not be degraded, but you probably want this anyway.
All of the following steps (except the bootloader installation) will be done on the running system.
1. Create Partitions on sdb
Just as you did create the partitions on sdb. Make sure sdb1 has the same start and end values as sda1.
Create sdb2 just as you did earlier (i.e. not the whole rest of the drive)
2. Clone sda1 to sdb1
Remount /dev/sda1 in read-only mode with mount -o remount,ro /boot
and clone the partition dd if=/dev/sda1 of=/dev/sdb1
.
3. Swap drives and make sure sdb boots
Swap sda and sdb. Install the bootloader on the new sda and make sure the bootloader still loads the kernel when the new sdb (i.e. the original drive) is not connected.
Boot will panic because there's no root volume, but you now know that it can boot. Reattach sdb
.
3. Extend your Volume Group
Add the new sda2 to your volume group like this:
pvcreate /dev/sda2
and vgextend centos /dev/sda2
4. Move over your swap and root volumes
The following commands will move not clone your volumes onto your new drive. The will however stay in the same volume group
pvmove -n swap /dev/sdb2 /dev/sda2
pvmove -n root /dev/sdb2 /dev/sda2
5. Clone your /home
Create a new volume for /home on sda2, mount it somewhere and clone the contents with xfsdump and xfsrestore
lvcreate --size 77,50G --name new_home centos /dev/sda2
mount /dev/centos/new_home /mnt
xfsdump -J /home | xfsrestore -J /mnt
6. Make sure selinux labels got transferred
Check that ls -Z /home
and ls -Z /mnt
match
7. Rename home volumes
Umount both home volumes and rename them accordingly
umount /home
umount /mnt
lvrename centos/home centos/old_home
lvrename centos/new_home centos/home
mount /home
You have now your cloned smaller /home mounted. The volume centos/old_home is the last one still on sdb2.
At this point your system should boot and run without any hassle, but you still need to get rid of sdb.
8. Cleanup
After your have rebooted and made sure everything still works as expected you can remove the old home volume using lvremove centos/old_home
. When you look at the output of pvs
you should notice that sdb2 should be completely unused.
At this point you can vgreduce centos /dev/sdb2
and pvremove /dev/sdb2
so the "old" drive is no more part of your volume group.
You can now shutdown the box and remove the old drive.
Best Answer
The
/dev/vg_osdisk/lv_swap
is a part of swap area (as used already logical volume) and cannot be expand xfs_growfs command.The sda3 (207.9G) partition is already assigned as a part of swap area.
If you want to increase OS filesystem area, you must decrease swap area(reduce swap logical volume) with
swapoff
command, and extend lv_root or lv_home logical volume and then extend xfs filesystemxfs_growfs /dev/v_osdisk/lv_root
orxfs_growfs /dev/v_osdisk/lv_home
.