How to Resize the Boot Disk on an old Red Hat Enterprise Linux-6 [Linux]
Red Hat Enterprise Linux 6 has long been at the end of its life. I mean ask yourself, do you know anyone who even uses RHEL-6 anymore? I know you should definitely not be using this, but if by some chance you are or were lucky enough to inherit one of those old school systems, I’m here to tell you a couple of steps that you can try, if you find yourself in the need to resize a boot volume.
Assumptions:
This scenario is based around a Red Hat Enterprise Linux 6 (RHEL-6) system running in Amazon AWS (Amazon Web Services), so I’m going to guess that you know your way around the AWS Console or CLI. These instructions do not apply to a more modern Linux operating system, as these newer systems have much better support and tools when it comes to resizing disks and volumes. This is only for those who are in the unfortunate state of having an old unsupported operating system. In this specific case, RHEL-6.
What you need:
You will need a secondary helper EC2 instance, we’ll call it: rhel6-helper.example.com
While the EC2 instance needings its boot disk resized, we’ll call it: rhel-needs-boot-disk-resize.example.com
DISCLAIMER:
Do this at your own risk! This is not a verified solution from Red Hat. This is more of a frugal, thrifty way of doing things. I recommend you do this on a crash and burn system before doing this in a production system. Most importantly, verify you have good snapshots/backups of your production system boot disks before any changes.
Got it? Great! Here’s a couple things that you can try if you find yourself stuck in a similar situation.
annotate the instance ID and its boot disk information:
Eg:
i-0b22a22eec53b9321
Volume: vol-049df61146c4d7901
Usually attached as: /dev/sda1
Using the AWS GUI or CLI, shut the instance down and increase the size of the boot disk.
Then power it back-on and SSH to the system to gather some more information using the fdisk command.
[rhel6-needs-boot-disk-resize ~]# fdisk -l
Disk /dev/xvda: 275 GB, 274877906944 bytes
...
...
Device? ? ? Boot? ? ? ? Start ? ? ? ? End? ? ? Blocks ? ? ? Id? System
/dev/xvda1 ? * ? ? ? ? ? 1? ? ? ? ? ? 16710? ? 134216704? ? 83? Linux
Annotate the Device, identified with a Boot asterisk.?
Shut the instance rhel6-needs-boot-disk-resize.example.com down and detach its boot disk.?
Now go to your helper EC2.
Do:
-------
Make sure parted and e2fsck are installed.
Do:
-------
Detach vol-049df61146c4d7901 from rhel6-needs-boot-disk-resize.example.com if not done already.
Do:
-------
Attach vol-049df61146c4d7901 to rhel6-helper.example.com as /dev/sdm (default)
[rhel6-helper ~]# fdisk -l
(identify the disk and volume to resize)
...
...
Disk /dev/xvdm: 275 GB, 274877906944 bytes
...
...
Device? ? ? Boot? ? ? Start ? ? ? ? End? ? ? Blocks? ? ? Id? System
/dev/xvdm1 ? * ? ? ? ? ? 1? ? ? ? ? 16710? ? 134216704 ? 83? Linux
[rhel6-helper ~]# parted /dev/xvdm
(use parted to work with the disk volume to resize)
...
...
Disk /dev/xvdm: 275GB
Sector size (logical/physical): 512B/512B
领英推荐
Partition Table: msdos
Number? Start ? End? ? Size ? Type ? ? File system? Flags
1? ? ? 1049kB? 137GB? 137GB? primary? ext4 ? ? ? ? boot
## use sector units
(parted) unit s ????????????????????????????????????????????????????????
(parted) print ??????????????????????????????????????????????????????????
...
...
Number? Start? End ? ? ? ? Size? ? ? ? Type ? ? File system? Flags
1? ? ? 2048s? 268435455s? 268433408s? primary? ext4 ? ? ? ? boot
## clear out partition
(parted) rm 1 ???
## make partition??????????????????????????????????????????????????????
(parted) mkpart primary 2048s 100%???????????????????????????????????????
(parted) print???????????????????????????????????????????????????????????
...
...
Number? Start? End ? ? ? ? Size? ? ? ? Type ? ? File system? Flags
1? ? ? 2048s? 536870911s? 536868864s? primary? ext4
## flag it as a boot partition
(parted) set 1 boot on ??????????????????????????????????????????????????
(parted) print ??????????????????????????????????????????????????????????
...
...
Number? Start? End ? ? ? ? Size? ? ? ? Type ? ? File system? Flags
1? ? ? 2048s? 536870911s? 536868864s? primary? ext4 ? ? ? ? boot
[rhel6-helper ~]# e2fsck -f /dev/xvdm1
...
...
/dev/xvdm1: 407386/8388608 files (5.7% non-contiguous), 29298778/33554176 blocks
Do:
Shut down EC2 then detach resized volume from rhel6-helper.example.com
Do:
Attach resized volume back to rhel6-needs-boot-disk-resize.example.com
Do:
Boot EC2 instance and SSH into rhel6-needs-boot-disk-resize.example.com
[rhel6-needs-boot-disk-resize ~]# fdisk -l
Disk /dev/xvda: 275 GB, 274877906944 bytes
...
...
Device? ? ? Boot? ? ? ? Start ? ? ? ? End ? ? ? Blocks? ? ? Id? System
/dev/xvda1 ? * ? ? ? ? ? 1? ? ? ? ? 33419 ? ? ? 268434432 ? 83? Linux
[rhel6-needs-boot-disk-resize ~]# resize2fs /dev/xvda1
...
...
[rhel6-needs-boot-disk-resize ~]# df -h
Filesystem? ? ? ? ? ? Size ? ? Used? ? Avail? ? Use% ? Mounted on
/dev/xvda1? ? ? ? ? ? 275G? 110G ? ? 165G ? 46% ? ? /
Hopefully, sections of this gave you a little bit of help with your RHEL-6 quest. If not, it will for sure help you completely destroy your system. Again, read to the end of any of these instructions before you attempt this. Don’t just wing it.