Fdisk (en): Unterschied zwischen den Versionen

Aus Gemini-Wiki
Zur Navigation springen Zur Suche springen
Zeile 25: Zeile 25:
  
 
{{Hinweis|Fdisk can handle partitions up to 2TB. With Images based on OE2.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 OE2.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.}}
 +
  
 
Back to [[#top | table of contents]]
 
Back to [[#top | table of contents]]
 +
  
 
= Show informations of all partitions =
 
= Show informations of all partitions =

Version vom 20. August 2012, 20:55 Uhr

Deutsch.png - in Deutsch English.png - in English
The Gemini Project

Partitioning with the command line

Fdisk (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 attention.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 OE2.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.


Back to table of contents


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.


Back to table of contents


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 => no partition displayed, 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...


Back to table of contents


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 => no partition displayed, 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...


Back to overview: Gemini-Wiki:English Portal or Mainpage