Fdisk (en): Unterschied zwischen den Versionen

Aus Gemini-Wiki
Zur Navigation springen Zur Suche springen
 
(10 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 3: Zeile 3:
 
  |[[Bild:english.png]] - [[Fdisk (en)|in English]]
 
  |[[Bild:english.png]] - [[Fdisk (en)|in English]]
 
  |}
 
  |}
__TOC__
 
 
 
'''[http://en.wikipedia.org/wiki/Fdisk Fdisk]''' (short for ''fixed disk'') is a program, which can be used for partitioning devices such as HDDs, USB Sticks, etc.. The program is used in the command line of the Dreambox. You need an connection via [[Telnet (en)|Telnet]] or [[SSH]].
 
'''[http://en.wikipedia.org/wiki/Fdisk Fdisk]''' (short for ''fixed disk'') is a program, which can be used for partitioning devices such as HDDs, USB Sticks, etc.. The program is used in the command line of the Dreambox. You need an connection via [[Telnet (en)|Telnet]] or [[SSH]].
  
Zeile 12: Zeile 10:
  
 
<br/>
 
<br/>
{{Achtung|1='''Attention!'''<br/>(Wrong) manipulations of existing partitions can result in loss of data. A backup of data is a must before using the program.}}
+
{{Warnung|1='''Attention!'''<br/>(Wrong) manipulations of existing partitions can result in loss of data. A backup of data is a must before using the program.}}
  
 
{{Hinweis|Fdisk can handle partitions up to 2TB. With Images based on [[OE 2.0]] the more "actual" [http://en.wikipedia.org/wiki/GNU_Parted GNU Parted] (parted) is available to create larger partitions. In this case you need to use a [http://en.wikipedia.org/wiki/GUID_Partition_Table gpt] as partition table.}}
 
{{Hinweis|Fdisk can handle partitions up to 2TB. With Images based on [[OE 2.0]] the more "actual" [http://en.wikipedia.org/wiki/GNU_Parted GNU Parted] (parted) is available to create larger partitions. In this case you need to use a [http://en.wikipedia.org/wiki/GUID_Partition_Table gpt] as partition table.}}
Zeile 61: Zeile 59:
 
  fdisk /dev/sdf
 
  fdisk /dev/sdf
  
You will see: Fdisk is ready to manipulate Partitions. If you push '''[m]''' and confirm with '''[Enter]''', all availiable options are displayed.
+
You will see: Fdisk is ready to manipulate Partitions. If you push {{Taste|m}} and confirm with {{Taste|↵ Enter}}, all availiable options are displayed.
  
 
  Command (m for help):  
 
  Command (m for help):  
Zeile 94: Zeile 92:
 
  root@dm8000:/# fdisk /dev/sdf <span style="color:red;">=> start fdisk for the device</span>
 
  root@dm8000:/# fdisk /dev/sdf <span style="color:red;">=> start fdisk for the device</span>
 
   
 
   
  Command (m for help): p <span style="color:red;">=> with p you can see the actual partitioning, here one partition: /dev/sdf1</span>
+
  Command (m for help): p <span style="color:red;">=> with {{Taste|p}} you can see the actual partitioning, here one partition: /dev/sdf1</span>
 
   
 
   
 
  Disk /dev/sdf: 8006 MB, 8006926336 bytes
 
  Disk /dev/sdf: 8006 MB, 8006926336 bytes
Zeile 103: Zeile 101:
 
  /dev/sdf1              1        1021    7817766  83 Linux
 
  /dev/sdf1              1        1021    7817766  83 Linux
 
   
 
   
  Command (m for help): d <span style="color:red;">=> d deletes the existing partition</span>
+
  Command (m for help): d <span style="color:red;">=> {{Taste|d}} deletes the existing partition</span>
 
  Selected partition 1
 
  Selected partition 1
 
   
 
   
  Command (m for help): p <span style="color:red;">=> no partition displayed, only the Raw Device</span>
+
  Command (m for help): p <span style="color:red;">=> {{Taste|p}} displays no partition, only the Raw Device</span>
 
   
 
   
 
  Disk /dev/sdf: 8006 MB, 8006926336 bytes
 
  Disk /dev/sdf: 8006 MB, 8006926336 bytes
Zeile 114: Zeile 112:
 
     Device Boot      Start        End      Blocks  Id System
 
     Device Boot      Start        End      Blocks  Id System
 
   
 
   
  Command (m for help): n <span style="color:red;">=> n for creating a new partition</span>
+
  Command (m for help): n <span style="color:red;">=> {{Taste|n}} for creating a new partition</span>
 
  Command action
 
  Command action
 
     e  extended
 
     e  extended
 
     p  primary partition (1-4)
 
     p  primary partition (1-4)
  p <span style="color:red;">=> p for creating a primary partition</span>
+
  p <span style="color:red;">=> {{Taste|p}} for creating a primary partition</span>
  Partition number (1-4): 1 <span style="color:red;">=> enter the partition number, in this case 1</span>
+
  Partition number (1-4): 1 <span style="color:red;">=> enter the partition number, in this case {{Taste|1}}</span>
  First cylinder (1-1021, default 1): Using default value 1 <span style="color:red;">=> Define the start of the partition, confirm with [Enter].</span>
+
  First cylinder (1-1021, default 1): Using default value 1 <span style="color:red;">=> Define the start of the partition, confirm with {{Taste|↵ Enter}}.</span>
  Last cylinder or +size or +sizeM or +sizeK (1-1021, default 1021): Using default value 1021 <span style="color:red;">=> Define the end of the partition, confirm with [Enter].</span>
+
  Last cylinder or +size or +sizeM or +sizeK (1-1021, default 1021): Using default value 1021 <span style="color:red;">=> Define the end
 +
of the partition, confirm with {{Taste|↵ Enter}}.</span>
 
   
 
   
  Command (m for help): p <span style="color:red;">=> p shows 1 partition ;)</span>
+
  Command (m for help): p <span style="color:red;">=> {{Taste|p}} shows 1 partition ;)</span>
 
   
 
   
 
  Disk /dev/sdf: 8006 MB, 8006926336 bytes
 
  Disk /dev/sdf: 8006 MB, 8006926336 bytes
Zeile 132: Zeile 131:
 
  /dev/sdf1              1        1021    7817766  83 Linux
 
  /dev/sdf1              1        1021    7817766  83 Linux
 
   
 
   
  Command (m for help): w <span style="color:red;">=> w starts the partitioning and ends the program </span>
+
  Command (m for help): w <span style="color:red;">=> {{Taste|w}} starts the partitioning and ends the program </span>
 
  The partition table has been altered!
 
  The partition table has been altered!
 
   
 
   
Zeile 161: Zeile 160:
 
  root@dm8000:/# fdisk /dev/sdf <span style="color:red;">=> start fdisk for the device</span>
 
  root@dm8000:/# fdisk /dev/sdf <span style="color:red;">=> start fdisk for the device</span>
 
   
 
   
  Command (m for help): p <span style="color:red;">=> with p you can see the actual partitioning, here one partition: /dev/sdf1</span>
+
  Command (m for help): p <span style="color:red;">=> with {{Taste|p}} you can see the actual partitioning, here one partition: /dev/sdf1</span>
 
   
 
   
 
  Disk /dev/sdf: 8006 MB, 8006926336 bytes
 
  Disk /dev/sdf: 8006 MB, 8006926336 bytes
Zeile 170: Zeile 169:
 
  /dev/sdf1              1        1021    7817766  83 Linux
 
  /dev/sdf1              1        1021    7817766  83 Linux
 
   
 
   
  Command (m for help): d <span style="color:red;">=> d deletes the existing partition</span>
+
  Command (m for help): d <span style="color:red;">=> {{Taste|d}} deletes the existing partition</span>
 
  Selected partition 1
 
  Selected partition 1
 
   
 
   
  Command (m for help): p <span style="color:red;">=> no partition displayed, only the Raw Device</span>
+
  Command (m for help): p <span style="color:red;">=> {{Taste|p}} displays no partition, only the Raw Device</span>
 
   
 
   
 
  Disk /dev/sdf: 8006 MB, 8006926336 bytes
 
  Disk /dev/sdf: 8006 MB, 8006926336 bytes
Zeile 181: Zeile 180:
 
     Device Boot      Start        End      Blocks  Id System
 
     Device Boot      Start        End      Blocks  Id System
 
   
 
   
  Command (m for help): n <span style="color:red;">=> n for creating a new partition</span>
+
  Command (m for help): n <span style="color:red;">=> {{Taste|n}} for creating a new partition</span>
 
  Command action
 
  Command action
 
     e  extended
 
     e  extended
 
     p  primary partition (1-4)
 
     p  primary partition (1-4)
  p <span style="color:red;">=> p for creating a primary partition</span>
+
  p <span style="color:red;">=> {{Taste|p}} for creating a primary partition</span>
  Partition number (1-4): 1 <span style="color:red;">=> enter the partition number, in this case 1</span>
+
  Partition number (1-4): 1 <span style="color:red;">=> enter the partition number, in this case {{Taste|1}}</span>
  First cylinder (1-1021, default 1): Using default value 1 <span style="color:red;">=> Define the start of the partition, confirm with [Enter].</span>
+
  First cylinder (1-1021, default 1): Using default value 1 <span style="color:red;">=> Define the start of the partition, confirm with {{Taste|↵ Enter}}.</span>
 
  Last cylinder or +size or +sizeM or +sizeK (1-1021, default 1021): +4GB <span style="color:red;">=> Define size of the first partition, in the example +4GB</span>
 
  Last cylinder or +size or +sizeM or +sizeK (1-1021, default 1021): +4GB <span style="color:red;">=> Define size of the first partition, in the example +4GB</span>
 
   
 
   
  Command (m for help): n <span style="color:red;">=> n for creating the second partition</span>
+
  Command (m for help): n <span style="color:red;">=> {{Taste|n}} for creating the second partition</span>
 
  Command action
 
  Command action
 
     e  extended
 
     e  extended
 
     p  primary partition (1-4)
 
     p  primary partition (1-4)
  p <span style="color:red;">=> p for creating a primary partition</span>
+
  p <span style="color:red;">=> {{Taste|p}} for creating a primary partition</span>
 
  Partition number (1-4): 2 <span style="color:red;">=> enter the partition number, in this case 2 for the second</span>
 
  Partition number (1-4): 2 <span style="color:red;">=> enter the partition number, in this case 2 for the second</span>
  First cylinder (512-1021, default 512): Using default value 512 <span style="color:red;">=> Define the start of the second partition, confirm with [Enter].</span>
+
  First cylinder (512-1021, default 512): Using default value 512 <span style="color:red;">=> Define the start of the second partition, confirm with {{Taste|↵ Enter}}.</span>
  Last cylinder or +size or +sizeM or +sizeK (512-1021, default 1021): Using default value 1021 <span style="color:red;">=> Define the end of the second partition, confirm with [Enter].</span>
+
  Last cylinder or +size or +sizeM or +sizeK (512-1021, default 1021): Using default value 1021 <span style="color:red;">=> Define the end
 +
of the second partition, confirm with {{Taste|↵ Enter}}.</span>
 
   
 
   
  Command (m for help): p <span style="color:red;">=> p shows both partitions ;)</span>
+
  Command (m for help): p <span style="color:red;">=> {{Taste|p}} shows both partitions ;)</span>
 
   
 
   
 
  Disk /dev/sdf: 8006 MB, 8006926336 bytes
 
  Disk /dev/sdf: 8006 MB, 8006926336 bytes
Zeile 209: Zeile 209:
 
  /dev/sdf2            512        1021    3905070  83 Linux
 
  /dev/sdf2            512        1021    3905070  83 Linux
 
   
 
   
  Command (m for help): w <span style="color:red;">=> w starts the partitioning and ends the program </span>
+
  Command (m for help): w <span style="color:red;">=> {{Taste|w}} starts the partitioning and ends the program </span>
 
  The partition table has been altered!
 
  The partition table has been altered!
 
   
 
   
Zeile 231: Zeile 231:
  
  
[[Kategorie:Basics]]  
+
[[Kategorie:Basics (en)]]  
[[Kategorie:Instructions]]
+
[[Kategorie:Instructions (en)]]

Aktuelle Version vom 29. November 2012, 12:16 Uhr

Deutsch.png - in Deutsch English.png - in English

Fdisk (short for fixed disk) is a program, which can be used for partitioning devices such as HDDs, USB Sticks, etc.. The program is used in the command line of the Dreambox. You need an connection via Telnet or SSH.

An alternative is sfdisk, which offers equal functions, but this program can also be controlled with options and is great to be used within scripts.

Partitioning is possible with the Dreambox, using the device manager in the settings menu. Also the device manager of the BluePanel offers this possibility. With both tools ist is possible to initialize the connected devices. Initializing means: the complete device gets a partition and is formated (e.g. ext3 or ext4).


Ambox warning.png Attention!
(Wrong) manipulations of existing partitions can result in loss of data. A backup of data is a must before using the program.
Ambox notice.png Fdisk can handle partitions up to 2TB. With Images based on OE 2.0 the more "actual" GNU Parted (parted) is available to create larger partitions. In this case you need to use a gpt as partition table.


Show informations of all partitions

With the following command you can see all partitions of all connected devices.

fdisk -l

An example of the output.

Disk /dev/sda: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks  Id System
/dev/sda1               1      121601   976760032  83 Linux

Disk /dev/sdf: 8006 MB, 8006926336 bytes
247 heads, 62 sectors/track, 1021 cylinders
Units = cylinders of 15314 * 512 = 7840768 bytes

   Device Boot      Start         End      Blocks  Id System
/dev/sdf1               1        1021     7817766  83 Linux

The example show a harddisk (/dev/sda1) of 1TB and the second device is an USB Stick (/dev/sdf1) with 8GB capacity. If you have connected these devices you should know this informations ;). Both devices consist of one partition, indicated by the 1 after the device name. If the stick would have 2 partitions, it would look like the following output.

Disk /dev/sdf: 8006 MB, 8006926336 bytes
247 heads, 62 sectors/track, 1021 cylinders
Units = cylinders of 15314 * 512 = 7840768 bytes

   Device Boot      Start         End      Blocks  Id System
/dev/sdf1               1         511     3912696  83 Linux
/dev/sdf2             512        1021     3905070  83 Linux


Back to table of contents


Using fdisk

This chapter will show briefly the usage of fdisk. First of all unmount the device (via device manager or console) bevore using fdisk. Of course you need to know the device name, e.g. /dev/sdf as in the example of the previous chapter. You can use the command mount to check if the device is mounted or not. If the device name is not displayed, for example when using UUID (Universally Unique Identifier) (standard from DMM), the command blkid helps.

Start the programm as follows.

fdisk /dev/sdf

You will see: Fdisk is ready to manipulate Partitions. If you push m and confirm with ↵ Enter, all availiable options are displayed.

Command (m for help): 

Here is an overwiew of the most important options.

Function Description
d Delete a partition.
n Create a new partition.
p Show the partition informations of the device.
q Quit fdisk, without applying the changes.
w Applies all the changes and quits the program.


Example - delete and create a partition

This chapter explains how to delete and create a partition. For this example we use an USB Stick with the device name /dev/sdf. The different actions of the example are marked in red text. Goal of the example is to learn the basic functions of fdisk ;)

root@dm8000:/# fdisk /dev/sdf => start fdisk for the device

Command (m for help): p => with p you can see the actual partitioning, here one partition: /dev/sdf1

Disk /dev/sdf: 8006 MB, 8006926336 bytes
247 heads, 62 sectors/track, 1021 cylinders
Units = cylinders of 15314 * 512 = 7840768 bytes

   Device Boot      Start         End      Blocks  Id System
/dev/sdf1               1        1021     7817766  83 Linux

Command (m for help): d => d deletes the existing partition
Selected partition 1

Command (m for help): p => p displays no partition, only the Raw Device

Disk /dev/sdf: 8006 MB, 8006926336 bytes
247 heads, 62 sectors/track, 1021 cylinders
Units = cylinders of 15314 * 512 = 7840768 bytes

   Device Boot      Start         End      Blocks  Id System

Command (m for help): n => n for creating a new partition
Command action
   e   extended
   p   primary partition (1-4)
p => p for creating a primary partition
Partition number (1-4): 1 => enter the partition number, in this case 1
First cylinder (1-1021, default 1): Using default value 1 => Define the start of the partition, confirm with ↵ Enter.
Last cylinder or +size or +sizeM or +sizeK (1-1021, default 1021): Using default value 1021 => Define the end
of the partition, confirm with ↵ Enter.

Command (m for help): p => p shows 1 partition ;)

Disk /dev/sdf: 8006 MB, 8006926336 bytes
247 heads, 62 sectors/track, 1021 cylinders
Units = cylinders of 15314 * 512 = 7840768 bytes

   Device Boot      Start         End      Blocks  Id System
/dev/sdf1               1        1021     7817766  83 Linux

Command (m for help): w => w starts the partitioning and ends the program 
The partition table has been altered!

Calling ioctl() to re-read partition table

root@dm8000:/#


With the command fdisk -l you can check the result. The partitioning is finished and the device is ready for further actions.

Format with the desired file system (e.g. ext3), is possible with the following command. The name (label) for the device is in this example usb. Check with 'mount' if the partition is mounted, the device needs to be unmounted before formating.

mkfs.ext3 -L usb /dev/sdf1


A file system check can be performed on an unmounted partition with the following command.

fsck.ext3 -p /dev/sdf1


Now the device can be used and mounted by the system. Use the device manager (DMM or BluePanel) or the command line...


Example - create two partitions

In this example 2 primary partitions are created on the USB Stick. The device is /dev/sdf with a capacity of 8GB. The first partition has a size of 4GB and the remaining capacity will be used for the second partition. The different actions of the example are marked in red text.

root@dm8000:/# fdisk /dev/sdf => start fdisk for the device

Command (m for help): p => with p you can see the actual partitioning, here one partition: /dev/sdf1

Disk /dev/sdf: 8006 MB, 8006926336 bytes
247 heads, 62 sectors/track, 1021 cylinders
Units = cylinders of 15314 * 512 = 7840768 bytes

   Device Boot      Start         End      Blocks  Id System
/dev/sdf1               1        1021     7817766  83 Linux

Command (m for help): d => d deletes the existing partition
Selected partition 1

Command (m for help): p => p displays no partition, only the Raw Device

Disk /dev/sdf: 8006 MB, 8006926336 bytes
247 heads, 62 sectors/track, 1021 cylinders
Units = cylinders of 15314 * 512 = 7840768 bytes

   Device Boot      Start         End      Blocks  Id System

Command (m for help): n => n for creating a new partition
Command action
   e   extended
   p   primary partition (1-4)
p => p for creating a primary partition
Partition number (1-4): 1 => enter the partition number, in this case 1
First cylinder (1-1021, default 1): Using default value 1 => Define the start of the partition, confirm with ↵ Enter.
Last cylinder or +size or +sizeM or +sizeK (1-1021, default 1021): +4GB => Define size of the first partition, in the example +4GB

Command (m for help): n => n for creating the second partition
Command action
   e   extended
   p   primary partition (1-4)
p => p for creating a primary partition
Partition number (1-4): 2 => enter the partition number, in this case 2 for the second
First cylinder (512-1021, default 512): Using default value 512 => Define the start of the second partition, confirm with ↵ Enter.
Last cylinder or +size or +sizeM or +sizeK (512-1021, default 1021): Using default value 1021 => Define the end
of the second partition, confirm with ↵ Enter.

Command (m for help): p => p shows both partitions ;)

Disk /dev/sdf: 8006 MB, 8006926336 bytes
247 heads, 62 sectors/track, 1021 cylinders
Units = cylinders of 15314 * 512 = 7840768 bytes

   Device Boot      Start         End      Blocks  Id System
/dev/sdf1               1         511     3912696  83 Linux
/dev/sdf2             512        1021     3905070  83 Linux

Command (m for help): w => w starts the partitioning and ends the program 
The partition table has been altered!

Calling ioctl() to re-read partition table
root@dm8000:/# 


With the command fdisk -l you can check the result. The partitioning is finished and the device is ready for further actions.

Format with the desired file system (e.g. ex43), is possible with the following command. The name (label) for the first partition is in this example usb, the second partition is usb1. Check with 'mount' if the partitions are mounted, the device needs to be unmounted before formating.

mkfs.ext4 -L usb /dev/sdf1
mkfs.ext4 -L usb1 /dev/sdf2

A file system check can be performed on an unmounted partition with the following command.

fsck.ext4 -p /dev/sdf1
fsck.ext4 -p /dev/sdf2

Now the partitions can be used and mounted by the system. Use the device manager (DMM or BluePanel) or the command line...