HDD: Difference between revisions

From Q
Jump to navigation Jump to search
Tgurr (talk | contribs)
Tgurr (talk | contribs)
 
(25 intermediate revisions by the same user not shown)
Line 1: Line 1:
Apart from the last step, setting up /etc/fstab there are no differences between partitioning a HDD or SSD drive. All modern Linux partitioning tools take care of aligning the partitions automatically.
Apart from the last step, setting up /etc/fstab there are no differences between partitioning a HDD or SSD drive. All modern Linux partitioning tools take care of aligning the partitions automatically.


== Create a simple Linux GPT partition layout (UEFI) ==
== Relevant Partition IDs ==
 
{{Note|Supported as of GPT fdisk 0.8.10.1.}}
 
 
{| class="wikitable"
|-
! Partition ID !! Description !! Auto-mounted by systemd !! Mount point
|-
| EF02 || BIOS boot partition || - ||
|-
| EF00 || EFI System Partition || - ||
|-
| FD00 || Linux RAID || - ||
|-
| 8200 || Linux swap || yes ||
|-
| 8300 || Linux filesystem || - ||
|-
| 8302 || Linux /home || yes || /home
|-
| 8303 || Linux x86 root (/) || yes || /
|-
| 8304 || Linux x86-64 root (/) || yes || /
|-
| 8305 || Linux ARM64 root (/) || yes || /
|-
| 8306 || Linux /srv || yes || /srv
|}
 
== Create a simple Linux GPT partition layout (UEFI with or without secure boot) ==


{{Code|GPT partition layout for UEFI|
{{Code|GPT partition layout for UEFI|
Line 8: Line 38:
/dev/sda2 500 MiB /boot 8300 ext4 Linux filesystem
/dev/sda2 500 MiB /boot 8300 ext4 Linux filesystem
/dev/sda3 512 MiB 8200 swap Linux swap
/dev/sda3 512 MiB 8200 swap Linux swap
/dev/sda4 25  GiB / 8300 ext4 Linux filesystem
/dev/sda4 25  GiB / 8304 ext4 Linux x86-64 root (/)
</pre>
</pre>
}}
}}
Line 47: Line 77:
enter
enter
enter
enter
8300
8304


p
p
Line 62: Line 92:
/dev/sda2 100 MiB /boot 8300 ext4 Linux filesystem
/dev/sda2 100 MiB /boot 8300 ext4 Linux filesystem
/dev/sda3 512 MiB 8200 swap Linux swap
/dev/sda3 512 MiB 8200 swap Linux swap
/dev/sda4 25  GiB / 8300 ext4 Linux filesystem
/dev/sda4 25  GiB / 8304 ext4 Linux x86-64 root (/)
</pre>
</pre>
}}
}}
Line 98: Line 128:
enter
enter
enter
enter
8300
8304


p
p
Line 107: Line 137:


== Create the filesystems ==
== Create the filesystems ==
Only for UEFI: {{Root|mkfs.vfat -F 32 /dev/sda1}}


{{Root|mkfs.ext4 /dev/sda2}}
{{Root|mkfs.ext4 /dev/sda2}}
Line 115: Line 143:


{{Root|mkfs.ext4 /dev/sda4}}
{{Root|mkfs.ext4 /dev/sda4}}
Additional for UEFI: {{Root|mkfs.vfat -F 32 /dev/sda1}}


== Label the filesystems ==
== Label the filesystems ==
Line 123: Line 153:


{{Root|tune2fs -L root /dev/sda4}}
{{Root|tune2fs -L root /dev/sda4}}
Additional for UEFI:
{{Root|fatlabel /dev/sda1 efi}}


And verify with:
And verify with:
Line 139: Line 173:


{{Root|mount /dev/sda2 /mnt/exherbo/boot}}
{{Root|mount /dev/sda2 /mnt/exherbo/boot}}
Additional for UEFI:


{{Root|mkdir /mnt/exherbo/boot/efi}}
{{Root|mkdir /mnt/exherbo/boot/efi}}
Line 148: Line 184:
{{Root|mount -o rbind /dev /mnt/exherbo/dev/}}
{{Root|mount -o rbind /dev /mnt/exherbo/dev/}}


{{Root|mount -o bind /sys /mnt/exherbo/sys/}}
{{Root|mount -o rbind /sys /mnt/exherbo/sys/}}


{{Root|mount -t proc none /mnt/exherbo/proc/}}
{{Root|mount -t proc none /mnt/exherbo/proc/}}
Line 163: Line 199:
{{File|/etc/fstab|
{{File|/etc/fstab|
<pre>
<pre>
UUID=0930a69b-f2d5-4607-93fe-4f8bfdf2ea87       /boot        ext4    defaults                   0 2
UUID=cf602240-7bac-4b29-8930-2080a5aac7cd       /           ext4    defaults                     0 1
UUID=8431f5f2-0cb1-4831-aed2-00d618543e0a      swap        swap    defaults                  0 0
UUID=0930a69b-f2d5-4607-93fe-4f8bfdf2ea87       /boot        ext4    defaults                     0 2
UUID=cf602240-7bac-4b29-8930-2080a5aac7cd       /           ext4    defaults                   0 1
UUID=8E3D-60F5                                  /boot/efi    vfat    umask=0077,shortname=winnt   0 0
# UEFI
UUID=8431f5f2-0cb1-4831-aed2-00d618543e0a      swap        swap    defaults                      0 0
UUID=8E3D-60F5                                  /boot/efi    vfat    umask=0077,shortname=winnt 0 0
</pre>
</pre>
}}
}}
Line 180: Line 215:
{{File|/etc/fstab|
{{File|/etc/fstab|
<pre>
<pre>
UUID=cf602240-7bac-4b29-8930-2080a5aac7cd      /            ext4    defaults,noatime,discard           0 1
UUID=cf602240-7bac-4b29-8930-2080a5aac7cd      /            ext4    defaults,noatime,discard             0 1
UUID=0930a69b-f2d5-4607-93fe-4f8bfdf2ea87      /boot        ext4    defaults,noatime,discard,noauto   0 2
UUID=0930a69b-f2d5-4607-93fe-4f8bfdf2ea87      /boot        ext4    defaults,noatime,discard,noauto     0 2
UUID=8E3D-60F5                                  /boot/efi    vfat    umask=0077,shortname=winnt         0 0
UUID=8E3D-60F5                                  /boot/efi    vfat    umask=0077,shortname=winnt,noauto    0 0
UUID=8431f5f2-0cb1-4831-aed2-00d618543e0a      swap        swap    defaults                           0 0
UUID=8431f5f2-0cb1-4831-aed2-00d618543e0a      swap        swap    defaults                             0 0
</pre>
}}
 
== SSD: Check estimated remaining life time / Wear Leveling Count ==
 
To check the current Wear Leveling Count (supported e.g. by Samsung SSDs).
 
{{Root|smartctl -a /dev/sda | grep "Wear_Leveling_Count"}}
 
{{Code|smartctl Wear_Leveling_Count Output|
<pre>
177 Wear_Leveling_Count     0x0013   099   099   000    Pre-fail  Always       -       2
</pre>
</pre>
}}
}}


The Wear_Leveling_Count starts to count down from 100 to 01, in this example it's 099 since the drive is pretty new.
== Edit reserved block count (on pure data partitions) ==
{{Root|tune2fs -m 0 /dev/sdd1}}


Then proceed to configure [[GRUB]] and your [[Kernel]].
{{Root|tune2fs -l /dev/sdd1 | grep "Reserved block count"}}

Latest revision as of 10:17, 5 June 2020

Apart from the last step, setting up /etc/fstab there are no differences between partitioning a HDD or SSD drive. All modern Linux partitioning tools take care of aligning the partitions automatically.

Relevant Partition IDs

Note: Supported as of GPT fdisk 0.8.10.1.


Partition ID Description Auto-mounted by systemd Mount point
EF02 BIOS boot partition -
EF00 EFI System Partition -
FD00 Linux RAID -
8200 Linux swap yes
8300 Linux filesystem -
8302 Linux /home yes /home
8303 Linux x86 root (/) yes /
8304 Linux x86-64 root (/) yes /
8305 Linux ARM64 root (/) yes /
8306 Linux /srv yes /srv

Create a simple Linux GPT partition layout (UEFI with or without secure boot)

Code: GPT partition layout for UEFI
/dev/sda1	200 MiB	/boot/efi	EF00	vfat		EFI System Partition
/dev/sda2	500 MiB	/boot		8300	ext4		Linux filesystem
/dev/sda3	512 MiB			8200	swap		Linux swap
/dev/sda4	25  GiB	/		8304	ext4		Linux x86-64 root (/)
# gdisk /dev/sda


Code: gdisk commands
Command (? for help): p
Disk /dev/sda: 156301488 sectors, 74.5 GiB
[...]

n
1
enter
+200M
EF00

c
1
EFI System Partition

n
2
enter
+500M
8300

n
3
enter
+512M
8200

n
4
enter
enter
8304

p
w
Y

Create a simple Linux GPT partition layout (Legacy BIOS)

Code: GPT partition layout for legacy BIOS
/dev/sda1	1   MiB		EF02	BIOS boot	BIOS boot partition
/dev/sda2	100 MiB	/boot	8300	ext4		Linux filesystem
/dev/sda3	512 MiB		8200	swap		Linux swap
/dev/sda4	25  GiB	/	8304	ext4		Linux x86-64 root (/)


# gdisk /dev/sda


Code: gdisk commands
Command (? for help): p
Disk /dev/sda: 156301488 sectors, 74.5 GiB
[...]

n
1
enter
+1M
EF02

n
2
enter
+100M
8300

n
3
enter
+512M
8200

n
4
enter
enter
8304

p
w
Y

Create the filesystems

# mkfs.ext4 /dev/sda2
# mkswap /dev/sda3
# mkfs.ext4 /dev/sda4

Additional for UEFI:

# mkfs.vfat -F 32 /dev/sda1

Label the filesystems

# tune2fs -L boot /dev/sda2
# mkswap -L swap /dev/sda3
# tune2fs -L root /dev/sda4

Additional for UEFI:

# fatlabel /dev/sda1 efi

And verify with:

# blkid

Mount the filesystems

# mkdir -p /mnt/exherbo
# swapon /dev/sda3
# mount /dev/sda4 /mnt/exherbo
# mkdir /mnt/exherbo/boot
# mount /dev/sda2 /mnt/exherbo/boot

Additional for UEFI:

# mkdir /mnt/exherbo/boot/efi
# mount /dev/sda1 /mnt/exherbo/boot/efi

Optional: For installation or rescue purposes you might also need to mount the following.

# mount -o rbind /dev /mnt/exherbo/dev/
# mount -o rbind /sys /mnt/exherbo/sys/
# mount -t proc none /mnt/exherbo/proc/

Configure /etc/fstab

List the UUIDs with:

# blkid


For HDDs

File: /etc/fstab
UUID=cf602240-7bac-4b29-8930-2080a5aac7cd       /            ext4    defaults                      0 1
UUID=0930a69b-f2d5-4607-93fe-4f8bfdf2ea87       /boot        ext4    defaults                      0 2
UUID=8E3D-60F5                                  /boot/efi    vfat    umask=0077,shortname=winnt    0 0
UUID=8431f5f2-0cb1-4831-aed2-00d618543e0a       swap         swap    defaults                      0 0

For SSDs

  • You could go for relatime as a compromise instead, but there are currently no known issues (exception is mutt) when using noatime
  • discard enables the TRIM function which should be available on all modern SSDs, check with
    # hdparm -I /dev/sda
  • mdraid, dm-crypt and the loopback block driver support passing discard commands to the underlying layer(s) since kernel 3.7


File: /etc/fstab
UUID=cf602240-7bac-4b29-8930-2080a5aac7cd       /            ext4    defaults,noatime,discard             0 1
UUID=0930a69b-f2d5-4607-93fe-4f8bfdf2ea87       /boot        ext4    defaults,noatime,discard,noauto      0 2
UUID=8E3D-60F5                                  /boot/efi    vfat    umask=0077,shortname=winnt,noauto    0 0
UUID=8431f5f2-0cb1-4831-aed2-00d618543e0a       swap         swap    defaults                             0 0

SSD: Check estimated remaining life time / Wear Leveling Count

To check the current Wear Leveling Count (supported e.g. by Samsung SSDs).

# smartctl -a /dev/sda
Code: smartctl Wear_Leveling_Count Output
177 Wear_Leveling_Count     0x0013   099   099   000    Pre-fail  Always       -       2

The Wear_Leveling_Count starts to count down from 100 to 01, in this example it's 099 since the drive is pretty new.

Edit reserved block count (on pure data partitions)

# tune2fs -m 0 /dev/sdd1
# tune2fs -l /dev/sdd1