I have just discovered a scenario where fdisk is safer/more useful than cfdisk, through the hard way.

Let's say a 40G hard drive /dev/hde has two primary partitions and 20G free space (as defined in /etc/fstab):
/dev/hde1: ext3 (10G) mounted on /mnt/dir1
/dev/hde2: ext3 (10G) mounted on /mnt/dir2


Now I want to extend /dev/hde2 to take up all the available space to make its size 30G.
So I do the following:
1) umount /dev/hde2
2) use cfdisk to delete /dev/hde2 partition
3) use cfdisk to create a new /dev/hde2 partition which takes up all the available space. And cfdisk shows its size as 30G.
4) mke2fs -j /dev/hde2
5) mount /dev/hde2
At this point, I run "df", it shows the /dev/hde2 is only 10G, the old size! At the same time, cfdisk swears it's 30G. Even a reboot cann't solve the problem.


What went wrong? I decided to repeat the step 1-5 , but using fdisk instead. Fdisk reports a warning on step 3, saying (sorry I don't remember the exact wording) the kernel is still holding the old partion table setting. Very revealing. Now my understanding (or rather guessing) is ,mke2fs relied on kernel to get the device size information (sure it does!), and it's 10G. Kernel was holding the partion information because /dev/hde1 is mounted.

The lesson is, before you make any change to a partition, make sure no partition from the same physical device is mounted. And use fdisk, not cfdisk (despite it's much more user-friendly).

-tk.




-- redhat-list mailing list unsubscribe mailto:[EMAIL PROTECTED] https://www.redhat.com/mailman/listinfo/redhat-list

Reply via email to