Linux Basic Partitioning: Difference between revisions

From WikiMLT
m (Spas moved page Fdisk Basic Partitioning with to Linux Basic Partitioning without leaving a redirect)
mNo edit summary
Line 6: Line 6:
* <code>/dev/nvme0n1p3</code> - Linux LVM (for: <code>/</code>, <code>/home</code>, etc.).
* <code>/dev/nvme0n1p3</code> - Linux LVM (for: <code>/</code>, <code>/home</code>, etc.).


We can use <code>fdisk</code> or <code>gdisk</code> within the command line or <code>gparted</code> or other similar tool for manipulation the partition table via the graphical user interface. Note this operation will wipe all partitions and create new partitions you need. In this guide we will use the tool <code>fdisk</code> to accomplish this task.
We can use [https://manpages.ubuntu.com/manpages/jammy/en/man8/fdisk.8.html <code>fdisk</code>] or [https://manpages.ubuntu.com/manpages/jammy/en/man8/gdisk.8.html <code>gdisk</code>] within the command line or [https://manpages.ubuntu.com/manpages/jammy/en/man8/gparted.8.html <code>gparted</code>] or other similar tool for manipulation the partition table via the graphical user interface. Note this operation will wipe all partitions and create new partitions you need.  
 
== Partitioning with '''Fdisk''' ==
In this guide we will use the tool <code>[https://manpages.ubuntu.com/manpages/jammy/en/man8/fdisk.8.html fdisk]</code> to accomplish this task.


<syntaxhighlight lang="shell" line="1" class="mlw-continue">
<syntaxhighlight lang="shell" line="1" class="mlw-continue">
Line 100: Line 103:
Syncing disks.
Syncing disks.
</syntaxhighlight>
</syntaxhighlight>
== References ==
* [[LVM Basic Operations]]


<noinclude>
<noinclude>

Revision as of 14:02, 12 September 2022

In this guide we are as­sum­ing that, we want to pre­pare the de­vice /​​​dev/​​​nvme0n1 for Lin­ux UE­FI in­stal­la­tion with LVM and GPT par­ti­tion ta­ble. So the par­ti­tions that will be cre­at­ed are as fol­low:

  • /​​​dev/​​​nvme0n1p1 – EFI Sys­tem (for: /​​​boot/​​​efi),
  • /​​​dev/​​​nvme0n1p2 – Lin­ux filesys­tem (for: /​​​boot),
  • /​​​dev/​​​nvme0n1p3 – Lin­ux LVM (for: /, /​​​home, etc.).

We can use fdisk or gdisk with­in the com­mand line or gpart­ed or oth­er sim­i­lar tool for ma­nip­u­la­tion the par­ti­tion ta­ble via the graph­i­cal user in­ter­face. Note this op­er­a­tion will wipe all par­ti­tions and cre­ate new par­ti­tions you need.

Par­ti­tion­ing with Fdisk

In this guide we will use the tool fdisk to ac­com­plish this task.

sudo fdisk /dev/nvme0n1
# Create a new empty GPT partition table:
Command (m for help): g
# Add a new partition:
Command (m for help): n
Partition number (1-128, default 1): 1
First sector (2048-1951473664, default 2048): [Press Enter]
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-1951473664, default 1951473664): +512M
Created a new partition 1 of type 'Linux filesystem' and of size 512 MiB.
# Add a new partition:
Command (m for help): n
Partition number (2-128, default 1): 2
First sector (1050624-1951473664, default 1050624): [Press Enter]
Last sector, +/-sectors or +/-size{K,M,G,T,P} (1050624-1951473664, default 1951473664): +488M
Created a new partition 2 of type 'Linux filesystem' and of size 488 MiB.
# Add a new partition:
Command (m for help): n
Partition number (3-128, default 1): 3
First sector (2050048-1951473664, default 2050048): [Press Enter]
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2050048-1951473664, default 1951473664): [Press Enter]
Created a new partition 3 of type 'Linux filesystem' and of size 930.54 GiB.
# Change a partition type:
Command (m for help): t
Partition number (1-3, default 3): 1
Partition type (type L to list all types): 1
Changed type of partition 'Linux filesystem' to 'EFI System'.
# Change a partition type:
Command (m for help): t
Partition number (1-3, default 3): 3
Partition type (type L to list all types): 31
Changed type of partition 'Linux filesystem' to 'Linux LVM'.
# Print the partition table:
Command (m for help): p
Disk /dev/nvme0n1: 931.51 GiB, 1000204886016 bytes, 1953525168 sectors
Disk model: Samsung SSD 980 1TB                     
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 16384 bytes / 131072 bytes
Disklabel type: gpt
Disk identifier: E5B93AC4-141D-4174-B94D-07FCBB074D5C

Device           Start        End    Sectors   Size Type
/dev/nvme0n1p1    2048    1050623    1048576   512M EFI System
/dev/nvme0n1p2 1050624    2050047     999424   488M Linux filesystem
/dev/nvme0n1p3 2050048 1953523711 1951473664 930.5G Linux LVM
#  Verify the partition table
Command (m for help): v
No errors detected.
Header version: 1.0
Using 2 out of 128 partitions.
A total of 0 free sectors is available in 0 segments (the largest is (null)).
# Write the table to the disk and exit:
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

Ref­er­ences