注意:

The Funtoo Linux project has transitioned to "Hobby Mode" and this wiki is now read-only.

Difference between revisions of "Partitioning using gdisk"

From Funtoo
Jump to navigation Jump to search
(Created page with "==== Partitioning Using gdisk ==== ===== Notes Before We Begin ===== These install instructions assume you are installing Funtoo Linux to an empty hard disk using GUID parti...")
 
 
(5 intermediate revisions by 3 users not shown)
Line 1: Line 1:
==== Partitioning Using gdisk ====


===== Notes Before We Begin =====
== Notes Before We Begin ==


These install instructions assume you are installing Funtoo Linux to an empty hard disk using GUID partition tables (GPT). If you are installing Funtoo Linux on a machine where another OS is installed, or there is an existing Linux distribution on your system that you want to keep, then you will need to adapt these instructions to suit your needs.
These install instructions assume you are installing Funtoo Linux to an empty hard disk using GUID partition tables (GPT). If you are installing Funtoo Linux on a machine where another OS is installed, or there is an existing Linux distribution on your system that you want to keep, then you will need to adapt these instructions to suit your needs.


If you are going to create a legacy MBR partition table instead of GUID/GPT, you will use the <tt>fdisk</tt> command instead of <tt>gdisk</tt>, and you will not need to create the GRUB boot loader partition. See the table under [[Funtoo Linux Installation#Partitioning Recommendations|Partitioning Recommendations]], in particular the
== Using gdisk ==
'''MBR Block Device (<tt>fdisk</tt>)''' and '''MBR Code''' columns. <tt>fdisk</tt> works just like <tt>gdisk</tt>, but creates legacy MBR partition tables instead of the newer GPT/GUID partition tables.
 
Advanced users may be interested in the following topics:
 
* [[GUID Booting Guide]]
* [[Rootfs over encrypted lvm]]
* [[Rootfs over encrypted lvm over raid-1 on GPT]]
* '''NEW!''' '''[[ZFS Install Guide]] (Also contains instructions for Rootfs over Encrypted ZFS!)'''
 
===== Using gdisk =====


The first step after booting SystemRescueCd is to use <tt>gdisk</tt> to create GPT (also known as GUID) partitions, specifying the disk you want to use, which is typically <tt>/dev/sda</tt>, the first disk in the system:
The first step after booting SystemRescueCd is to use <tt>gdisk</tt> to create GPT (also known as GUID) partitions, specifying the disk you want to use, which is typically <tt>/dev/sda</tt>, the first disk in the system:
Line 41: Line 30:
Above, you'll see that we have a 500 MiB boot partition, a 32 MiB "BIOS boot partition" (also known as the GRUB boot loader partition), 4 GiB of swap, and the remaining disk used by a 107.7 GiB root partition.
Above, you'll see that we have a 500 MiB boot partition, a 32 MiB "BIOS boot partition" (also known as the GRUB boot loader partition), 4 GiB of swap, and the remaining disk used by a 107.7 GiB root partition.


===== For new <tt>gdisk</tt> users =====
== For new <tt>gdisk</tt> users ==


These partitions were created using the "<tt>n</tt>" command from within <tt>gdisk</tt>. The <tt>gdisk</tt> commands to create the partition table above are as follows. Adapt sizes as necessary, although these defaults will work for most users. The partition codes entered below can be found in the [[#Partitioning Recommendations|Partitioning Recommendations]] table below, in the GPT Code column.
These partitions were created using the "<tt>n</tt>" command from within <tt>gdisk</tt>. The <tt>gdisk</tt> commands to create the partition table above are as follows. Adapt sizes as necessary, although these defaults will work for most users. The partition codes entered below can be found in the [[#Partitioning Recommendations|Partitioning Recommendations]] table below, in the GPT Code column.
Line 47: Line 36:
Within <tt>gdisk</tt>, follow these steps:
Within <tt>gdisk</tt>, follow these steps:


'''Create a new empty partition table''' (This ''will'' erase all data on the disk when saved):
'''Create a new empty partition table'''
{{fancywarning|This will '''erase all data''' on the disk when saved!}}


<console>
<console>
Line 71: Line 61:
Partition Number: ##i##2 ↵
Partition Number: ##i##2 ↵
First sector: ##i##↵
First sector: ##i##↵
Last sector: ##i##+1M
Last sector: ##i##+32M
Hex Code: ##i##EF02 ↵
Hex Code: ##i##EF02 ↵
</console>
</console>
Line 113: Line 103:
* <tt>/dev/sda4</tt>, which will hold your root filesystem.
* <tt>/dev/sda4</tt>, which will hold your root filesystem.


===== For Previous fdisk users =====
== All Done! ==
 
If you have installed Gentoo Linux before, the one thing that is likely new to you here is the GRUB boot loader partition, which is listed as "BIOS boot partition" within <tt>gdisk</tt>. This partition is required for GRUB 2 to boot GPT/GUID boot disks. What is it? In GRUB-speak, this partition is essentially the location of the meat of GRUB's boot loading code. If you've used GRUB Legacy in the past, this partition is where the new GRUB stores the equivalent of the <tt>stage1_5</tt> and <tt>stage2</tt> files in legacy GRUB. Since GPT-based partition tables have less dead space at the beginning of the disk than their MBR equivalents, an explicitly defined partition of code <tt>EF02</tt> is required to hold the guts of the boot loader.


In all other respects, the partition table is similar to that which you might create for an MBR-based disk during a Gentoo Linux installation. We have a boot and a root partition with code <tt>0700</tt>, and a Linux swap partition with code <tt>8200</tt>.
Now, you can return to the main [[Funtoo Linux Installation]] instructions. Please note that your root filesystem is on <code>/dev/sda4</code>, and your swap partition is <code>/dev/sda3</code>. You will need to adjust your <code>/etc/fstab</code> accordingly when you edit it.

Latest revision as of 19:33, July 25, 2015

Notes Before We Begin

These install instructions assume you are installing Funtoo Linux to an empty hard disk using GUID partition tables (GPT). If you are installing Funtoo Linux on a machine where another OS is installed, or there is an existing Linux distribution on your system that you want to keep, then you will need to adapt these instructions to suit your needs.

Using gdisk

The first step after booting SystemRescueCd is to use gdisk to create GPT (also known as GUID) partitions, specifying the disk you want to use, which is typically /dev/sda, the first disk in the system:

root # gdisk /dev/sda

You should find gdisk very similar to fdisk. Here is the partition table we want to end up with:

Command (? for help): p
Disk /dev/sda: 234441648 sectors, 111.8 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): A4E5208A-CED3-4263-BB25-7147DC426931
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 234441614
Partitions will be aligned on 2048-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048          206847   500.0 MiB   8300  Linux filesystem
   2          206848          272383   32.0 MiB    EF02  BIOS boot partition
   3          272384         8660991   4.0 GiB     8200  Linux swap
   4         8660992       234441614   107.7 GiB   8300  Linux filesystem

Command (? for help): 

Above, you'll see that we have a 500 MiB boot partition, a 32 MiB "BIOS boot partition" (also known as the GRUB boot loader partition), 4 GiB of swap, and the remaining disk used by a 107.7 GiB root partition.

For new gdisk users

These partitions were created using the "n" command from within gdisk. The gdisk commands to create the partition table above are as follows. Adapt sizes as necessary, although these defaults will work for most users. The partition codes entered below can be found in the Partitioning Recommendations table below, in the GPT Code column.

Within gdisk, follow these steps:

Create a new empty partition table

   Warning

This will erase all data on the disk when saved!

Command: o ↵
This option deletes all partitions and creates a new protective MBR.
Proceed? (Y/N): y ↵

Create Partition 1 (boot):

Command: n ↵
Partition Number: 1 ↵
First sector: 
Last sector: +500M ↵
Hex Code: 

Create Partition 2 (GRUB):

Command: n ↵
Partition Number: 2 ↵
First sector: 
Last sector: +32M ↵
Hex Code: EF02 ↵

Create Partition 3 (swap):

Command: n ↵
Partition Number: 3 ↵
First sector: 
Last sector: +4G ↵
Hex Code: 8200 ↵

Create Partition 4 (root):

Command: n ↵
Partition Number: 4 ↵
First sector: 
Last sector:  (for rest of disk)
Hex Code: 

Along the way, you can type "p" and hit Enter to view your current partition table. If you make a mistake, you can type "d" to delete an existing partition that you created. When you are satisfied with your partition setup, type "w" to write your configuration to disk:

Write Partition Table To Disk:

Command: w ↵
Do you want to proceed? (Y/N): Y ↵

The partition table will now be written to disk and gdisk will close.

Now, your GPT/GUID partitions have been created, and will show up as the following block devices under Linux:

  • /dev/sda1, which will be used to hold the /boot filesystem,
  • /dev/sda2, which will be used directly by the new GRUB,
  • /dev/sda3, which will be used for swap space, and
  • /dev/sda4, which will hold your root filesystem.

All Done!

Now, you can return to the main Funtoo Linux Installation instructions. Please note that your root filesystem is on /dev/sda4, and your swap partition is /dev/sda3. You will need to adjust your /etc/fstab accordingly when you edit it.