Bug 621488

Summary: Can't add/remove partition on a disk with currently mounted other partitions
Product: [Fedora] Fedora Reporter: Kamil Páral <kparal>
Component: gpartedAssignee: Deji Akingunola <dakingun>
Status: CLOSED NEXTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: 13CC: dakingun, gedakc, sagarun
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2010-08-16 11:59:57 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Kamil Páral 2010-08-05 09:05:35 UTC
Description of problem:
I have a single disk device, /dev/sda. /dev/sda1 is my /boot, /dev/sda2 is my /, etc. I want to create a new partition /dev/sda7 in a free unallocated space at the end of my disk.

If I use gparted to create a new partition, it creates it but reports an error:

libparted messages:
WARNING: the kernel failed to re-read the partition table on /dev/sda (Device or resource busy).  As a result, it may not reflect all of your changes until after reboot.
WARNING: the kernel failed to re-read the partition table on /dev/sda (Device or resource busy).  As a result, it may not reflect all of your changes until after reboot.

The partition is created, but not seen by kernel.

When I try to format that partition to ext4 now, I receive another set of messages:

set partition type on /dev/sda7    FAILED
libparted messages:
WARNING: the kernel failed to re-read the partition table on /dev/sda (Device or resource busy).  As a result, it may not reflect all of your changes until after reboot.
WARNING: the kernel failed to re-read the partition table on /dev/sda (Device or resource busy).  As a result, it may not reflect all of your changes until after reboot.

The filesystem is not created.

I believe this problem is caused by using partprobe on a disk that currently has other locked (mounted) partitions. But it is perfectly possible to inform kernel about new/deleted partitions, you just can't use partprobe and must use addpart/delpart instead. On top of that, I'm pretty confident that gparted used to work in situations like this, it used to be possible to add new partition even on disk with other currently mounted partitions. It is not possible anymore.

I know I can boot from livecd to work around this issue, but that's not really the solution I would like to see.

Version-Release number of selected component (if applicable):
parted-2.1-8.fc13.x86_64
gparted-0.5.2-1.fc13.x86_64
pyparted-3.3-1.fc13.x86_64

How reproducible:
always

Steps to Reproduce:
1. Boot from system located somewhere on /dev/sda.
2. Try to add new partition to the same disk /dev/sda, using unallocated space is sufficient.
3. Try to format the new partition.
4. Watch it fail twice.
  
Actual results:
gparted can't be used on disks with some mounted partitions present - the most common case

Expected results:
quite the opposite

Additional info:
I tried to use parted and it reports the same error when removing partitions and kernel isn't informed neither, so I suspect it suffers from the same issues.

Comment 1 Curtis Gedak 2010-08-07 16:33:54 UTC
You are absolutely correct that GParted used to be able to add/remove partitions when other partitions were mounted.

The loss of this ability is due to a change in the libparted library in parted versions 2.0 through to 2.2 inclusive.  Parted 2.3 include a patch that re-enables the ability to inform the kernel of partition changes when other partitions are active/mounted.

The relevant patches can be found in the following links:

libparted: reenable use of BLKPG ioctls
http://git.debian.org/?p=parted/parted.git;a=commit;h=0e04d17386274fc218a9e6f9ae17d75510e632a3

libparted: improve BLKPG error checking
http://git.debian.org/?p=parted/parted.git;a=commit;h=7165951dfb584aae2901ac3f1a28fe3624667f19

These above patches are included the parted 2.3 release.  Hence if you use GParted with libparted 2.3, then you should once again be able to add/remove partitions when other partitions are active/mounted.

Comment 2 Kamil Páral 2010-08-09 07:17:02 UTC
Thanks for helpful reply, Curtis. I'll retest this in Fedora 14 using parted 2.3.

Comment 3 Kamil Páral 2010-08-16 11:59:57 UTC
It seems it is really fixed in parted 2.3. I tested it in Fedora 14 and everything seem to be working really well. Thanks, closing.

Comment 4 Arun S A G 2010-10-09 07:08:47 UTC
Any chances of back porting this patches to F-13?