Skip to content

Instantly share code, notes, and snippets.

@ninegene
Last active June 1, 2024 22:39
Show Gist options
  • Save ninegene/2192ee173f2dad63423d0f067c6ee242 to your computer and use it in GitHub Desktop.
Save ninegene/2192ee173f2dad63423d0f067c6ee242 to your computer and use it in GitHub Desktop.
Creating bootable Mint Linux USB on macOS

Download the iso fiile

https://www.linuxmint.com/download.php

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

hdiutil convert -format UDRW -o linux.iso.img linux.iso
$ hdiutil convert -format UDRW -o linuxmint-21.3-cinnamon-64bit.iso.img linuxmint-21.3-cinnamon-64bit.iso
Reading Driver Descriptor Map (DDM : 0)…
Reading Linux Mint 21.3 Cinnamon 64-bit  (Apple_ISO : 1)…
Reading Apple (Apple_partition_map : 2)…
Reading Linux Mint 21.3 Cinnamon 64-bit  (Apple_ISO : 3)…
Reading EFI (Apple_HFS : 4)…
Reading Linux Mint 21.3 Cinnamon 64-bit  (Apple_ISO : 5)…
.......................................................................................................................
Elapsed Time:  7.518s
Speed: 389.1MB/s
Savings: 0.0%
created: /Users/aung/Downloads/linuxmint-21.3-cinnamon-64bit.iso.img.dmg

Prepare USB Drive: Erase and Format

List the drives

diskutil list
$ diskutil list
/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *251.0 GB   disk0
   1:                        EFI EFI                     314.6 MB   disk0s1
   2:                 Apple_APFS Container disk1         250.7 GB   disk0s2

/dev/disk1 (synthesized):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      APFS Container Scheme -                      +250.7 GB   disk1
                                 Physical Store disk0s2
   1:                APFS Volume Macintosh HD - Data     223.6 GB   disk1s1
   2:                APFS Volume Preboot                 2.1 GB     disk1s2
   3:                APFS Volume Recovery                1.2 GB     disk1s3
   4:                APFS Volume Macintosh HD            10.2 GB    disk1s4
   5:              APFS Snapshot com.apple.os.update-... 10.2 GB    disk1s4s1
   6:                APFS Volume VM                      1.1 GB     disk1s5

/dev/disk2 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     Apple_partition_scheme                        *31.0 GB    disk2
   1:        Apple_partition_map                         4.1 KB     disk2s1
   2:                  Apple_HFS                         5.2 MB     disk2s2
                    (free space)                         31.0 GB    -

Erase external /dev/disk2

diskutil eraseDisk FAT32 MYNAME MBRFormat /dev/diskX
$ diskutil eraseDisk FAT32 USBDISK MBRFormat /dev/disk2
Started erase on disk2
Unmounting disk
Creating the partition map
Waiting for partitions to activate
Formatting disk2s1 as MS-DOS (FAT32) with name USBDISK
512 bytes per physical sector
/dev/rdisk2s1: 60589120 sectors in 1893410 FAT32 clusters (16384 bytes/cluster)
bps=512 spc=32 res=32 nft=2 mid=0xf8 spt=32 hds=255 hid=2048 drv=0x80 bsec=60618752 bspf=14793 rdcl=2 infs=1 bkbs=6
Mounting disk
Finished erase on disk2

Verify

$ diskutil list
/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *251.0 GB   disk0
   1:                        EFI EFI                     314.6 MB   disk0s1
   2:                 Apple_APFS Container disk1         250.7 GB   disk0s2

/dev/disk1 (synthesized):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      APFS Container Scheme -                      +250.7 GB   disk1
                                 Physical Store disk0s2
   1:                APFS Volume Macintosh HD - Data     226.7 GB   disk1s1
   2:                APFS Volume Preboot                 2.1 GB     disk1s2
   3:                APFS Volume Recovery                1.2 GB     disk1s3
   4:                APFS Volume Macintosh HD            10.2 GB    disk1s4
   5:              APFS Snapshot com.apple.os.update-... 10.2 GB    disk1s4s1
   6:                APFS Volume VM                      1.1 GB     disk1s5

/dev/disk2 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *31.0 GB    disk2
   1:                 DOS_FAT_32 USBDISK                 31.0 GB    disk2s1

Unmount the USB flash drive

diskutil unmountDisk /dev/diskX
diskutil unmountDisk /dev/disk2

Copy the .img.dmg to the USB flash drive

time sudo dd if=linux.img.dmg of=/dev/diskX bs=1m
$ time sudo dd if=linuxmint-21.3-cinnamon-64bit.iso.img.dmg of=/dev/disk2 bs=1m
2925+1 records in
2925+1 records out
3067232256 bytes transferred in 434.667648 secs (7056500 bytes/sec)
sudo dd if=linuxmint-21.3-cinnamon-64bit.iso.img.dmg of=/dev/disk2 bs=1m  0.02s user 10.85s system 2% cpu 7:14.70 total

Based on

$ diskutil
Disk Utility Tool
Utility to manage local disks and volumes
Most commands require an administrator or root user

WARNING: Most destructive operations are not prompted

Usage:  diskutil [quiet] <verb> <options>, where <verb> is as follows:

     list                 (List the partitions of a disk)
     info[rmation]        (Get information on a specific disk or partition)
     listFilesystems      (List file systems available for formatting)
     listClients          (List all current disk management clients)
     activity             (Continuous log of system-wide disk arbitration)

     u[n]mount            (Unmount a single volume)
     unmountDisk          (Unmount an entire disk (all volumes))
     eject                (Eject a disk)
     mount                (Mount a single volume)
     mountDisk            (Mount an entire disk (all mountable volumes))

     enableJournal        (Enable HFS+ journaling on a mounted HFS+ volume)
     disableJournal       (Disable HFS+ journaling on a mounted HFS+ volume)
     moveJournal          (Move the HFS+ journal onto another volume)
     enableOwnership      (Exact on-disk User/Group IDs on a mounted volume)
     disableOwnership     (Ignore on-disk User/Group IDs on a mounted volume)

     rename[Volume]       (Rename a volume)

     verifyVolume         (Verify the file system data structures of a volume)
     repairVolume         (Repair the file system data structures of a volume)
     verifyDisk           (Verify the components of a partition map of a disk)
     repairDisk           (Repair the components of a partition map of a disk)
     resetFusion          (Reset the components of a machine's Fusion Drive)

     eraseDisk            (Erase an existing disk, removing all volumes)
     eraseVolume          (Erase an existing volume)
     reformat             (Erase an existing volume with same name and type)
     eraseOptical         (Erase optical media (CD/RW, DVD/RW, etc.))
     zeroDisk             (Erase a disk, writing zeros to the media)
     randomDisk           (Erase a disk, writing random data to the media)
     secureErase          (Securely erase a disk or freespace on a volume)

     partitionDisk        ((re)Partition a disk, removing all volumes)
     addPartition         (Create a new partition to occupy free space)
     splitPartition       (Split an existing partition into two or more)
     mergePartitions      (Combine two or more existing partitions into one)
     resizeVolume         (Resize a volume, increasing or decreasing its size)

     appleRAID <verb>     (Perform additional verbs related to AppleRAID)
     coreStorage <verb>   (Perform additional verbs related to CoreStorage)
     apfs <verb>          (Perform additional verbs related to APFS)
     image <verb>         (Perform additional verbs related to DiskImage)

diskutil <verb> with no options will provide help on that verb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment