KanoComputing / kano-burners

SD Card burner for OSX
GNU General Public License v2.0
12 stars 11 forks source link

Kano Burner fails to cope with Formatted SD Cards #52

Open wibbit opened 9 years ago

wibbit commented 9 years ago

I'm in the process of testing kano burner on a Fedora 21 system, and ran in to an issue relating to the unmounting of the media once the image has been downloaded.

The SD card in question has two partitions, as listed below.

I'm happy for these both to be wiped.

Device Boot Start End Sectors Size Id Type /dev/mmcblk0p1 8192 204800 196609 96M c W95 FAT32 (LBA) /dev/mmcblk0p2 221184 5005311 4784128 2.3G 83 Linux

When attempting to use kano burner, I get the following error.

Preparing /dev/mmcblk0 for burning.. ran: [fdisk -l | grep '/dev/mmcblk0[0-9][0-9]*' | awk '{print $1}'] 0 ran: [umount /dev/mmcblk0] 32 [ERROR] umount: /dev/mmcblk0: not mounted

At the time the two partitions were mounted.

/dev/mmcblk0p2 on /run/media/furlongd/rootfs type ext4 (rw,nosuid,nodev,relatime,seclabel,data=ordered,uhelper=udisks2) /dev/mmcblk0p1 on /run/media/furlongd/kanux-1.3.3 type vfat (rw,nosuid,nodev,relatime,uid=1000,gid=1000,fmask=0022,dmask=0077,codepage=437,iocharset=ascii,shortname=mixed,showexec,utf8,flush,errors=remount-ro,uhelper=udisks2)

Looking at the code, i think the issue is the following line.

cmd = "fdisk -l | grep '%s[0-9][0-9]*' | awk '{print $1}'" % disk_id

That does not pick up on the 'p' in the device name indicating a particular partition, this appears to be the new format that fedora at least is adopting.

Re-formatting the disk with a single partition appears to fix the issue.

Updating the partition string alone does not help, as it still tries to unmount the parent device, which is not mounted (and at least on RHEL variants never would be when there are partitions).

So the following worked for me, but it's probably far from ideal.

def unmount_disk(disk_id):
    # to unmount an entire disk, we first need to unmount all it's volumes
    unmount_volumes(disk_id)

#    # now we can safely unmount the disk
#    cmd = 'umount {}'.format(disk_id)
#    _, error, return_code = run_cmd(cmd)
#    if not return_code:
#        debugger('disk {} successfully unmounted'.format(disk_id))
#    else:
#        debugger('[ERROR] ' + error.strip('\n'))
#        raise unmount_error

def unmount_volumes(disk_id):
    # all volumes on a disk have an index attached e.g. /dev/sdb1, /dev/sdb2
    cmd = "fdisk -l | grep '%sp[0-9][0-9]*' | awk '{print $1}'" % disk_id
    output, _, _ = run_cmd(cmd)

    # it may also happen that the disk does not have volumes
    # in which case the loop below won't do anything
    for volume in output.splitlines():
        cmd = 'umount {}'.format(volume)
        _, error, return_code = run_cmd(cmd)
        if not return_code:
            debugger('volume {} successfully unmounted'.format(volume))
        else:
            debugger('[ERROR] ' + error.strip('\n'))
Ealdwulf commented 9 years ago

Thanks for reporting this!

On 19 May 2015 at 22:28, wibbit notifications@github.com wrote:

I'm in the process of testing kano burner on a Fedora 21 system, and ran in to an issue relating to the unmounting of the media once the image has been downloaded.

The SD card in question has two partitions, as listed below.

I'm happy for these both to be wiped.

Device Boot Start End Sectors Size Id Type /dev/mmcblk0p1 8192 204800 196609 96M c W95 FAT32 (LBA) /dev/mmcblk0p2 221184 5005311 4784128 2.3G 83 Linux

When attempting to use kano burner, I get the following error.

Preparing /dev/mmcblk0 for burning.. ran: [fdisk -l | grep '/dev/mmcblk0[0-9][0-9]*' | awk '{print $1}'] 0 ran: [umount /dev/mmcblk0] 32 [ERROR] umount: /dev/mmcblk0: not mounted

At the time the two partitions were mounted.

/dev/mmcblk0p2 on /run/media/furlongd/rootfs type ext4 (rw,nosuid,nodev,relatime,seclabel,data=ordered,uhelper=udisks2) /dev/mmcblk0p1 on /run/media/furlongd/kanux-1.3.3 type vfat (rw,nosuid,nodev,relatime,uid=1000,gid=1000,fmask=0022,dmask=0077,codepage=437,iocharset=ascii,shortname=mixed,showexec,utf8,flush,errors=remount-ro,uhelper=udisks2)

Looking at the code, i think the issue is the following line.

cmd = "fdisk -l | grep '%s[0-9][0-9]*' | awk '{print $1}'" % disk_id

That does not pick up on the 'p' in the device name indicating a particular partition, this appears to be the new format that fedora at least is adopting.

Re-formatting the disk with a single partition appears to fix the issue.

Updating the partition string does not help, as it still tries to unmount the parent device, which is not mounted (and at least on RHEL variants never would be).

cmd = "fdisk -l | grep '%sp[0-9][0-9]*' | awk '{print $1}'" % disk_id

— Reply to this email directly or view it on GitHub https://github.com/KanoComputing/kano-burners/issues/52.

wibbit commented 9 years ago

No Problem.

I'll have a look to see the best way in fedora world, to detect and unmount the device, though I fear my coding is beyond zilch, so I'll not be able to provide much assistance there.

Doug

On 20 May 2015 at 10:24, Alex Burr notifications@github.com wrote:

Thanks for reporting this!

On 19 May 2015 at 22:28, wibbit notifications@github.com wrote:

I'm in the process of testing kano burner on a Fedora 21 system, and ran in to an issue relating to the unmounting of the media once the image has been downloaded.

The SD card in question has two partitions, as listed below.

I'm happy for these both to be wiped.

Device Boot Start End Sectors Size Id Type /dev/mmcblk0p1 8192 204800 196609 96M c W95 FAT32 (LBA) /dev/mmcblk0p2 221184 5005311 4784128 2.3G 83 Linux

When attempting to use kano burner, I get the following error.

Preparing /dev/mmcblk0 for burning.. ran: [fdisk -l | grep '/dev/mmcblk0[0-9][0-9]*' | awk '{print $1}'] 0 ran: [umount /dev/mmcblk0] 32 [ERROR] umount: /dev/mmcblk0: not mounted

At the time the two partitions were mounted.

/dev/mmcblk0p2 on /run/media/furlongd/rootfs type ext4 (rw,nosuid,nodev,relatime,seclabel,data=ordered,uhelper=udisks2) /dev/mmcblk0p1 on /run/media/furlongd/kanux-1.3.3 type vfat

(rw,nosuid,nodev,relatime,uid=1000,gid=1000,fmask=0022,dmask=0077,codepage=437,iocharset=ascii,shortname=mixed,showexec,utf8,flush,errors=remount-ro,uhelper=udisks2)

Looking at the code, i think the issue is the following line.

cmd = "fdisk -l | grep '%s[0-9][0-9]*' | awk '{print $1}'" % disk_id

That does not pick up on the 'p' in the device name indicating a particular partition, this appears to be the new format that fedora at least is adopting.

Re-formatting the disk with a single partition appears to fix the issue.

Updating the partition string does not help, as it still tries to unmount the parent device, which is not mounted (and at least on RHEL variants never would be).

cmd = "fdisk -l | grep '%sp[0-9][0-9]*' | awk '{print $1}'" % disk_id

Reply to this email directly or view it on GitHub https://github.com/KanoComputing/kano-burners/issues/52.

Reply to this email directly or view it on GitHub https://github.com/KanoComputing/kano-burners/issues/52#issuecomment-103821251 .