bzt
Posts: 555
Joined: Sat Oct 14, 2017 9:57 pm

Re: USB image writer

Sat Feb 29, 2020 3:33 pm

Dear Ernst,

I understand your problem.
Ernst wrote:there is no "User" language (at least under Win7)
All I can say is, the official documentation of GetUserDefaultLangID() says that there's is a user language in Windows, and the Control Panel has more Language and Region tabs unfortunately. According to the linked doc:
Returns the language identifier for the current user as set under Control Panel > Clock, Language, and Region > Change date, time, or number formats > Formats tab > Format dropdown.
That's what USBImager use, because localization always sets those (clock and number formats) for a particular language correctly. Try to set your date and number format to English, not German, that should do the trick.

Another solution for programs could be using locale names, but unfortunately those are not available for Windows XP only Vista and upwards. It would be better to simply have a LANG environment variable just like with the other operating systems, but there isn't. I'm really sorry about the inconvenience, and I'm open to your suggestions if setting the date and number format does not applicable for you for some reason. Maybe I could introduce a command line flag to turn translation off?

Cheers,
bzt

bzt
Posts: 555
Joined: Sat Oct 14, 2017 9:57 pm

Re: USB image writer

Sat Feb 29, 2020 4:25 pm

I've implemented the LANG environment variable for Windows too, but it doesn't work for me (here is a good description how to set environment variables, I've also tried "set LANG" from cmd.exe, but MinGW's getenv("LANG") just doesn't return it :-( ).

So I've provided another way for you to avoid language detection alltogether. Use

Code: Select all

usbimager.exe -Len
to force English language (or use "-Lde" to force German). You can create a .lnk shortcut and set the -L flag in the shortcut's "Target" field. After that whenever you click on that shortcut, it will start USBImager in English.

Cheers,
bzt

Ernst
Posts: 1331
Joined: Sat Feb 04, 2017 9:39 am
Location: Germany

Re: USB image writer

Sat Feb 29, 2020 4:45 pm

bzt wrote:
Sat Feb 29, 2020 3:33 pm
According to the linked doc:
Returns the language identifier for the current user as set under Control Panel > Clock, Language, and Region > Change date, time, or number formats > Formats tab > Format dropdown.
That's what USBImager use, because localization always sets those (clock and number formats) for a particular language correctly.
That is the exact problem: it is all about formats, not about the languages of the text in a display object.
bzt wrote:
Sat Feb 29, 2020 3:33 pm
Try to set your date and number format to English, not German, that should do the trick.
Unfortunately this affects the time format, my mind works internationally and gets a SEGFAULT on the display of AM/PM (and maybe on the date format set to MM/dd/yy instead of the proper dd.MM.yyyy format).

bzt wrote:
Sat Feb 29, 2020 3:33 pm
Maybe I could introduce a command line flag to turn translation off?
This would be an acceptable solution, but it would be more appropriate the other way around.
The road to insanity is paved with static ip addresses

Ernst
Posts: 1331
Joined: Sat Feb 04, 2017 9:39 am
Location: Germany

Re: USB image writer

Sat Feb 29, 2020 4:47 pm

bzt wrote:
Sat Feb 29, 2020 4:25 pm
I've implemented the LANG environment variable for Windows too, but it doesn't work for me (here is a good description how to set environment variables, I've also tried "set LANG" from cmd.exe, but MinGW's getenv("LANG") just doesn't return it :-( ).

So I've provided another way for you to avoid language detection alltogether. Use

Code: Select all

usbimager.exe -Len
to force English language (or use "-Lde" to force German). You can create a .lnk shortcut and set the -L flag in the shortcut's "Target" field. After that whenever you click on that shortcut, it will start USBImager in English.

Cheers,
bzt
To me that looks like a reasonable solution.

Thanks
Ernst
The road to insanity is paved with static ip addresses

bzt
Posts: 555
Joined: Sat Oct 14, 2017 9:57 pm

Re: USB image writer

Sat Feb 29, 2020 6:36 pm

Ernst wrote:
Sat Feb 29, 2020 4:45 pm
That is the exact problem: it is all about formats, not about the languages of the text in a display object.
But it is about language! GetUserDefaultLangID() returns language code for those settings! Something like "en_US" or "de_DE" in a 32 bit encoded value (you can check that by running "usbimager.exe -v"), and not the format string. Now why do you set this in a number format settings panel is beyond my comprehention...
Ernst wrote:Unfortunately this affects the time format, my mind works internationally and gets a SEGFAULT on the display of AM/PM (and maybe on the date format set to MM/dd/yy instead of the proper dd.MM.yyyy format).
Hahaha, you are wrong the correct format is yyyy-mm-dd :-D :-D :-D Okay, I can totally understand why don't you want English dates. Putting the day in the middle is a complete lack of any logic.
Ernst wrote:To me that looks like a reasonable solution.
Okay, I'm glad I've found a solution for you! Hopefully this is universal enough to solve other's potential issues with language as well.

Now I've also found GetUserDefaultUILanguage too (which was never returned by the search engine until now). This function should return exactly the same code as the LangID(), but for the Control Panel's Language tab. I could try to use this instead, it sounds much more like what I actually need anyway. (According to the linked doc, there should be a language option, but you say you don't have user language option on the Control Panel):
The user UI language determines the user interface language used for menus, dialog boxes, help files, and so forth. It can be set by the current user in the Language tab of the regional and language options portion of Control Panel.
If you don't mind, I'd like to give it a try tomorrow. If you can change the locale to German but keep the language in English with this, that would be the best. (I'll keep the command line option regardless)

EDIT: I've tried (under Win7). With GetUserDefaultUILanguage() it always returns the system language, and there's no way to change that from the Control Panel. I don't have a Language tab either. (Also missing from the screenshot below which I took from a Windows Help forum)

However if I use GetUserDefaultLangID(), then it returns the language set on the Control Panel > Region and Language > Formats > Format
Image
So I think I'll keep this version for now. You can set this "Format" to English, and then specify date formats differently (dd.mm.yyyy and 24 hours clock for example), that works too.

Cheers,
bzt
Last edited by bzt on Sat Feb 29, 2020 7:35 pm, edited 1 time in total.

User avatar
rpdom
Posts: 16961
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: USB image writer

Sat Feb 29, 2020 7:27 pm

bzt wrote:
Sat Feb 29, 2020 6:36 pm
Okay, I can totally understand why don't you want English dates. Putting the day in the middle is a complete lack of any logic.
Yes, but that's not the English date format. That's the American date format. We English use dd/mm/yy or dd/mm/yyyy usually. :D
Unreadable squiggle

bzt
Posts: 555
Joined: Sat Oct 14, 2017 9:57 pm

Re: USB image writer

Sat Feb 29, 2020 7:44 pm

rpdom wrote:
Sat Feb 29, 2020 7:27 pm
Yes, but that's not the English date format. That's the American date format. We English use dd/mm/yy or dd/mm/yyyy usually. :D
Oh, my mistake, sorry! You are right. I should have written American date format. I can't really follow, because the first thing I do with any English (or American) OS is to set all formats to ISO (which happens to be the same as my region's native format :-)) and keyboard layout to international, because that's what I'm used to.

Anyway the good news is, you can set the "Format" to a specific language, and then set the date and time formats individually.

Cheers,
bzt

User avatar
Greg Erskine
Posts: 139
Joined: Sat Sep 15, 2012 4:20 am

Re: USB image writer

Sat Feb 29, 2020 10:09 pm

bzt wrote:
Sat Feb 29, 2020 11:44 am
Greg Erskine wrote:
Sat Feb 29, 2020 10:46 am
Sounds like I haven't convinced you of my use case. lol.
No, but I've added the label regardless. Just remember you should not trust it, check the size, manufacturer's name and model strings too, that's my advice
Hi bzt,

Perfect thanks!
PCP_BOOT5.PNG
PCP_BOOT5.PNG (8.5 KiB) Viewed 1469 times
Thanks for the advise. Although I may sound a little naïve, I've been doing this stuff a long time. I suppose you might say I'm now at the stage where I am settled in my ways and don't like to change. This little addition means I can move on from Win32DiskImager without changing my process. :)

I am involved with the development of piCorePlayer, an extremely small music player based on TinyCore (10 seconds to write an image). What is great about your software as it is almost identical across all platforms, we only have to document the SD card creation process for our users once instead of 4 times.

regards
Greg
* Raspberry Pi is a trademark of the Raspberry Pi Foundation

bzt
Posts: 555
Joined: Sat Oct 14, 2017 9:57 pm

Re: USB image writer

Sun Mar 01, 2020 8:22 am

Thanks, Greg!
Greg Erskine wrote:
Sat Feb 29, 2020 10:09 pm
Thanks for the advise. Although I may sound a little naïve, I've been doing this stuff a long time. I suppose you might say I'm now at the stage where I am settled in my ways and don't like to change. This little addition means I can move on from Win32DiskImager without changing my process. :)
Welcome! I'm glad you liked it! You can always give a star to my gitlab repo :-)
Greg Erskine wrote:I am involved with the development of piCorePlayer, an extremely small music player based on TinyCore (10 seconds to write an image).
That's a great project you have! Haven't heard about it, but now I've googled it. I like that it entirely runs from a ramdisk which makes it extremely fast and kind to the SD card!
Greg Erskine wrote:What is great about your software as it is almost identical across all platforms, we only have to document the SD card creation process for our users once instead of 4 times.
Yeah, I made a great effort to make it identical. Maybe the UI's look-and-feel is different, but it has the same elements in the same positions across all platforms. And what's behind the scene actually compiled from the same source, or if it has platform-dependent part (like getting the drive's capacity or manufacturer) then the source implements exactly the same API :-) I've spent lot of time to make it this way, thank you for noticing!

Cheers,
bzt

bzt
Posts: 555
Joined: Sat Oct 14, 2017 9:57 pm

Re: USB image writer

Tue Mar 03, 2020 2:38 pm

Dear All,

A new version (build number 5) is out. This does not affect functionality, it is a user-interface only update.

Changelog:
  • the "-L(xx)" force language option is now available on all platforms
  • grammatically checked and fixed translations for: German, French, Dutch, Russian and Turkish
  • made "MiB" and "GiB" translatable (as it turned out, they have a different name in French)
  • documentation updated
I'd like to say thanks to this great forum community for helping me out with the translations. I've named all users in the "Contributors" section of the document. Thank you!

I'm still looking for volunteers to check the Spanish, Italian, Japanese, Polish and Portuguese translations (these are the languages which have their own sub-section on this forum). A verification on the Chinese translation would be great too, and of course, new languages are always welcome!

Cheers,
bzt

bzt
Posts: 555
Joined: Sat Oct 14, 2017 9:57 pm

Re: USB image writer

Sat Mar 07, 2020 9:16 pm

Hi All,

New version. This is actually not a new release (still has build number 5), I've just modified the Makefile.

Changelog:
  • You can use

    Code: Select all

    make deb
    to create .deb package (no additional dependencies, does not require dpkg-build nor dh etc., you can create the .deb under Gentoo for example)
  • From now on, USBImager is also available in Ubuntu LTS deb format
  • The other zip binaries haven't changed at all
  • Updated documentation
Cheers,
bzt

User avatar
CaptainMidnight
Posts: 74
Joined: Sun Nov 03, 2019 4:32 pm
Location: UK

Re: USB image writer

Sun Mar 08, 2020 4:22 pm

Hi bzt, it would seem that your program hopefully can transition from release candidate to stable release soon?
"Never get out of the boat." Absolutely goddamn right!
Unless you were goin' all the way...

bzt
Posts: 555
Joined: Sat Oct 14, 2017 9:57 pm

Re: USB image writer

Sun Mar 08, 2020 5:48 pm

CaptainMidnight wrote:
Sun Mar 08, 2020 4:22 pm
Hi bzt, it would seem that your program hopefully can transition from release candidate to stable release soon?
Yes, looks like it.

Many tests have been conducted (a lot by you :-) thanks) and USBImager has now been successfully ran on 32 bit and 64 bit systems, under Windows (Xp, 7, 10), Linux (Raspbian, Ubuntu, Debian, Gentoo and Arch, not sure about Linux Mint), MacOSX (Mojave, Catalina, El Capitan) too.

I'm going to wait another week just to be on the safe side, and if no bug will be found during that time I'm going to announce a stable release. During this week I'll accept only dictionary fixes and maybe new languages if there's a need. Per user request, Ukrainian translation has been added, and will be available in the stable release.

Cheers,
bzt

jahboater
Posts: 5625
Joined: Wed Feb 04, 2015 6:38 pm
Location: West Dorset

Re: USB image writer

Sun Mar 08, 2020 5:58 pm

bzt wrote:
Sun Mar 08, 2020 5:48 pm
not sure about Linux Mint)
It ran fine on Linux Mint 18.3 (64-bit of course).
Pi4 8GB running PIOS64

yekim54
Posts: 8
Joined: Wed Jul 04, 2018 3:43 pm
Location: Dunn Loring (US)

Re: USB image writer

Sun Mar 08, 2020 7:36 pm

Here's what I want to do (Linux Mint 19.3):
(1) Use USB Image Writer to create an image file of a 256GB USB drive.
(2) Use USB Image Writer to write the image file to a 128GB USB drive.
Will this work or do the USB drives need to be the same size?

Edit to add the following information:
The 256GB USB disk has the following two partitions:
/dev/sda1 fat32 512.00MB 7.02MB used (EFI System partition)
/dev/sda2 ext4 237.97GB 30.3GB used
So, I guess my question is: Do I need to shrink partition /dev/sda2 before creating the image file in order to write the image to the smaller 128GB USB drive? Or will USB Image Writer automatically shrink it during the writing process?
Last edited by yekim54 on Mon Mar 09, 2020 1:51 pm, edited 1 time in total.
Raspberry Pi 1B, 3B+, 4B

croft
Posts: 55
Joined: Fri Dec 13, 2019 4:58 pm

Re: USB image writer

Sun Mar 08, 2020 10:48 pm

will it work with buster
will it download to buster

bzt
Posts: 555
Joined: Sat Oct 14, 2017 9:57 pm

Re: USB image writer

Tue Mar 10, 2020 6:51 am

jahboater wrote:
Sun Mar 08, 2020 5:58 pm
It ran fine on Linux Mint 18.3 (64-bit of course).
Thank you very much, good to know!
croft wrote:will it work with buster
will it download to buster
Yes, it already does work with buster. Download the armv4l zip and unpack it to /usr. I can provide a Raspbian deb too if there's a need.

Cheers,
bzt

bzt
Posts: 555
Joined: Sat Oct 14, 2017 9:57 pm

Re: USB image writer

Tue Mar 10, 2020 7:37 am

Hi,
yekim54 wrote:
Sun Mar 08, 2020 7:36 pm
Will this work or do the USB drives need to be the same size?
No, the device must be greater or equal in size to the image file. So for example you can write a 128G image to a 128G USB drive or to a 256G USB drive; but there's simply not enough storage space to write a 256G image to a 128G drive.
yekim54 wrote:
Sun Mar 08, 2020 7:36 pm
So, I guess my question is: Do I need to shrink partition /dev/sda2 before creating the image file in order to write the image to the smaller 128GB USB drive? Or will USB Image Writer automatically shrink it during the writing process?
USBImager does not care about partitions and file system sizes. It saves the entire disk and restores the entire disk. Just like the "dd" command, USBImager does not interpret the image file. For both tools, the image file is nothing more than one sector after another, a disk dump (that's actually where the "dd" command's name and the image file's extension comes from).

The reason behind this is simple: USBImager's main users are simple users, who are unfamiliar with the command line and only want to write a (possibly compressed) image file to a drive, and maybe create a backup of that drive. That's all it offers - saving and restoring disk dumps - nothing more, nothing less. This is the UNIX way, to do only one thing and do it well. If you have special needs, then you should learn how to use the command line and combine more commands together.

One solution to your problem could be to make sure of it, no information is stored on the second half of the drive, and then create a special image file of the first half only:
1. shrink the file system size of sda2 to 127G (128G-512M)
2. using fdisk (or gparted whatever), resize the sda2 partition to the file system's size
3. use dd to create an image file from the first half of the drive only: "dd bs=$[1024*1024] count=$[128*1024] if=/dev/sda of=image.dd"
4. you'll now be able to write "image.dd" to a 128G drive using USBImager

Cheers,
bzt

bzt
Posts: 555
Joined: Sat Oct 14, 2017 9:57 pm

Re: USB image writer

Tue Mar 10, 2020 3:04 pm

Dear All,

New release (build number 6) is out. Just a few UI-related stuff again.

For some reason under Unity, the window position is not reported properly by X11. I had to add 8 pixels to get the correct value. Now popups appear exactly where they should be and where the others (Gnome-desktop, LXDE, openbox, etc.) displays them.

Changelog
  • Properly position the combobox popups under Unity (affects Debian LTS .deb version only)
  • Verified and fixed translation for Spanish (all platforms)
  • Added Ukrainian dictionary (all platforms)
  • Rasbian .deb package can be downloaded too for convenience
Cheers,
bzt

jahboater
Posts: 5625
Joined: Wed Feb 04, 2015 6:38 pm
Location: West Dorset

Re: USB image writer

Tue Mar 10, 2020 3:53 pm

bzt wrote:
Tue Mar 10, 2020 7:37 am
For both tools, the image file is nothing more than one sector after another, a disk dump (that's actually where the "dd" command's name and the image file's extension comes from).
I add, purely for amusement, that dd comes from the OS/360 JCL "Data Definition" card.

It is not a contraction of DASD (Direct Access Storage Device - a hard disk, also from IBM) as some might think.

Its old anyway.
Pi4 8GB running PIOS64

DarkElvenAngel
Posts: 717
Joined: Tue Mar 20, 2018 9:53 pm

Re: USB image writer

Sat Mar 14, 2020 12:02 pm

Bzt,

I had a little issue in raspbian using this I get an error cannot unmount sd

Is this perhaps an issue with the automatic mounting? My user is a member of the disk group.

Everything else is working great.

croft
Posts: 55
Joined: Fri Dec 13, 2019 4:58 pm

Re: USB image writer

Sat Mar 14, 2020 12:24 pm

will it ever work with buster on a pi 4


croft

DarkElvenAngel
Posts: 717
Joined: Tue Mar 20, 2018 9:53 pm

Re: USB image writer

Sat Mar 14, 2020 2:54 pm

croft wrote:
Sat Mar 14, 2020 12:24 pm
will it ever work with buster on a pi 4


croft
I used it on a Pi 4 4Gb it works you have to manually

Code: Select all

sudo umount /dev/sda?
assuming you're writing to sda

I'm wondering if this is something we can sort out should be possible.

croft
Posts: 55
Joined: Fri Dec 13, 2019 4:58 pm

Re: USB image writer

Sat Mar 14, 2020 4:54 pm

hi
deb would not install
wot did i did not correct

croft

bzt
Posts: 555
Joined: Sat Oct 14, 2017 9:57 pm

Re: USB image writer

Sat Mar 14, 2020 5:56 pm

DarkElvenAngel wrote:
Sat Mar 14, 2020 2:54 pm
croft wrote:
Sat Mar 14, 2020 12:24 pm
will it ever work with buster on a pi 4


croft
I used it on a Pi 4 4Gb it works you have to manually

Code: Select all

sudo umount /dev/sda?
assuming you're writing to sda

I'm wondering if this is something we can sort out should be possible.
I'll take a look, but it is possible that certain mount points are not mounted as user therefore you don't have permission to umount them. You'll have to do a "mount | grep /dev/sda" to see that. For me, there's a "user" option in the fstab and I can mount and umount removable devices as user without problems.

For example:

Code: Select all

$ cat /etc/fstab | grep sdb1
/dev/sdb1	/mnt	auto	rw,user,sync,noauto	0 0
And when I attach an USB stick, I see

Code: Select all

$ mount /dev/sdb1
$ mount | grep sdb1
/dev/sdb1 on /mnt type vfat (rw,nosuid,nodev,noexec,relatime,sync,uid=1000,gid=1000,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro,user=bzt)
As you can see, the mount point automatically got "uid=1000" and "user=bzt" options. (I don't like automount, I prefer manual mounts, but if you're using usbmount or similar utilities, I'm pretty sure you can configure it to use your user.)

Umounting the disk manually as you've suggested works too, or as a last resort you can run usbimager through sudo. There's no security risk really, I just don't like running applications as root if I don't absolutely have to.

@croft: I've already told you that it works on Raspbian, if you have some issues with installing the deb, then please copy paste the exact error message here so that I can help. Did you run "sudo dpkg -i usbimager-*.deb"?

Cheers,
bzt

Return to “General discussion”