LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   usbimg2disk.sh issue in -current / 14.1 (https://www.linuxquestions.org/questions/slackware-14/usbimg2disk-sh-issue-in-current-14-1-a-4175559701/)

MarcT 11-23-2015 04:24 PM

usbimg2disk.sh issue in -current / 14.1
 
Hello folks,

I was trying to make a bootable USB stick containing the 64bit kernel from -current, using a 64bit Slackware 14.1 install.

It works fine & boots OK if I dd the usbboot.img straight to the stick, but the usbimg2disk.sh script (from slackware64-current/usb-and-pxe-installers) fails.

From looking at the script, "fdisk" is used to partition the stick, then "sfdisk" is used to set a partition active (bootable).

It seems as if "sfdisk" does not like the partition table previously made by Slackware's "fdisk".


Code:

root@anvil:/home/marc/LinuxStuff/slackware/slackware64-current/usb-and-pxe-installers# sh usbimg2disk.sh -i ./usbboot.img -o /dev/sdd -f

# We are going to format and use this device - '/dev/sdd':
# Vendor : USB2.0 
# Model  : Flash Disk     
# Size  : 1000 MB
#
# FDISK OUTPUT:
#
# Disk /dev/sdd: 1048 MB, 1048576000 bytes
# 13 heads, 47 sectors/track, 3351 cylinders, total 2048000 sectors
# Units = sectors of 1 * 512 = 512 bytes
# Sector size (logical/physical): 512 bytes / 512 bytes
# I/O size (minimum/optimal): 512 bytes / 512 bytes
# Disk identifier: 0x29a3e829
#
# Device Boot      Start        End      Blocks  Id  System
# /dev/sdd1            2048    2047999    1022976    b  W95 FAT32

***                                                      ***
*** If this is the wrong drive, then press CONTROL-C now! ***
***                                                      ***
Or press ENTER to continue:
--- Formatting /dev/sdd with VFAT partition label 'USBSLACKINS'...
--- Last chance! Press CTRL-C to abort!
Or press ENTER to continue:
--- Available free space on the the USB drive is 1020960 KB
--- Required free space for installer: 44256 KB
--- Copying boot files to the USB drive...
--- Cleaning up the staging area...
--- Making the USB drive '/dev/sdd' bootable...
*** usbimg2disk.sh FAILED at line 470 ***
--- Cleaning up the staging area...
umount2: No such file or directory
umount: /mnt/img.RQFVVX: not found

Line 470 tries to make the partition bootable. If I run the line by hand:

Code:

root@anvil:~# echo ',,,*' | /sbin/sfdisk /dev/sdd -N1
Checking that no-one is using this disk right now ...
OK

Disk /dev/sdd: 1017 cylinders, 33 heads, 61 sectors/track
Old situation:
sfdisk: Warning: The partition table looks like it was made
  for C/H/S=*/13/47 (instead of 1017/33/61).
For this listing I'll assume that geometry.

Units = cylinders of 312832 bytes, blocks of 1024 bytes, counting from 0

  Device Boot Start    End  #cyls    #blocks  Id  System
/dev/sdd1          3+  3351-  3349-  1022976    b  W95 FAT32
sfdisk:                start: (c,h,s) expected (3,4,28) found (1,0,36)

sfdisk:                end: (c,h,s) expected (1023,12,47) found (1017,12,47)

/dev/sdd2          0      -      0          0    0  Empty
/dev/sdd3          0      -      0          0    0  Empty
/dev/sdd4          0      -      0          0    0  Empty
Warning: given size (1017) exceeds max allowable size (1016)
sfdisk: bad input

Anyhow, I found "parted" can set the active partition correctly, so here's a simple diff:
Code:

--- usbimg2disk.sh      2015-11-10 17:53:14.000000000 +0000
+++ /tmp/usbimg2disk.sh 2015-11-23 21:52:32.200632930 +0000
@@ -148,7 +148,7 @@
  fi
 
  # Set the bootable flag for the first partition:
-  echo ',,,*' | /sbin/sfdisk $USBDRV -N1
+  /usr/sbin/parted -s $USBDRV set 1 boot on
 }
 
 # Parse the commandline parameters:


After this I can successfully make a bootable USB stick. It booted OK on the one machine I tried. Will try a few more.

Marc

WLD 11-29-2015 08:20 PM

Does it run partprobe after creating the new partition table? Maybe that would make a difference if it's not doing it.

ckrzen 11-30-2015 02:39 PM

I ran the following to make my usb stick ready before running the usbimg2disk.sh script:

# cfdisk -z /dev/XXX # that is the cfdisk command, not the cgdisk command. replace XXX with your device name(sdb, sdd, etc.).

This opens the partition editor with a blank slate. Pick 'dos' for the label type if using the newest versions that support GPT, etc.

Then just write-out a new blank table. The usbimg2disk script will partition it and format for you.

Hope that helps.

MarcT 11-30-2015 03:54 PM

I don't think partprobe is needed. fdisk automatically re-reads the partition table.
I believe the issue is fdisk creates a partition table with a CHS geometry that sfdisk doesn't like.

MarcT 01-13-2016 09:43 AM

Retested with 14.2 beta (and a different USB stick) and the issue with usbimg2disk.sh remains.

Code:

root@anvil:/home/marc/LinuxStuff/slackware/slackware64-current/usb-and-pxe-installers# sh usbimg2disk.sh -f -i /home/marc/LinuxStuff/slackware/slackware64-current/usb-and-pxe-installers/usbboot.img -L Slack14.2B -o /dev/sdd

# We are going to format and use this device - '/dev/sdd':
# Vendor : SanDisk
# Model  : Cruzer         
# Size  : 7633 MB
#
# FDISK OUTPUT:
#
# Disk /dev/sdd: 8004 MB, 8004304896 bytes
# 212 heads, 46 sectors/track, 1603 cylinders, total 15633408 sectors
# Units = sectors of 1 * 512 = 512 bytes
# Sector size (logical/physical): 512 bytes / 512 bytes
# I/O size (minimum/optimal): 512 bytes / 512 bytes
# Disk identifier: 0x8af20759
#
# Device Boot      Start        End      Blocks  Id  System
# /dev/sdd1            2048    15633407    7815680    b  W95 FAT32

***                                                      ***
*** If this is the wrong drive, then press CONTROL-C now! ***
***                                                      ***
Or press ENTER to continue:
--- Formatting /dev/sdd with VFAT partition label 'Slack14.2B'...
--- Last chance! Press CTRL-C to abort!
Or press ENTER to continue:
--- Available free space on the the USB drive is 7800424 KB
--- Required free space for installer: 46240 KB
--- Copying boot files to the USB drive...
--- Cleaning up the staging area...
--- Making the USB drive '/dev/sdd' bootable...
*** usbimg2disk.sh FAILED at line 470 ***
--- Cleaning up the staging area...
umount2: No such file or directory
umount: /mnt/img.uhQtua: not found


The problem is caused by "sfdisk" (which is used in line 470 to make a partition active), which does not like the partition table created by "fdisk" on line 101.

Code:

root@anvil:/home/marc/LinuxStuff/slackware/slackware64-current/usb-and-pxe-installers# echo ',,,*' | /sbin/sfdisk /dev/sdd -N1
Checking that no-one is using this disk right now ...
OK

Disk /dev/sdd: 1020 cylinders, 247 heads, 62 sectors/track
Old situation:
sfdisk: Warning: The partition table looks like it was made
  for C/H/S=*/212/46 (instead of 1020/247/62).
For this listing I'll assume that geometry.

Units = cylinders of 4993024 bytes, blocks of 1024 bytes, counting from 0

  Device Boot Start    End  #cyls    #blocks  Id  System
/dev/sdd1          0+  1603-  1603-  7815680    b  W95 FAT32
sfdisk:                start: (c,h,s) expected (0,44,25) found (0,33,3)

sfdisk:                end: (c,h,s) expected (1023,211,46) found (1020,211,46)

/dev/sdd2          0      -      0          0    0  Empty
/dev/sdd3          0      -      0          0    0  Empty
/dev/sdd4          0      -      0          0    0  Empty
Warning: given size (1021) exceeds max allowable size (1020)
sfdisk: bad input


The patch in the first post fixes this issue by using "parted" to set the active partition instead of sfdisk (but creates a dependency on parted being installed).
Alternatively this patch fixes the issue using by using fdisk to set the active partition:

Code:

--- usbimg2disk.sh      2015-11-10 17:53:14.000000000 +0000
+++ /tmp/usbimg2disk.sh 2016-01-13 15:37:27.128093683 +0000
@@ -148,7 +148,15 @@
  fi
 
  # Set the bootable flag for the first partition:
-  echo ',,,*' | /sbin/sfdisk $USBDRV -N1
+  # Temporarily accept errors (so that we can examine them):
+  set +e
+  /sbin/fdisk $USBDRV <<EOF
+a
+1
+w
+EOF
+  # Fail on errors again:
+  set -e
 }
 
 # Parse the commandline parameters:

Can this be applied before -current becomes 14.2 GA?


All times are GMT -5. The time now is 04:28 PM.