LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   why unable to open /dev/sda5(6) using fdisk? (https://www.linuxquestions.org/questions/linux-newbie-8/why-unable-to-open-dev-sda5-6-using-fdisk-893051/)

mei0fei 07-21-2011 07:22 PM

why unable to open /dev/sda5(6) using fdisk?
 
administrator@ubuntu:/dev$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/loop0 7.5G 4.4G 2.8G 61% /
none 431M 640K 431M 1% /dev
none 438M 192K 438M 1% /dev/shm
none 438M 104K 438M 1% /var/run
none 438M 0 438M 0% /var/lock
/dev/sda6 32G 15G 18G 46% /host
/dev/sda5 32G 9.0G 24G 29% /media/软件
administrator@ubuntu:/dev$ fdisk /dev/sda5

Unable to open /dev/sda5

Tinkster 07-21-2011 08:07 PM

Because it's a partition, and fdisk only operates on whole devices.

mei0fei 07-21-2011 08:23 PM

o, thank you! but where can I find the whole device? I have only a hard disk on my computer. I want to list partitions on this hard disk using fdisk.

TobiSGD 07-21-2011 08:31 PM

The whole disk is /dev/sda so that the command to list the partitions on it is
Code:

sudo fdisk -l /dev/sda

Tinkster 07-21-2011 08:33 PM

The simple rule here is: use the device you saw/wanted, and chop of the digit.
So, instead of
Code:

fdisk /dev/sda5
do
Code:

fdisk -l /dev/sda
That's the raw (whole) device, the numbers you see are the numbers
of the respective partitions.

I added that -l as a "safety measure". While you can obviously
use fdisk and then interactively display the information you're
after, it's safer to use the -l switch, which makes fdisk output
the partition table and some other information, and quit. No risk
of accidentally re-writing (destroying?) your partitioning.



Cheers,
Tink

mei0fei 07-21-2011 09:03 PM

thank you! I see the partitions on my hard disk.


All times are GMT -5. The time now is 09:34 AM.