slafochmed
Posts: 2
Joined: Wed Oct 01, 2014 2:15 pm

partition confusion

Wed Oct 01, 2014 2:35 pm

Hi there, perhaps some of you can resolve my linux confusion about my strange partitions in raspbian. I would like to understand. The confusion is certainly because of my strange setup, so I will describe what I did.
First here is my confusion:
I have an external harddisk and I do

Code: Select all

sudo fdisk -l
Disk /dev/sda: 750.2 GB, 750156374016 bytes
255 heads, 63 sectors/track, 91201 cylinders, total 1465149168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x7feb07f7

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1        2047        1023+  ee  GPT
/dev/sda2            2048     1023999      510976    b  W95 FAT32
/dev/sda3   *     1024000  1464944639   731960320   83  Linux
I think I created this partitioning on a MintLinux with gparted. I put a FAT32 partition for Windows PC with the drivers to recognize EXT2, so that I can access the EXT2 on Windows PCs.
Now, if I want to do a

Code: Select all

sudo e2fsck /dev/sda3
e2fsck 1.42.5 (29-Jul-2012)
e2fsck: No such device or address while trying to open /dev/sda3
Possibly non-existent or swap device?
Now, the solution is that the ext2 file system is not on sda3, but on sda2!

Code: Select all

sudo e2fsck -C 0 /dev/sda2
e2fsck 1.42.5 (29-Jul-2012)
cosmos700 was not cleanly unmounted, check forced.
Pass 1: Checking inodes, blocks, and sizes
sudo e2fsck -C 0 /dev/sda2cosmos700: |=====                                     cosmos700: |============================                            - 50.7%
So the correct way is to have the check run on sda2. There is also no sda3 in /dev .
I can access all my files and I mount them with autofs and a label to /media/cosmos700 and no problems so far.
I am also using NFS to share it on the network. Working fine.
But I really wonder about why fdisk shows different partitions than there actually are?
Perhaps it is my lacking knowledge about partitioning. Perhaps it is something about primary, extended and logical partitions?
I would be happy if some expert can explain this to me. :)

User avatar
Jednorozec
Posts: 809
Joined: Sun Nov 24, 2013 2:17 pm
Location: Deposit, NY

Re: partition confusion

Thu Oct 02, 2014 12:10 pm

I think that the problem is that you're using fdisk on a disk with a GPT partition table. Try using gdisk instead. I always use gparted rather than those other two programs.
The most important leg of a three legged stool is the one that's missing.
It's called thinking. Why don't you try it sometime?

cpc464
Posts: 239
Joined: Tue Jul 08, 2014 5:10 pm
Contact: Website

Re: partition confusion

Thu Oct 02, 2014 4:47 pm

or it might be a mix up. The "system" column in fdisk just denotes the "type" code for that partition, which does not actually have to match the type of the file system therein

Please post the output of a simple "mount" command.
Unix engineer since 1989

User avatar
rpdom
Posts: 17170
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: partition confusion

Thu Oct 02, 2014 5:33 pm

cpc464 wrote:or it might be a mix up. The "system" column in fdisk just denotes the "type" code for that partition, which does not actually have to match the type of the file system therein

Please post the output of a simple "mount" command.
Judging by the fact that "There is also no sda3 in /dev", I'd say that the GPT partitioning was confusing things. I haven't looked at GPT recently, but I'd hazard a guess that the kernel sees the GPT table with just two partitions in and uses that, but fdisk only understands the MS-DOS partition table and sees some compatibility table with the GPT table showing as an extra partition.

cpc464
Posts: 239
Joined: Tue Jul 08, 2014 5:10 pm
Contact: Website

Re: partition confusion

Fri Oct 03, 2014 9:24 am

It is hard to second guess what might have happened on the OP's system. I would recommend looking at mount and df -hT and swapon -s as a next step, because they will at least confirm the FS type on every mounted partition.

GPT disks are unlikely to be the cause. IIRC, fdisk will complain loudly if it encounters a GPT partition table. For example here is an ESXi system with GPT disks attached:

Code: Select all

~ # fdisk -l
***
*** The fdisk command is deprecated: fdisk does not handle GPT partitions.  Please use partedUtil
***
Found valid GPT with protective MBR; using GPT
and on Red Hat 6.5 and on Raspbian latest (no actual GPT disks attached)

Code: Select all

$ strings /sbin/fdisk | grep -i gpt
WARNING: GPT (GUID Partition Table) detected on '%s'! The util fdisk doesn't support GPT. Use GNU Parted.
partition table format (GPT).
Unix engineer since 1989

slafochmed
Posts: 2
Joined: Wed Oct 01, 2014 2:15 pm

Re: partition confusion

Sun Oct 05, 2014 3:42 pm

Thank you all for your advice.
I see now that fdisk is not the best program to use.
I am setting up a 2 Terabyte disk to be my main storage and will partition it by parted instead.

Here are some commands that you recommended for further output. (The fdisk output is still the same as in my first post).

Code: Select all

###  sudo mount

/dev/root on / type ext4 (rw,noatime,data=ordered)
devtmpfs on /dev type devtmpfs (rw,relatime,size=219764k,nr_inodes=54941,mode=755)
tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=44788k,mode=755)
tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /run/shm type tmpfs (rw,nosuid,nodev,noexec,relatime,size=89560k)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
/dev/mmcblk0p1 on /boot type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,errors=remount-ro)
rpc_pipefs on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw,relatime)
nfsd on /proc/fs/nfsd type nfsd (rw,relatime)
/etc/auto.media on /media type autofs (rw,relatime,fd=6,pgrp=2229,timeout=300,minproto=5,maxproto=5,indirect)

Code: Select all

###  content of
###  /etc/auto.media

cosmos700 -fstype=auto LABEL="cosmos700"

Code: Select all

### sudo df -hT

Filesystem     Type      Size  Used Avail Use% Mounted on
rootfs         rootfs     30G  2.4G   26G   9% /
/dev/root      ext4       30G  2.4G   26G   9% /
devtmpfs       devtmpfs  215M     0  215M   0% /dev
tmpfs          tmpfs      44M  280K   44M   1% /run
tmpfs          tmpfs     5.0M     0  5.0M   0% /run/lock
tmpfs          tmpfs      88M     0   88M   0% /run/shm
/dev/mmcblk0p1 vfat       56M  9.7M   47M  18% /boot

Code: Select all

###  sudo swapon -s

Filename                                Type            Size    Used    Priority
/var/swap                               file            102396  0       -1
... and I see now a warning in my fdisk -l output that I missed during my first post, thanks for the hints!

Code: Select all

WARNING: GPT (GUID Partition Table) detected on '/dev/sdc'! The util fdisk doesn't support GPT. Use GNU Parted.
... and yes, you are right, the parted output looks better:

Code: Select all

sudo parted /dev/sdc
GNU Parted 2.3
Using /dev/sdc
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print
Model: ST375064 0A (scsi)
Disk /dev/sdc: 750GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start   End    Size   File system  Name  Flags
 1      1049kB  524MB  523MB  fat16
 2      524MB   750GB  750GB  ext2

(parted)
:) Thanks!

Return to “Advanced users”