Fdisk (en): Unterschied zwischen den Versionen
Mfgeg (Diskussion | Beiträge) |
|||
(13 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
Zeile 1: | Zeile 1: | ||
− | |||
− | |||
− | |||
{|width="40%" | {|width="40%" | ||
|[[Bild:deutsch.png]] - [[Fdisk|in Deutsch]] | |[[Bild:deutsch.png]] - [[Fdisk|in Deutsch]] | ||
|[[Bild:english.png]] - [[Fdisk (en)|in English]] | |[[Bild:english.png]] - [[Fdisk (en)|in English]] | ||
|} | |} | ||
− | + | '''[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 [[ | ||
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. | 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. | ||
Zeile 15: | Zeile 10: | ||
<br/> | <br/> | ||
− | {{ | + | {{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 67: | Zeile 59: | ||
fdisk /dev/sdf | fdisk /dev/sdf | ||
− | You will see: Fdisk is ready to manipulate Partitions. If you push | + | 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 92: | Zeile 84: | ||
| width="600px" | Applies all the changes and quits the program. | | width="600px" | Applies all the changes and quits the program. | ||
|} | |} | ||
− | |||
− | |||
− | |||
Zeile 103: | 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 112: | 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 | + | 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 123: | 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 | + | 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 | + | 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 141: | 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 162: | Zeile 152: | ||
Now the device can be used and mounted by the system. Use the device manager (DMM or BluePanel) or the command line... | Now the device can be used and mounted by the system. Use the device manager (DMM or BluePanel) or the command line... | ||
− | |||
− | |||
− | |||
Zeile 173: | 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 182: | 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 | + | 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 193: | 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 | + | 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 | + | 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 | + | 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 221: | 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 243: | Zeile 231: | ||
− | + | [[Kategorie:Basics (en)]] | |
+ | [[Kategorie:Instructions (en)]] |
Aktuelle Version vom 29. November 2012, 12:16 Uhr
- in Deutsch | - 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).
Attention! (Wrong) manipulations of existing partitions can result in loss of data. A backup of data is a must before using the program. |
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. |
Inhaltsverzeichnis
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...