Bug 959181 - fatresize: SD card resize fails due to incorrect /dev/mmcblk* path
fatresize: SD card resize fails due to incorrect /dev/mmcblk* path
Status: RESOLVED FIXED
Classification: openSUSE
Product: openSUSE Distribution
Classification: openSUSE
Component: Other
Leap 42.3
Other Other
: P3 - Medium : Normal (vote)
: ---
Assigned To: Sebastian Parschauer
E-mail List
https://github.com/ya-mouse/fatresize...
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2015-12-15 13:21 UTC by David Disseldorp
Modified: 2019-12-26 16:55 UTC (History)
4 users (show)

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments
fatresize: Fix getting device name from partition name (1.35 KB, patch)
2017-12-03 15:45 UTC, Sebastian Parschauer
Details | Diff
fatresize: Fix getting device name from partition name (1.91 KB, patch)
2017-12-19 17:44 UTC, Sebastian Parschauer
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Disseldorp 2015-12-15 13:21:45 UTC
When resizing an SD card FAT filesystem via YaST partitioner, I encountered the error:
  fatresize '/dev/mmcblk0p1'
  Error: Could not stat device /dev/mmcblk0p - No such file or directory.

fatresize incorrectly assumes that a base /dev/ path for a given partition can be obtained by stripping the trailing numeric suffix from the partition /dev path. Such an assumption works for /dev/sdX# paths but not for SD cards, which are assigned /dev/mmcblkXp# paths.
Comment 2 Hans-Peter Jansen 2017-08-13 18:48:55 UTC
I've no business with fatresize in any way.
Comment 3 Chenzi Cao 2017-09-19 11:25:40 UTC
Hi Gertjan, would you like taking a look at this issue please? Please feel free to reassign whenever necessary, thank you.
Comment 4 Gertjan Lettink 2017-09-19 11:31:29 UTC
Who assigned this bug to me and why?
Comment 5 Sebastian Parschauer 2017-10-25 10:30:02 UTC
I'm the right assignee for fatresize stuff as it is part of the parted package.

It is quite easy to find out:
> # zypper wp `which fatresize`
> $ osc bugowner -e parted

The expert partitioner is part of yast2-storage. So +CC Arvin Schnell.

Thanks for reporting! I'm able to reproduce this on Leap 42.3 now. Moving to Leap 42.3 as 42.1 is already dead.

I've tried to shrink my FS on a 32GB SD card to 5GB. YaST called this:

> # /usr/sbin/fatresize '/dev/mmcblk0p1' 5245221
> Error: Could not stat device /dev/mmcblk0p - No such file or directory.
> ped_device_get failed

I'll work on this.
Comment 6 Sebastian Parschauer 2017-10-25 11:02:13 UTC
fatresize 0.1 included with parted must be ancient if version 1.0.2 at
> https://sourceforge.net/projects/fatresize/files/fatresize/
is from 2005 already.

The project seems to be dead. Everybody but us forks version 1.0.2 and applies custom patches on top but usage is different.

Shouldn't be too hard to support the old usage with new fatresize with a custom patch.

@Arvin: Can fatresize be replaced with something different? Can we upgrade to version 1.0.2 at least? Should I create a Fate for this? TIA
Comment 7 Sebastian Parschauer 2017-10-25 11:12:54 UTC
Looks like the original author created a version 1.0.3 last year and continues work on GitHub:
> https://github.com/ya-mouse/fatresize
Comment 8 Sebastian Parschauer 2017-10-25 12:53:02 UTC
Latest upstream at commit 46cf019fe771 is also affected. 

> # ./fatresize -s 5245221 /dev/mmcblk0p1
> fatresize 1.0.3 ()
> Error: Could not stat device /dev/mmcblk0p - No such file or directory.

I had to remove man page auto-generation to make it compile as it fails on Leap 42.3 with our docbook packages.

Reported to upstream at: https://github.com/ya-mouse/fatresize/issues/2
Comment 9 Arvin Schnell 2017-10-25 17:41:08 UTC
(In reply to Sebastian Parschauer from comment #6)

> @Arvin: Can fatresize be replaced with something different? Can we upgrade
> to version 1.0.2 at least? Should I create a Fate for this? TIA

Using another command in upcoming releases (including SLE 15) is no problem
for me. We just have to coordinate so that "fatresize" and YaST are updated
at the same time. I do not need a feature request for that.
Comment 10 Sebastian Parschauer 2017-10-27 10:07:32 UTC
Only internal SD card readers like the one in my Lenovo Thinkpad X250 laptop are affected.

Possible workaround: Use a USB SD card reader presenting SCSI devices to the OS.
Comment 11 Sebastian Parschauer 2017-12-03 13:49:37 UTC
I've used my leisure time for this as I wouldn't get enough priority for this otherwise.

Here is the fix for upstream:
> https://github.com/ya-mouse/fatresize/pull/4
Comment 12 Sebastian Parschauer 2017-12-03 15:45:38 UTC
Created attachment 751168 [details]
fatresize: Fix getting device name from partition name

Backport for Leap 42.3 and SLES12-SP3.
Comment 13 Sebastian Parschauer 2017-12-18 07:00:21 UTC
This is queued in home:sparschauer:branches:Base:System/parted together with the upgrade to 1.0.3. I've reworked it again to use platform independent ped_device_get() instead of POSIX open().

What still does not work is partition guessing when providing the disk device path. But I think we can live with that as YaST should always provide a partition path.

# fatresize -i /dev/sdb
fatresize 1.0.3 ()
FAT: fat32
...

Can't get partition number. /dev/sdb1 is assumed.

# fatresize -i /dev/mmcblk0
fatresize 1.0.3 ()
You must specify exactly one existing device.

Partition number 0 and disk device /dev/mmcblk is assumed.
Comment 14 Sebastian Parschauer 2017-12-19 17:44:21 UTC
Created attachment 753712 [details]
fatresize: Fix getting device name from partition name

Updated patch backport for fatresize 0.1. This one uses ped_device_get() instead of open() now. We stick to version 0.1 in SLE15 as version 1.0.3 is plain too unstable and behaves differently.

Tested with YaST against an SD card in internal SD card reader (/dev/mmcblk0p1) and external USB SD card reader (/dev/sdb1). Works absolutely the same way now.
Comment 16 Sebastian Parschauer 2017-12-19 18:16:55 UTC
@maint-coord: Please tag for parted SLE12-SP3 maintenance. TIA
Comment 17 Thomas Göttlicher 2017-12-20 11:08:15 UTC
(In reply to Sebastian Parschauer from comment #16)
> @maint-coord: Please tag for parted SLE12-SP3 maintenance. TIA
Done. Thanks for the heads-up.
Comment 18 Sebastian Parschauer 2017-12-29 22:41:28 UTC
Merged upstream:
> https://github.com/ya-mouse/fatresize/commit/cf12400b5231e8a2eafc18c81428da618f741bb6

v1.0.4 has been released with all my fixes merged at upstream by now.

This is also in SLE15 already. So closing as fixed.
Comment 20 Swamp Workflow Management 2019-10-22 17:00:40 UTC
SUSE-RU-2019:2741-1: An update that has 9 recommended fixes can now be installed.

Category: recommended (moderate)
Bug References: 1023818,1032562,1056508,1078820,1081547,1092327,1104667,959181,969165
CVE References: 
Sources used:
SUSE CaaS Platform 3.0 (src):    parted-3.1-35.3.17

NOTE: This line indicates an update has been released for the listed product(s). At times this might be only a partial fix. If you have questions please reach out to maintenance coordination.