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/sdae
resizepart PART_NUMBER END
quit
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/sdae
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sdae 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/sdae2
VG Name centos_4602c
PV Size 118.24 GiB / not usable 3.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 30269
Free PE 0
Allocated PE 30269
PV 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 found
Physical volume "/dev/sdae2" changed
1 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/sdae2
VG Name centos_4602c
PV Size <475.84 GiB / not usable 3.25 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 121813
Free PE 91544
Allocated PE 30269
PV UUID yvHO6t-cYHM-CCCm-2hOO-mJWf-6NUI-zgxzwc
# vgdisplay
--- Volume group ---
VG Name centos_4602c
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 6
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 3
Max PV 0
Cur PV 2
Act PV 2
VG Size <475.93 GiB
PE Size 4.00 MiB
Total PE 121838
Alloc PE / Size 30269 / <118.24 GiB
Free PE / Size 91569 / 357.69 GiB
VG UUID ORcp2t-ntwQ-CNSX-NeXL-Udd9-htt9-kLfvRc
# lvextend -l +91569 /dev/centos_4602c/root
Size 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/root
meta-data=/dev/mapper/centos_4602c-root isize=512 agcount=4, agsize=3276800 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=13107200, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=6400, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 13107200 to 106873856
Verify the results
Note that the c-root LVM partition is now 408GB.
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos_4602c-root 408G 2.4G 406G 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
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