Welcome!
Important information
-- Spectre and Meltdown vulnerabilities
-- Change in MX sources

News
-- MX Linux on social media: here
-- Mepis support still here

Current releases
-- MX-17.1 Final release info here
-- antiX-17 release info here

New users
-- Please read this first, and don't forget to add system and hardware information to posts!
-- Here are the Forum Rules

[Tutorial] Make your Linux USB write-able

Topics relating to MX Docs and MX Videos
Post Reply
Message
Author
Alt
Forum Novice
Forum  Novice
Posts: 73
Joined: Wed Jan 27, 2016 1:28 am

[Tutorial] Make your Linux USB write-able

#1 Post by Alt » Sun Jun 17, 2018 2:02 pm

Ever wondered how to use your Linux Live USB as a flash drive. For those who didn't I have to remind/inform that in the Linux world distro-makers produce so called hybrid ISO-s.
hybrid ISO files that can be booted or started from both BD or DVD and USB flash drive devices when the image is written to any of these storage devices.
So nowadays there's universal way for any distro. Just use dd in Terminal or some GUI tool like Etcher and get proper USB with your distro ("the way it meant to be used").
One of the downsides of this method is that now your Flash drive is read only and you can't do anything else with it.
For Windows there's brilliant tool Rufus which offers another method which gives you USB with write-able partition. Despite the fact that internally it uses syslinux, I didn't find GUI tool like this for Linux, or at least modern simple tutorial to achieve this with command-line.
Meanwhile in the Debian documentation
https://www.debian.org/releases/stable/amd64/ch04s03.html.en wrote:The hybrid image on the stick does not occupy all the storage space, so it may be worth considering using the free space to hold firmware files or packages or any other files of your choice. This could be useful if you have only one stick or just want to keep everything you need on one device.
And they're not wrong it's possible with some CLI magic!

-----------------

0) Insert your 'read only" Linux USB stick and open Terminal

DISCLAIMER: please check EVERY STEP before proceeding, there's a RISK to confuse devices and DELETE your VALUABLE DATA.

TLDR:

Code: Select all

sudo fdisk -l
sudo fdisk /dev/sdb # n > p > 3x Enter > t > Enter > c > w
sudo mkfs.fat /dev/sdb3 -n USBDATA
1) Find your device

Code: Select all

sudo fdisk -l
Alternatively use gnome-disk-utility / GParted / Partition Manager etc

2) Ok, for me it's /dev/sdb.

Code: Select all

sudo fdisk /dev/sdb
a) Create new primary partition with "n" > "p"
b) Press Enter 3 times to occupy rest of the disk space
c) Ok, this step is not necessary for Linux machines, that's just extra precaution for compatibility with different OS. I'm changing filesystem type from default "Linux" to more appropriate "W95 FAT32 (LBA)" (you can choose whatever you're going to use further).
So press "t", press Enter to confirm that we're modifying 3-rd partion, press "c"
d) Write all your change disk with "w", exit with "q"

3) The most important! Change partition table for that new partition. The reason why we can't do anything with USB stick is that all new partitions by default have that read-only CD format (ISO 9660).
Wait a second! Didn't we just change it in that previous "extra" step!
Well, according to gnome-disks (gnome-disk-utility) "Partition Type" is now really FAT32, but "Contents" (whatever it means) is still "ISO 9660"!
Fortunately we have anothet great CLI tool called mkfs
Remember DISCLAIMER? If unsure check with fdisk -l again!

Code: Select all

sudo mkfs.fat /dev/sdb3 -n USBDATA
So we just format that "unfortunate partition" and give it a name "USBDATA"

P.S. DON"T TRY to format that partition with "GNOME-Disks" (if you did, then just delete (d) and recreate (n > p ...) that partition with fdisk).
Unfortunately the best way to re-format it is mkfs.fat / mkfs.exfat / mkfs.ext4 / mkfs.ntfs (with -Q switch for faster format)

Alt
Forum Novice
Forum  Novice
Posts: 73
Joined: Wed Jan 27, 2016 1:28 am

Re: [Tutorial] Make your Linux USB write-able

#2 Post by Alt » Sun Jun 17, 2018 2:04 pm

Originally I tried to fix different problem. It was impossible (and still is) to launch in UEFI mode all recent MX 17.1 Snapshots (April, May, June), while original 17.1 release was fine. As it turned out, I simply didn't have EFI partition on those new ISO-s.

Actually the easiest method (kudos to fehlix for this suggestion!) is just to copy to your FAT32 USB stick all folders from ISO. But this way you won't be able to run that USB in Legacy mode.

So let's fix it (more or less) properly!

<This manual someday will become outdated and in order to follow it you must understand 1st post!>

-------
1)

Code: Select all

sudo fdisk /dev/sdb # n > p > enter (partition # 2) > enter (default first sector) > +14M (last sector) > t > enter (partition # 2) > ef (Hex code for EFI, check with L) > w
2)

Code: Select all

sudo mkfs.fat /dev/sdb2 -n MXEFI
3) Mount that partition with "Gnome Disks" or "Disk Manager"

4) On the first step I created 14 MB partition for "lazy" step 3-a
a) Copy folders "EFI" & "boot" from ISO to that partition
b) OR recreate such structure (taken it from original ISO)
  • EFI/BOOT/bootx64.efi ; EFI/BOOT/grubx64.efi ; EFI/BOOT/mt86.png
  • /boot/uefi-mt/mtest-64.efi
  • /boot/grub/grub.cfg
4) Open /boot/grub/grub.cfg and add single line at the beginning

Code: Select all

set root=(hd0)
I tested and installed June 2018 Snapshot in UEFI mode this way.
Last edited by Alt on Sun Jun 17, 2018 2:35 pm, edited 7 times in total.

Alt
Forum Novice
Forum  Novice
Posts: 73
Joined: Wed Jan 27, 2016 1:28 am

Re: [Tutorial] Make your Linux USB write-able

#3 Post by Alt » Sun Jun 17, 2018 2:06 pm

---Reserved for someone's alternative solution (Rufus-like?)---
"MX Live USB Maker" gives you something like Rufus does but only for MX/AntiX.
Last edited by Alt on Mon Jun 18, 2018 1:40 pm, edited 2 times in total.

User avatar
anticapitalista
Forum Veteran
Forum Veteran
Posts: 5651
Joined: Sat Jul 15, 2006 10:40 am

Re: [Tutorial] Make your Linux USB write-able

#4 Post by anticapitalista » Sun Jun 17, 2018 5:43 pm

Or just use our live-usb-maker tool if using linux.
anticapitalista
Reg. linux user #395339.

Philosophers have interpreted the world in many ways; the point is to change it.

antiX-17 "Heather Heyer" - lean and mean.
https://antixlinux.com

clicktician
Forum Novice
Forum  Novice
Posts: 96
Joined: Sat May 02, 2015 4:35 pm

Re: [Tutorial] Make your Linux USB write-able

#5 Post by clicktician » Sun Jun 17, 2018 7:46 pm

anticapitalista wrote:
Sun Jun 17, 2018 5:43 pm
Or just use our live-usb-maker tool if using linux.
+1. Works perfectly for me, too. Perhaps I'm not understanding the problem.
Son, someday all this will belong to your ex wife.

User avatar
fehlix
Forum Regular
Forum Regular
Posts: 909
Joined: Wed Apr 11, 2018 5:09 pm

Re: [Tutorial] Make your Linux USB write-able

#6 Post by fehlix » Mon Jun 18, 2018 7:10 am

Alt wrote:
Sun Jun 17, 2018 2:02 pm
... "Partition Type" is now really FAT32, but "Contents" (whatever it means) is still "ISO 9660"!
The above appears to be an indication that you might consider
to clear the residual partition table information before you do format a partition.
Otherwise you might confuse your firmware and potentially yourself.
An easy way to do this might be achieved with MX Linux provided tools:

Code: Select all

$ sudo live-usb-maker partition-clear 
which will provide you a selection of plugged in USB devices to clear
the residual partition table information on the USB device
and looks like this example:
===============================================================================
Starting live-usb-maker
===============================================================================

Please select the target usb device
= sdg 29.5G Innostor Innostor
> sdh 29.4G JetFlash Transcend 32GB
Press <Enter> to select the highlighted entry
Use 'h' for help, 'r' to redraw, 'q' to quit
Will use target device sdg (29.5G Innostor Innostor)
Will use source null

-------------------------------------------------------------------------------
Ready to perform partition-clear action on sdg
-------------------------------------------------------------------------------

Shall we begin?
= yes
> no
> pretend mode
Press <Enter> to select the highlighted entry
Use 'h' for help, 'r' to redraw, 'q' to quit
>> partition-clear
>> done
:puppy:

Alt
Forum Novice
Forum  Novice
Posts: 73
Joined: Wed Jan 27, 2016 1:28 am

Re: [Tutorial] Make your Linux USB write-able

#7 Post by Alt » Mon Jun 18, 2018 12:54 pm

clicktician wrote:
Sun Jun 17, 2018 7:46 pm
anticapitalista wrote:
Sun Jun 17, 2018 5:43 pm
Or just use our live-usb-maker tool if using linux.
+1. Works perfectly for me, too. Perhaps I'm not understanding the problem.
The problem is when you writing image using dd (as Manual suggests) or Etcher.
It's a classic universal method across distros.
https://mxlinux.org/user_manual_mx17/mxum.pdf wrote: line for the 32 bit kernels:
dd bs=4M if=MX-17_386-mx.iso of=/dev/sde && sync
• and this one for the 64 bit one:
dd bs=4M if=MX-17-b1_x64-mx.iso of=/dev/sde && sync
Imagine if someone is coming from Ubuntu, Mint, KDE Neon or even Debian. KDE Neon recommends "Rosa Image writer", which is dd wrapper, I guess same with Ubuntu/Mint tools, Debian doesn't like UnetbootIn & recommends dd or cp.
I believe most of those users won't try "MX Live USB Maker" and will get their USB stick with broken UEFI.
Nowadays it's not widespread because promoted "release" image is fine but for some Snapshot users it's a problem.

-----------

As for this manual, advantage of dd + second partition is that you'll never ever mess with your Distro on flash (well, it's possible to delete something on EFI partition but it's hidden in most cases).
Maybe consider such option for "MX Live USB Maker"?

clicktician
Forum Novice
Forum  Novice
Posts: 96
Joined: Sat May 02, 2015 4:35 pm

Re: [Tutorial] Make your Linux USB write-able

#8 Post by clicktician » Tue Jun 19, 2018 9:30 am

Alt wrote:
Mon Jun 18, 2018 12:54 pm
The problem is when you writing image using dd (as Manual suggests) or Etcher.
It's a classic universal method across distros.
Ah. I see. So, it's kind of a chicken and egg thing. You don't have live-usb-maker until you've installed MX. And if you're trying to install MX for the first time, you're forced to use an alternative method that may not be ideal.
Son, someday all this will belong to your ex wife.

Post Reply

Return to “Documentation and videos”