Skip to content

Instantly share code, notes, and snippets.

@a-maumau
Last active February 21, 2024 05:14
Show Gist options
  • Save a-maumau/a8507607fdb85bee6554016e2ab74092 to your computer and use it in GitHub Desktop.
Save a-maumau/a8507607fdb85bee6554016e2ab74092 to your computer and use it in GitHub Desktop.
creating ubuntu boot usb drive on macOS

thanks to https://timesaving.hatenablog.com/entry/2023/04/01/150000 (Japanese)

Tested in macOS Monterey.
Everything will done in terminal, except for downloading the Ubuntu image.

Download Ubuntu Image

https://ubuntu.com/download

Format USB Drive

It may not require this step because we will write Ubuntu image with dd command.
I will leave it just in case.

You may can do in Disk Utility, but I couldn't format, so we will do in terminal.


 Before erasing the drive, check it is OK to erase

Locate usb drive

Search the usb drive with diskutil list

$ diskutil list

/dev/disk0 (internal):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   ...

/dev/disk3 (synthesized):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   ...

/dev/disk4 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *15.5 GB    disk4
   1:                        EFI EFI                     209.7 MB   disk4s1
   2:       Microsoft Basic Data UBUNTU2204              15.3 GB    disk4s2

Find the drive which you prepared.
You should check the part (external, physical).

In my case, I used 16 GB USB flash drive and it was /dev/disk4.

Format with FAT32

Format by

sudo diskutil eraseDisk FAT32 UBUNTU2204 <your_usb_drive>

<your_usb_drive> is what you found in the previous step.
In my case, it was /dev/disk4, so replace the <your_usb_drive> with /dev/disk4.
(UBUNTU2204 is the drive name, I am not sure it will affect the drive name because we will rewrite the usb drive)

Convert .iso to .dmg

Convert by

hdiutil convert -format UDRW -o ./Downloads/ubuntu-22.04.3-desktop-amd64.img ./Downloads/ubuntu-22.04.3-desktop-amd64.iso

I used ubuntu-22.04.3-desktop-amd64.iso, it depends on which version of ubuntu you use.
It will generate ubuntu-22.04.3-desktop-amd64.img.dmg

Unmount the USB Drive

Unmount by

diskutil unmountDisk <your_usb_drive>

Write to USB Drive

Write by

sudo dd if=./Downloads/ubuntu-22.04.3-desktop-amd64.img.dmg of=<your_usb_drive> bs=1m
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment