Dit deel is nog niet vertaald. Je ziet de Engelse tekst.
Wat het doet
fdisk DEVICE opens a menu. Changes are kept in memory until you press w (write); q quits without saving. fdisk -l lists the partition tables of disks.
It handles both MBR (DOS) and GPT tables: o creates a new MBR table, g a new GPT table. After writing, the kernel normally reads the new table; if the disk is in use, run partprobe.
Zo schrijf je het
fdisk [OPTION]... DEVICE
fdisk -l [DEVICE]...Belangrijkste delen
m- Help.
p- Print the partition table.
n- New partition.
d- Delete a partition.
t- Change the partition type (alias like swap, lvm, linux, raid, uefi).
l- List known types.
o/g- Create a new empty MBR / GPT table.
a- Toggle the bootable flag (MBR).
x- Expert menu.
v- Verify the table.
i- Information about a partition.
F- Show free space.
w- Write the table and quit.
q- Quit without saving.
Opties 17
Meest gebruikt
Niets past bij dit filter.
Voorbeelden 10
$ als gewone gebruiker# als root (of met sudo)
1List the partition tables
fdisk -l /dev/vdb Disk /dev/vdb: 10 GiB, 10737418240 bytes, 20971520 sectors Disklabel type: gptCheck the disk before changing it.
2Create a GPT table and a partition
fdisk /dev/vdb Command (m for help): g Command (m for help): n Partition number (1-128, default 1): <Enter> First sector (2048-20971486, default 2048): <Enter> Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-20971486, default 20969471): +2G Command (m for help): wSizes like +2G are GiB.
3MBR primary partition
fdisk /dev/vdc Command (m for help): o Command (m for help): n Select (default p): p Command (m for help): wMBR: up to 4 primary partitions.
4Change the type to swap or LVM
fdisk /dev/vdb Command (m for help): t Partition number (1-3, default 3): 2 Partition type or alias (type L to list all): lvmAliases: linux, swap, lvm, raid, uefi.
5Delete a partition
fdisk /dev/vdb Command (m for help): d Partition number (1-3, default 3): 3Nothing changes on disk until
w.6Show free space
fdisk /dev/vdb Command (m for help): FWhere new partitions can go.
7Script a partition (no menu)
printf 'g\nn\n\n\n+1G\nw\n' | fdisk /dev/vdbFor labs; for real scripts prefer
parted -sorsfdisk.8Make the kernel read the new table
Needed when the disk was in use.
9Back up and restore a partition table
sfdisk -d /dev/vdb > /root/vdb-table.txt sfdisk /dev/vdb < /root/vdb-table.txtsfdisk is the script companion of fdisk.
10Check details of all disks
fdisk -xShows UUIDs and attributes of GPT partitions.
Niets past bij dit filter.
Let op
- Double check the device name.
won the wrong disk can destroy a system. - Deleting a partition does not wipe data, but the file system becomes unreachable.
Exitcodes
0 :: Done. 1 :: Error.