Skip to content

Instantly share code, notes, and snippets.

@abelcallejo
Last active December 17, 2024 06:59
Show Gist options
  • Save abelcallejo/846b9b21b35f401f8df733ffd78165ec to your computer and use it in GitHub Desktop.
Save abelcallejo/846b9b21b35f401f8df733ffd78165ec to your computer and use it in GitHub Desktop.
Creating bootable Linux USB using Mac

Creating bootable Linux USB using Mac

mac

CentOS, Ubuntu, Slackware, etc. Whatever Linux-based OS it is, you can create a bootable USB for it by using a Mac.

1. Prepare the .iso file

Download it, copy it, whatever it takes to prepare that Linux-based OS .iso file

2. Convert the .iso file into a .img.dmg

hdiutil convert -format UDRW -o linux.img linux.iso

Output

Reading Master Boot Record (MBR : 0)…
Reading CentOS 7 x86_64                  (Apple_ISO : 1)…
Reading  (Type EF : 2)…
Reading CentOS 7 x86_64                  (Apple_ISO : 3)…
.........................................................
Elapsed Time: 30.450s
Speed: 143.7Mbytes/sec
Savings: 0.0%
created: /tmp/linux.img.dmg

3. List the drives of the Mac

diskutil list

Output

/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *500.3 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:                 Apple_APFS Container disk1         500.1 GB   disk0s2

/dev/disk1 (synthesized):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      APFS Container Scheme -                      +500.1 GB   disk1
                                 Physical Store disk0s2
   1:                APFS Volume Macintosh HD            446.8 GB   disk1s1
   2:                APFS Volume Preboot                 37.9 MB    disk1s2
   3:                APFS Volume Recovery                519.0 MB   disk1s3
   4:                APFS Volume VM                      3.2 GB     disk1s4

/dev/disk2 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *31.4 GB    disk2
   1:             Windows_FAT_32 NO NAME                 31.4 GB    disk2s1

Make sure to note the device that identifies the flash drive. In this case it is /dev/disk2

4. Unmount the flash drive

diskutil unmountDisk /dev/disk2

Output

Unmount of all volumes on disk2 was successful

5. Copy the .img.dmg to the flash drive

time sudo dd if=linux.img.dmg of=/dev/disk2 bs=1m

Output

Password: 
4375+1 records in
4375+1 records out
4588007424 bytes transferred in 1720.352991 secs (2666899 bytes/sec)

real	28m54.116s
user	0m0.059s
sys	1m0.412s
@tedonmain
Copy link

works! exactly as documented here. Thank You!

@mahfuz16
Copy link

mahfuz16 commented Mar 3, 2024

Works perfectly. Thanks.

@skeggse
Copy link

skeggse commented Mar 5, 2024

The drive I tried this on wasn't recognized as bootable in the system I was trying to use it on.

EDIT: you may need to disable secure boot on the target device 🤦

@nprasad2077
Copy link

Worked great! Thank you

@riturajborpujari
Copy link

Worked as it has been showed. Thankyou!

@saldanhandre
Copy link

I believe we should download the mac arm64 kali linux image correct?

@EnergyAndy
Copy link

Step 5 & dd block size 1 megabyte is not very excellent but prone to media errors.

By using 4096 block size the creation took 100% longer but I got media that worked well, 1m did not.

The page size of the file system is super good guidance and probably may easily be multiplied with some low figures. However, 1 meg is too much and has high probabilty not working well.

@CharlesCCC
Copy link

@EnergyAndy is correct, I'm having issue install the base system with 1m block size, but after change to 4096, it all worked well.

thank you all for sharing those tips.

@eplt
Copy link

eplt commented Aug 15, 2024

@mattf29
Copy link

mattf29 commented Aug 31, 2024

I have used Etcher in the past and it works really well, but I used it so rarely I uninstalled it and couldn't be bothered to go and reinstall it. These simple instructions with no additional software required. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment