3

I have a VM running CentOS 6.3. LVM is not installed. From the VM side, I have increased the underlying disk from 15GB to 40GB, so I now need to expand the partition and file system.

I've managed to boot into "Rescue Mode" so no file systems are mounted. My problem occurres when trying to use parted's resize command.

[root@livedvd ~]# parted
(parted) print
Model: VMware Virtual disk (scsi)
Disk /dev/sda: 42.9GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number    Start    End     Size    Type     File system    Flags
 1        1049kB   269MB   268MB   primary  ext3           boot
 2        269MB    1880MB  1880MB  primary  linux-swap(v1) 
 3        1880MB   17.2GB  15.3GB  primary  ext4

(parted)

So I now try and expand the partition with:

(parted) resize 3 4366MB 35GB
WARNING: you are attempting to use parted to operate on (resize) a file system...
...
No Implmentation: Support for opening ext4 file systems is not implemented yet.
(parted)

Great! Is 6.3 that old! I have done a yum update, but it made no difference. The warning message goes on to say I should be using e2fsprogs. I tried resize2fs /dev/sda3, however, it states that "the filesystem is already 3735296 blocks long. Nothing to do". My understanding is this is for the file system. I have to expand the partition first.

I have also increase the memory from 1GB to 4GB so I am also trying to increase the linux-swap, hence the 4366MB value.

I found this site, referencing the "no implementation error" and suggesting I use cfdisk /dev/sda3. The post goes on to say this will delete the partition. I should then recreate it with resize2fs /dev/sda3. Not sure I like the sound of deleting partitions.

If anyone could point me in the right direction, I'd be post grateful for any pointers.

6
  • you use parted to remove and remake the partition THEN you can use resize2fs to make the filesystem fill it all.
    – JamesRyan
    Nov 13, 2014 at 16:08
  • GParted claims support for EXT4. They have a bootable release here. Nov 13, 2014 at 16:12
  • C6.3 is out of support; do you have an extremely good reason for not going to 6.6?
    – MadHatter
    Nov 13, 2014 at 16:14
  • Woter, please stop putting your salutations back in. jscott has already given you a clear pointer to the local etiquette: not only do we find their lack to be acceptable, we find an aggressive attempt to include them quite the opposite.
    – MadHatter
    Nov 13, 2014 at 16:25

3 Answers 3

3

I've never done this with parted, however I've done it with fdisk/resize2fs. Here's a link on how to do it:

http://geekpeek.net/resize-filesystem-fdisk-resize2fs/

Basically the jist of it is:

  1. Unmount the filesystem that you're resizing
  2. Delete the partition, and create a larger partition with the same first sector (All you're doing is deleting the reference in the partition table, not the actual partition, so it'll find the file system in the new larger partition)
  3. Extend the filesystem to fill the larger partition
  4. Remount the resized filesystem.
2
  • What Aaron Copley said works as well, GParted is a good utility if you have a GUI or if you can reboot into the GParted live CD(I'm not sure if your working with is a production server or not and weather it can go offline or not).
    – MVanOrder
    Nov 13, 2014 at 16:32
  • Thank you very much. That worked a treat. I was a little concerned about the "delete partition" bit, but as you say, it's just a reference.
    – woter324
    Nov 13, 2014 at 17:45
0

https://ubuntuforums.org/showthread.php?t=1389429

I solved this by doing the following with parted:

Run parted on your device: parted /dev/sdX
Change display unit to sectors: unit s
Print current partition table and note the start sector for your partition: p
Delete your partition (won't delete the data or filesystem): rm <number>
Recreate the partition with the starting sector from above: mkpart primary <start> <end>
Exit parted: quit
Check the filesystem: sudo e2fsck -f /dev/sdXX
Resize filesystem: sudo resize2fs /dev/sdXX
-1

For those running LVM do the following. If you aren't running LVM you should be. Run lvm all day long in a virtual environment here. I know it doesn't answer your question but it may help someone with LVM so here you go.

All you need to do to add space provided you aren't adding discs is to just run the following while it is online and mounted.

first run vgdisplay and if you have available free space

lvresize -L +10G /dev/VGname/LVname

then run resize2fs /dev/VGname/LVname

you are done.

1
  • The question specifically states that LVM is not being used. If you want to answer a different question, first ask it then post the answer, but first check to see if the question has already been asked.
    – austinian
    Dec 10, 2015 at 23:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .