You are not logged in.

#1 2012-11-06 15:13:00

toothandnail
Member
From: Oxfordshire, UK
Registered: 2012-05-05
Posts: 90

USB flash drive problem

I'm running a fully updated copy of Arch, using systemd, with Xfce as DE. Just hit an odd problem.

I needed a recent copy of SMS (Slackware-based server) on a flash drive. Its easy enough to prepare - explode the ISO to the flash drive, then run a script to make the flash drive bootable. Only trouble is, under Arch/Xfce it doesn't work - the script can't be executed.

I've done a bit of research, and it seems likely that udisks and polkit control this behaviour. While I can understand the extra security involved in setting things up this way, its annoying, and I would like to change it. However, so far my research hasn't helped much - I have no idea where or how to set things up the way I want.

The behaviour is more than a little inconsistent - I have no problem with scripts executed from a USB hard drive, just from flash drives.

Can anyone tell me what is needed to set the defaults to suit my use? In this instance, I was able to boot to Debian to run the script, but I don't expect to be able to do that for much longer.....

Paul.

Offline

#2 2012-11-07 00:49:43

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,168

Re: USB flash drive problem

What are you using to mount them? https://wiki.archlinux.org/index.php/Xf … le_Devices?


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#3 2012-11-07 15:17:21

DSpider
Member
From: Romania
Registered: 2009-08-23
Posts: 2,273

Re: USB flash drive problem

Study the install script. Maybe you can work around it. Or maybe there's another, simpler way to write it to the USB stick (e.g. using dd).


"How to Succeed with Linux"

I have made a personal commitment not to reply in topics that start with a lowercase letter. Proper grammar and punctuation is a sign of respect, and if you do not show any, you will NOT receive any help (at least not from me).

Offline

#4 2012-11-08 02:03:20

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,168

Re: USB flash drive problem

Or mount it as you would a USB hdd? (I am guessing these are getting mounted by root under /mnt with more privileges than the flash drives?)


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#5 2012-11-08 18:44:12

toothandnail
Member
From: Oxfordshire, UK
Registered: 2012-05-05
Posts: 90

Re: USB flash drive problem

cfr wrote:

Sorry to be slow - bad couple of days.

Yes, I'm following pretty much that route. The strange thing is that the problem does no appear on USB hard drives, but does on flash drives. So I think its got to be something in polkit that is setting it up that way. I just have no idea where to look to fix it.

Paul.

Offline

#6 2012-11-08 18:52:43

toothandnail
Member
From: Oxfordshire, UK
Registered: 2012-05-05
Posts: 90

Re: USB flash drive problem

DSpider wrote:

Study the install script. Maybe you can work around it. Or maybe there's another, simpler way to write it to the USB stick (e.g. using dd).

smile Well, I worked around it by running another distro. As to a workaround with Arch, I can't see one. dd isn't an option in this instance -  I'm not writing the iso to the flash drive, I'm writing the contents. That istn't a problem in itself, the problem is that I have to run the script to set the flash drive as bootable.

The script is as below:

#!/bin/bash

set -e
TARGET=""
MBR=""

# Find out which partition or disk are we using
MYMNT=$(cd -P $(dirname $0) ; pwd)
while [ "$MYMNT" != "" -a "$MYMNT" != "." -a "$MYMNT" != "/" ]; do
   TARGET=$(egrep "[^[:space:]]+[[:space:]]+$MYMNT[[:space:]]+" /proc/mounts | tail -n 1 | cut -d " " -f 1)
   if [ "$TARGET" != "" ]; then break; fi
   MYMNT=$(dirname "$MYMNT")
done

if [ "$TARGET" = "" ]; then
   echo "Can't find device to install to."
   echo "Make sure you run this script from a mounted device."
   exit 1
fi

if [ "$(cat /proc/mounts | grep "^$TARGET" | grep noexec)" ]; then
   echo "The disk $TARGET is mounted with noexec parameter, trying to remount..."
   mount -o remount,exec "$TARGET"
fi

MBR=$(echo "$TARGET" | sed -r "s/[0-9]+\$//g")
NUM=${TARGET:${#MBR}}
cd "$MYMNT"

clear
echo "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"
echo "                        Welcome to sms boot installer                         "
echo "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"
echo
echo "This installer will setup disk $TARGET to boot only SMS Installer."
if [ "$MBR" != "$TARGET" ]; then
   echo
   echo "Warning! Master boot record (MBR) of $MBR will be overwritten."
   echo "If you use $MBR to boot any existing operating system, it will not work"
   echo "anymore. Only sms will boot from this device. Be careful!"
fi
echo
echo "Press any key to continue, or Ctrl+C to abort..."
read junk
clear

echo "Flushing filesystem buffers, this may take a while..."
sync

# setup MBR if the device is not in superfloppy format
if [ "$MBR" != "$TARGET" ]; then
   echo "Setting up MBR on $MBR..."
   ./syslinux/lilo -S /dev/null -M $MBR ext # this must be here to support -A for extended partitions
   echo "Activating partition $TARGET..."
   ./syslinux/lilo -S /dev/null -A $MBR $NUM
   echo "Updating MBR on $MBR..." # this must be here because LILO mbr is bad. mbr.bin is from syslinux
   cat ./syslinux/mbr.bin > $MBR
fi

echo "Setting up boot record for $TARGET..."
./syslinux/syslinux -d syslinux $TARGET

echo "Disk $TARGET should be bootable now. Installation finished."

echo
echo "Read the information above and then press any key to exit..."
read junk

smile Apart from the immediate problem, I really don't like having that sort of control taken away from me - I find it much too reminiscent of Windows. So for future reference, I  would really like to know how to set things up to suit my usage, not someone else's idea of what my usage should be....

Paul.

Offline

#7 2012-11-08 19:02:06

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: USB flash drive problem

The script appears to just be a bunch of sanity checks and then it installs syslinux (and lilo somehow?).  I think you should just do this manually.  SMS is just a normal Linux fielsystem that is preloaded with stuffs, yeah?  I see no reason why doing a traditional bootloader installation would not work.

Offline

#8 2012-11-08 20:40:37

DSpider
Member
From: Romania
Registered: 2009-08-23
Posts: 2,273

Re: USB flash drive problem

toothandnail wrote:

Only trouble is, under Arch/Xfce it doesn't work - the script can't be executed.

"Doesn't work" isn't very descriptive. Does it say anything?

Maybe you need to run "sync" at the end, or copy a large-ish file (~100 MB) and then delete the file.

$ sync

"How to Succeed with Linux"

I have made a personal commitment not to reply in topics that start with a lowercase letter. Proper grammar and punctuation is a sign of respect, and if you do not show any, you will NOT receive any help (at least not from me).

Offline

#9 2012-11-08 20:43:40

anonymous_user
Member
Registered: 2009-08-28
Posts: 3,059

Re: USB flash drive problem

toothandnail wrote:

I'm not writing the iso to the flash drive, I'm writing the contents.

Why don't you write the ISO to your USB? The SMS ISO is bootable and runs as a LiveCD, nah?

Offline

#10 2012-11-09 08:40:48

toothandnail
Member
From: Oxfordshire, UK
Registered: 2012-05-05
Posts: 90

Re: USB flash drive problem

WonderWoofy wrote:

The script appears to just be a bunch of sanity checks and then it installs syslinux (and lilo somehow?).  I think you should just do this manually.  SMS is just a normal Linux fielsystem that is preloaded with stuffs, yeah?  I see no reason why doing a traditional bootloader installation would not work.

I may try that the next time it comes up. The odd thing is that the flash drive is running a standard Vfat file system, but when checked, it shows the Windows install batch file as executable, but does not show the install.sh as executable. And I cannot make install.sh executable, nor can I run it using:

bash ./install.sh

That option fails with an error regarding file permissions. So somewhere in the mix of udisk/polkit, a policy is saying that I cannot execute files on the flash drive. Which I find more than just a bit annoying....

Paul.

Offline

#11 2012-11-09 08:49:26

toothandnail
Member
From: Oxfordshire, UK
Registered: 2012-05-05
Posts: 90

Re: USB flash drive problem

DSpider wrote:
toothandnail wrote:

Only trouble is, under Arch/Xfce it doesn't work - the script can't be executed.

"Doesn't work" isn't very descriptive. Does it say anything?

Maybe you need to run "sync" at the end, or copy a large-ish file (~100 MB) and then delete the file.

$ sync

Sorry. As you say, doesn't work isn't very descriptive. To be more precise, the install script is not listed as executable (which is pretty strange on a Vfat file system). Looking at the files concerned, with is the attributes that they have:

fang@sirius:/var/run/media/fang/9FD5-3C9F$ ls -l usb*
-rwxr-xr-x 1 fang users 1685 Apr  8  2012 usbboot.bat
-rw-r--r-- 1 fang users 2239 Apr  8  2012 usbboot.sh

Since this is a vfat file system, all files would normally be showing as executable. However, the DOS batch file is, the Linux script isn't. Which means that something is manipulating the normal file system attributes. While this in no longer a problem (I booted to a Debian-based distro and ran the script from there), I want to know how to adjust the attributes that are presented in future.

Paul.

Offline

Board footer

Powered by FluxBB