Installing Red Hat Linux in a M.2 that crashes the installer
Few months ago I encountered with a problem with RHEL installer and some of the M.2 drives.
I’ve productized my Product, to be released with M.2 booting SATA drives of 128GB.
The procedure for preparing the Servers (90 and 60 drives, Cold Storage) was based on the installation of RHEL in the M.2 128GB drive. Then the drives are cloned.
Few days before mass delivery the company request to change the booting M.2 drives for others of our own, 512 GB drives.
I’ve tested many different M.2 drives and all of them were slightly different.
Those 512 GB M.2 drives had one problem… Red Hat installer was failing with a python error.
We were running out of time, so I decided to clone directly from the 128GB M.2 working card, with everything installed, to the 512 GB card. Doing that is so easy as booting with a Rescue Linux USB disk, and then doing a dd from the 128GB drive to the 512GB drive.
Booting with a live USB system is important, as Filesystem should not be mounted to prevent corruption when cloning.
Then, the next operation would be booting the 512 GB drive and instructing Linux to claim the additional space.
Here is the procedure for doing it (note, the OS installed in the M.2 was CentOS in this case):
Determine the device that needs to be operated on (this will usually be the boot drive); in this example it is /dev/sdae
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos_4602c-root 50G 2.4G 47G 1% /
devtmpfs 16G 0 16G 0% /dev
tmpfs 16G 0 16G 0% /dev/shm
tmpfs 16G 395M 16G 3% /run
tmpfs 16G 0 16G 0% /sys/fs/cgroup
/dev/sdae1 1014M 146M 869M 15% /boot
/dev/mapper/centos_4602c-home 57G 33M 57G 1% /home
tmpfs 3.2G 0 3.2G 0% /run/user/0
logs 68G 7.4M 68G 1% /logs
mysql 481G 128K 481G 1% /mysql
N58-C3-D16-P3-S1 491T 334G 490T 1% /N58-C3-D16-P3-S1
Extend the OS partition using Parted
# parted /dev/sdaeresizepart PART_NUMBER ENDquit
Where:
- PART_NUMBER: Is the partition number obtained from the “print” command
- END: This is the end of the drive; for example, for a 50GB drive, enter 50000
Examining the LVM Partitions
The centos_4602c-root LVM partition is the one we want to extend.
# lsblk /dev/sdaeNAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTsdae 65:224 0 477G 0 disk├─sdae1 65:225 0 1G 0 part /boot└─sdae2 65:226 0 475.9G 0 part├─centos_4602c-root 253:0 0 50G 0 lvm /├─centos_4602c-swap 253:1 0 11.9G 0 lvm [SWAP]└─centos_4602c-home 253:2 0 56.3G 0 lvm /home
Using LVM Commands
The following commands will:
- Display the LVM volumes on the system
- Resize a volume (device)
- Re-display the updated LVM volumes
- Extend the desired LVM partition (lvextend command)
# pvdisplay/dev/sdbm: open failed: No medium found/dev/sdbn: open failed: No medium found/dev/sdbj: open failed: No medium found/dev/sdbk: open failed: No medium found/dev/sdbl: open failed: No medium found--- Physical volume ---PV Name /dev/sdae2VG Name centos_4602cPV Size 118.24 GiB / not usable 3.00 MiBAllocatable yes (but full)PE Size 4.00 MiBTotal PE 30269Free PE 0Allocated PE 30269PV UUID yvHO6t-cYHM-CCCm-2hOO-mJWf-6NUI-zgxzwc
# pvresize /dev/sdae2/dev/sdbm: open failed: No medium found/dev/sdbn: open failed: No medium found/dev/sdbj: open failed: No medium found/dev/sdbk: open failed: No medium found/dev/sdbl: open failed: No medium foundPhysical volume "/dev/sdae2" changed1 physical volume(s) resized or updated / 0 physical volume(s) not resized
# pvdisplay/dev/sdbm: open failed: No medium found/dev/sdbn: open failed: No medium found/dev/sdbj: open failed: No medium found/dev/sdbk: open failed: No medium found/dev/sdbl: open failed: No medium found--- Physical volume ---PV Name /dev/sdae2VG Name centos_4602cPV Size <475.84 GiB / not usable 3.25 MiBAllocatable yesPE Size 4.00 MiBTotal PE 121813Free PE 91544Allocated PE 30269PV UUID yvHO6t-cYHM-CCCm-2hOO-mJWf-6NUI-zgxzwc
# vgdisplay--- Volume group ---VG Name centos_4602cSystem IDFormat lvm2Metadata Areas 2Metadata Sequence No 6VG Access read/writeVG Status resizableMAX LV 0Cur LV 3Open LV 3Max PV 0Cur PV 2Act PV 2VG Size <475.93 GiBPE Size 4.00 MiBTotal PE 121838Alloc PE / Size 30269 / <118.24 GiBFree PE / Size 91569 / 357.69 GiBVG UUID ORcp2t-ntwQ-CNSX-NeXL-Udd9-htt9-kLfvRc
# lvextend -l +91569 /dev/centos_4602c/rootSize of logical volume centos_4602c/root changed from 50.00 GiB (12800 extents) to <407.69 GiB (104369 extents).Logical volume centos_4602c/root successfully resized.
Extend the xfs file system to use the extended space
The xfs file system for the root partition will need to be extended to use the extra space; this is done using the xfs_grow command as shown below.
# xfs_growfs /dev/centos_4602c/rootmeta-data=/dev/mapper/centos_4602c-root isize=512 agcount=4, agsize=3276800 blks= sectsz=512 attr=2, projid32bit=1= crc=1 finobt=0 spinodes=0data = bsize=4096 blocks=13107200, imaxpct=25= sunit=0 swidth=0 blksnaming =version 2 bsize=4096 ascii-ci=0 ftype=1log =internal bsize=4096 blocks=6400, version=2= sectsz=512 sunit=0 blks, lazy-count=1realtime =none extsz=4096 blocks=0, rtextents=0data blocks changed from 13107200 to 106873856
Verify the results
Note that the c-root LVM partition is now 408GB.
# df -hFilesystem Size Used Avail Use% Mounted on/dev/mapper/centos_4602c-root 408G 2.4G 406G 1% /devtmpfs 16G 0 16G 0% /devtmpfs 16G 0 16G 0% /dev/shmtmpfs 16G 395M 16G 3% /runtmpfs 16G 0 16G 0% /sys/fs/cgroup/dev/sdae1 1014M 146M 869M 15% /boot/dev/mapper/centos_4602c-home 57G 33M 57G 1% /hometmpfs 3.2G 0 3.2G 0% /run/user/0logs 68G 7.4M 68G 1% /logsmysql 481G 128K 481G 1% /mysqlN58-C3-D16-P3-S1 491T 334G 490T 1% /N58-C3-D16-P3-S1
So now we are able to clone directly from one 512GB to another.
You may be interested to take a look to the commands:
growpart
resize2fs
xfs_growfs (from xfsprogs package)
If you want to do this in an instance in Amazon, here is a very good documentation.
Rules for writing a Comment