Moving CentOS 7 to LVM on Raspberry Pi 3 / ARMv7L
I will formalize this later when I can
- This is purely assuming you’re using CentOS 7 on RPI3 and have DD’ed the image per their installation instructions. This assumption will lead the below
- Confirm your version has support via CONFIG_BLK_DEV_INITRD kernel compile option. You can check /proc/config.gz for this..if you dont have it then modprobe configs
- Generate an initrd – dracut -f -v /boot/initrd $(uname -r)
- Append ‘initramfs initrd 0x01f00000’ to /boot/config.txt
- Modify /boot/cmdline.txt to read initrd=0x01f00000 after root=/dev/…. and before rootfstype=ext4
- Reboot as a test. Note that your boot time will go from about 5-10 seconds to upwards of a minute or so. You will see the Raspberry Pi splash screen for about 5 seconds as opposed to .5 or 1 second before. This is because the Pi now needs to load the 26MB initrd in to memory before continuing
- If it comes back up then you can move the file system now
- Edit /etc/fstab and change noatime for / to be ro,noatime
- Reboot
- yum install -y lvm2
- fdisk /dev/mmcblk0
- Create a new partition and exit
- Reboot
- pvcreate /dev/mmcblk0p4
- vgcreate root /dev/mmcblk0p4
- lvcreate –name=”lv_root” -l 45%FREE root <—- more on this later
- mkdir /mnt/new
- mount /dev/mapper/root/lv_root /mnt/new
- Copy the file system: tar -cvpf – –one-file-system –acls –xattrs –selinux / | tar xpf – -C /mnt/new/
- Edit /boot/cmdline.txt root= to be root=/dev/mapper/root-lv_root
- Reboot