Difference between revisions of "HowTo Create A GPT Disk With EFI System And exFAT Partitions Using Parted"

From NST Wiki
Jump to navigationJump to search
(Create exFAT Partition)
(Format exFAT Partition)
Line 126: Line 126:
 
  Flushing... done.
 
  Flushing... done.
 
  File system created successfully.
 
  File system created successfully.
 +
[root@shopper2 ~]#
 +
 +
[root@shopper2 ~]# /bin/lsblk -a -o name,label,size,fstype,model;
 +
NAME                    LABEL  SIZE FSTYPE      MODEL
 +
sda                            111.8G            OCZ-VERTEX3
 +
├─sda1                            1G ext4       
 +
└─sda2                        110.8G LVM2_member
 +
  ├─shopper2--nst30-root        103G xfs       
 +
  └─shopper2--nst30-swap        7.8G swap       
 +
sdb                            223.6G            SanDisk_SDSSDX240GG25
 +
└─sdb1                        223.6G LVM2_member
 +
  └─shopper2data-data          223.6G ext4       
 +
sdc                            111.8G            USB3.1_NVME_DISK
 +
├─sdc1                          260M           
 +
└─sdc2                  NVMe  111.5G exfat     
 
  [root@shopper2 ~]#
 
  [root@shopper2 ~]#

Revision as of 09:17, 2 January 2020

Overview

The purpose of this article is to create a disk that can be read / written to by all major operating systems (i.e., macOS, Windows and Linux). A removable USB storage device containing SSD SATA or NVMe media formatted with an exFAT partition can be used to accomplish this. At the time of this writing, January 02, 2020, a removable USB-C drive containing a CORSAIR FORCE Series MP500 120GB NVMe storage device will be demonstrated.

The USB drive is attached to an NST system as device: "/dev/sdc". The parted disk utility will be used to create the GUID Partition Table (GPT) disk label, the EFI System Partition and the exFAT partition.

The following diagram is an example GUID Partition Table layout:

Wikipedia Reference: The layout of a disk with the GUID Partition Table. In this example, each logical block is 512 bytes in size and each entry has 128 bytes. The corresponding partition entries are assumed to be located in LBA 2–33. Negative LBA addresses indicate a position from the end of the volume, with −1 being the last addressable block.

Zero Out Previous Disk Label - Optional

This optional step will zero out any previous disk label. We will use the dcfldd utility. The first 1GB of the disk will be zeroed out:

[root@shopper2 ~]# dcfldd if=/dev/zero of=/dev/sdc statusinterval=64 bs=1M count=1k;
1024 blocks (1024Mb) written.
1024+0 records in
1024+0 records out
[root@shopper2 ~]#

We can now used parted to examine the disk and see that we are starting out with an "unrecognized" disk structure:

[root@shopper2 ~]# /sbin/parted -s /dev/sdc print;
Error: /dev/sdc: unrecognised disk label
Model: JM583  (scsi)
Disk /dev/sdc: 120GB
Sector size (logical/physical): 512B/512B
Partition Table: unknown
Disk Flags: 
[root@shopper2 ~]#

Create GPT Disk Label

The GPT disk label will now be created:

[root@shopper2 ~]# parted /dev/sdc;
GNU Parted 3.2
Using /dev/sdc
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel gpt                                                      
(parted) quit
Information: You may need to update /etc/fstab.

[root@shopper2 ~]# /sbin/parted -s /dev/sdc print;                        
Model: JM583  (scsi)
Disk /dev/sdc: 120GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start  End  Size  File system  Name  Flags

[root@shopper2 ~]#

Create EFI System Partition

A new EFI System Partition will be created using the following commands (the recommended size is at least 260 MiB):

[root@shopper2 ~]# parted /dev/sdc;
GNU Parted 3.2
Using /dev/sdc
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mkpart primary fat32 1MiB 261MiB                                 
(parted) set 1 esp on                                                     
(parted) print                                                            
Model: JM583  (scsi)
Disk /dev/sdc: 120GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End    Size   File system  Name     Flags
 1      1049kB  274MB  273MB  fat32        primary  boot, esp

(parted) quit                                                             
Information: You may need to update /etc/fstab.

[root@shopper2 ~]#

Create exFAT Partition

A new exFAT partition will now be created using the remaining unused disk area:

[root@shopper2 ~]# parted /dev/sdc;                        
GNU Parted 3.2
Using /dev/sdc
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print                                                            
Model: JM583  (scsi)
Disk /dev/sdc: 120GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End    Size   File system  Name     Flags
 1      1049kB  274MB  273MB               primary  boot, esp

(parted) mkpart primary ntfs 261MiB 100%
(parted) print                                                            
Model: JM583  (scsi)
Disk /dev/sdc: 120GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End    Size   File system  Name     Flags
 1      1049kB  274MB  273MB               primary  boot, esp
 2      274MB   120GB  120GB  ntfs         primary

(parted) quit                                                             
Information: You may need to update /etc/fstab.

[root@shopper2 ~]# /sbin/parted -s /dev/sdc print;                        
Model: JM583  (scsi)
Disk /dev/sdc: 120GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End    Size   File system  Name     Flags
 1      1049kB  274MB  273MB               primary  boot, esp
 2      274MB   120GB  120GB               primary  msftdata

[root@shopper2 ~]#

Format exFAT Partition

[root@shopper2 ~]# mkfs.exfat -n NVMe /dev/sdc2
mkexfatfs 1.3.0
Creating... done.
Flushing... done.
File system created successfully.
[root@shopper2 ~]#

[root@shopper2 ~]# /bin/lsblk -a -o name,label,size,fstype,model;
NAME                     LABEL   SIZE FSTYPE      MODEL
sda                            111.8G             OCZ-VERTEX3
├─sda1                             1G ext4        
└─sda2                         110.8G LVM2_member 
  ├─shopper2--nst30-root         103G xfs         
  └─shopper2--nst30-swap         7.8G swap        
sdb                            223.6G             SanDisk_SDSSDX240GG25
└─sdb1                         223.6G LVM2_member 
  └─shopper2data-data          223.6G ext4        
sdc                            111.8G             USB3.1_NVME_DISK
├─sdc1                           260M             
└─sdc2                   NVMe  111.5G exfat       
[root@shopper2 ~]#