HTGWA: Partition, format, and mount a big disk in Linux with parted

It is a easy information, a part of a collection I am going to name 'How-To Information With out Advertisements'. In it, I'll doc how I partition, format, and mount a big disk (2TB+) in Linux with parted.

Be aware that newer fdisk variations may fit higher with large drives... however since I am now used to parted I am sticking with it for the foreseeable future.

Listing all out there drives

$ sudo parted -l
Error: /dev/sda: unrecognised disk label
Mannequin: ATA Samsung SSD 870 (scsi)                                         
Disk /dev/sda: 8002GB
Sector measurement (logical/bodily): 512B/512B
Partition Desk: unknown
Disk Flags:

Good, I had plugged in that SSD simply now, and it is model new, so it does not have a partition desk, label, or something. It is the one I need to function on. It is situated at /dev/sda. I may additionally discover that information with lsblk.

Partition your drive with parted

$ sudo parted /dev/sda
(parted) mklabel gpt             # to create a partition desk
(parted) print                   # to confirm parition information
(parted) mkpart main 0% 100%  # create main partition filling complete disk
(parted) stop

Confirm you see the partition with fdisk

$ sudo fdisk -l /dev/sda                                        
Disk /dev/sda: 7.3 TiB, 8001563222016 bytes, 15628053168 sectors
Disk mannequin: Samsung SSD 870 
Items: sectors of 1 * 512 = 512 bytes
Sector measurement (logical/bodily): 512 bytes / 512 bytes
I/O measurement (minimal/optimum): 512 bytes / 512 bytes
Disklabel sort: gpt
Disk identifier: 44C96693-5B5E-4ABB-AEEC-A60C613E7EC6

Gadget     Begin         Finish     Sectors  Dimension Sort
/dev/sda1   2048 15628052479 15628050432  7.3T Linux filesystem

Now we all know the partition ID, /dev/sda1.

Format the partition

I nearly at all times use EXT4, as a result of it is good and dependable:

$ sudo mkfs.ext4 /dev/sda1
mke2fs 1.44.5 (15-Dec-2018)
Discarding machine blocks: performed                            
Creating filesystem with 1953506304 4k blocks and 244191232 inodes
Filesystem UUID: c597dcb4-83b2-4a93-a8a0-34d17af17729
Superblock backups saved on blocks: 
    32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
    4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 
    102400000, 214990848, 512000000, 550731776, 644972544, 1934917632

Allocating group tables: performed                            
Writing inode tables: performed                            
Creating journal (262144 blocks): performed
Writing superblocks and filesystem accounting info: performed 

Mount the partition

$ sudo mkdir /mnt/mydrive
$ sudo mount /dev/sda1 /mnt/mydrive

Confirm the mount exhibits up with df

$ df -h
Filesystem      Dimension  Used Avail Use% Mounted on
/dev/root        29G  1.5G   27G   6% /
/dev/sda1       7.3T   93M  6.9T   1% /mnt/mydrive

Bingo! It is mounted.

Make the mount persist

In the event you do not add the mount to /and so on/fstab, it will not be mounted after you reboot!

First, get the UUID of the drive (the worth contained in the quotations within the output under—and not the PARTUUID):

$ sudo blkid
/dev/sda1: UUID="c597dcb4-83b2-4a93-a8a0-34d17af17729" TYPE="ext4" PARTLABEL="main" PARTUUID="99457865-24e2-4e2a-becd-1d6498de2369"

Edit /and so on/fstab (e.g. sudo nano /and so on/fstab) and add a line like the next to the tip:

UUID=c597dcb4-83b2-4a93-a8a0-34d17af17729 /mnt/mydrive ext4 defaults 0 0

Save that file and reboot.

Be aware: If genfstab is on the market in your system, use it as an alternative. A lot much less prone to asplode issues: genfstab -U /mnt/mydrive >> /mnt/and so on/fstab.

Confirm the mount continued.

After reboot:

$ df -h
Filesystem      Dimension  Used Avail Use% Mounted on
/dev/root        29G  1.5G   27G   6% /
/dev/sda1       7.3T   93M  6.9T   1% /mnt/mydrive

Source link

Leave a Reply

Your email address will not be published. Required fields are marked *