2

I have been attempting to convert my drives filesystem over to EXT4, purely because it will always be plugged into the Raspberry Pi thus it is just much better to go through ext4.

I am having a problem, however - regardless of what I do, blkid always reports the drive as a "ntfs" drive, which is not what I want.

I have been through fdisk, deleted the only partition on the drive, created a new linux partition (which works), wrote the changes to disk and reboot - however, upon reboot and mount the drive is constantly working (i.e the disk is spinning and head is moving) regardless of the fact that nothing is actually happening

There is obviously something wrong here, the drive has an LED that indicates the drive is busy and that is constantly flickering now I have tried to set up an ext4 filesystem, once I format back to ntfs or fat, it is fine.

Any help would be appreciated!

edit:

Should probably state I have a Raspberry Pi Model B and a Samsung M3 portable HDD. HDD is plugged into a powered USB Hub.

edit2:

The process I have been taking:

  • Start by checking blkid, make sure the device has been recognized and check the filesystem (at this point, it has always been ntfs)
  • Type sudo fdisk /dev/sda, delete any existing partitions
  • Create a brand new, primary partition, onto the HDD. Make it span the full drive.
  • Write the changes to the harddrive, reboot the Pi
  • Next, I run sudo mkfs.ext4 /dev/sda1 to format the new partition with ext4
  • Once again, I reboot.
  • Finally, I mount the partition using sudo mount /dev/sda1 /media/usbhdd

And this where I am now, the External Harddrive is constantly working (identified by the LED blinking, and the drive itself vibrating)

After all of this, here are the results:

/proc/partitions

major minor  #blocks  name

179        0    7565312 mmcblk0
179        1      57344 mmcblk0p1
179        2    7503872 mmcblk0p2
  8        0  976762584 sda
  8        1  976761560 sda1

sudo fdisk /dev/sda partition print

Disk /dev/sda: 1000.2 GB, 1000204886016 bytes
81 heads, 63 sectors/track, 382818 cylinders, total 1953525168 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: 0x2acf4408

Device Boot      Start         End      Blocks   Id  System
/dev/sda1         2048  1953525167   976761560   83  Linux

It might also be worth noting that, at this point, blkid does not display the drive at all.

Jake Ball
  • 191
  • 8
  • I'm not seeing where in your list of steps you formatted the new partition as some variation of ext. You might want to try the drive on a desktop linux, even if it's a live CD/USB boot. – Chris Stratton Feb 23 '15 at 21:22
  • @ChrisStratton, Popped the Harddrive in, checked blkid - found it was ntfs. Typed in fdisk, selected the correct drive, deleted the partition on the drive, added a new Linux partition, wrote the changes. Then, I ran "mkfs -t ext4" followed by the location of the disk, to format into ext4. Finally, I mounted the drive and this is where I am at. blkid reports ntfs, upon reboot, it still reports ntfs – Jake Ball Feb 23 '15 at 21:48
  • If you really, really, really want to start from scratch you can unmount it and dd a couple of megabytes of /dev/zero over the start of the major block device, wiping out the partition table and everything - but be really careful you are doing that to the correct target device! You should be able to verify that you have done it with hexdump, and still see your zeros after a connection cycle. – Chris Stratton Feb 23 '15 at 21:56
  • @ChrisStratton Started doing that for the whole device about an hour ago (without realizing) and it is still going. Not sure how long it is going to take, I'll keep you informed. – Jake Ball Feb 23 '15 at 22:05
  • 1
    You don't need to wipe the whole thing, just the partition table. I'd expect a pi to take a long time to wipe a modern hard drive, especially if you didn't set a large blocksize. – Chris Stratton Feb 23 '15 at 22:07
  • Stopped that process, rebooted and blkid no longer lists the device. fdisk also doesn't reference the device, so I am unable to change anything. – Jake Ball Feb 23 '15 at 22:17
  • What is the exact command you are using for fdisk? What does dmesg say about the drive? – Chris Stratton Feb 23 '15 at 22:20
  • oops! I wasn't using sudo when attempting to view fdisk. dmesg shows the Pi has found the drive, and complains about an unknown partition table. - fdisk now shows the drive, stating it does not contain a valid partition table – Jake Ball Feb 23 '15 at 22:25
  • There's a command in fdisk to make a brand new partition table. You may want to make your table, write it, then reconnect/reboot before making filesystems - there's some caching of the partition table in the kernel, and fdisk it supposed to tell it to re-read that but perhaps that is not working on your system. – Chris Stratton Feb 23 '15 at 22:32
  • Yeah, just ran through that, created a primary partition that covers the whole drive. When opened the device in fdisk (sudo fdisk /dev/sda). It did state "Building a new DOS disklabel with disk identifier 0x4721f36a." which surely DOS is not what I want to do? Anyway - created a Primary partition, formatted the partition with ext4 and rebooted. Once again, the pi is seeing the drive as a ntfs filesystem. am i doing something wrong here? – Jake Ball Feb 23 '15 at 22:42
  • Edit the output of fdisk's print of the partition table into your question, and also the contents of /proc/partitions – Chris Stratton Feb 23 '15 at 22:45
  • @ChrisStratton I have added the requested info into the question itself. – Jake Ball Feb 23 '15 at 22:54
  • Do NOT use fdisk to format partition (read man pages). sudo mkfs.ext4 /dev/sda should work – Milliways Feb 23 '15 at 22:56
  • @Milliways as far as I know, I haven't? I have created the partition within fdisk, and then formatted with mkfs -t ext4. I assume that is what you mean? – Jake Ball Feb 23 '15 at 22:58
  • No mkfs.ext4, although they probably boil down to the same. I did this just a couple of days ago. I use parted to create partitions (the man pages have a lot of info on tools, some of which are old). Your fdisk shows /dev/sda1p1. What does sudo parted print show? – Milliways Feb 23 '15 at 23:06
  • Are you running fdisk on /dev/sda1 instead of /dev/sda ? When I run it on my linux box, the start of my output is "Disk /dev/sda: xx GB" not /dev/sda1 as you show. – Chris Stratton Feb 23 '15 at 23:10
  • To both above: This is sending me round in a circle here. I have outlined the exact process I have been taking when trying to achieve this in the question. I have also attached updated fdisk print and /proc/partitions. I hope this can help you understand exactly what I am doing. – Jake Ball Feb 23 '15 at 23:37
  • The question @ChrisStratton asked (and I wondered myself) is "what command did you type for fdisk" You have posted the output, but not command – Milliways Feb 23 '15 at 23:43
  • @Milliways I have used sudo fdisk /dev/sda to add a primary partition which is labelled as /dev/sda1. – Jake Ball Feb 23 '15 at 23:45
  • Your new fdisk output looks a lot more workable than your previous one, where you seemed to have a partition inside a partition. Try rebooting now and see if you can format it. – Chris Stratton Feb 23 '15 at 23:59
  • @ChrisStratton I have formatted, rebooted and the drive no longer appears in blkid. I can mount the drive, but back to the issue where the drive is constantly in use despite the Pi being idle (which I wasn't having when it was formatted as NTFS). – Jake Ball Feb 24 '15 at 00:06

1 Answers1

1

This is getting out of hand in comments. sudo fdisk -l /dev/sdb should show something like:-

sudo fdisk -l /dev/sdb

Disk /dev/sdb: 60.0 GB, 60011642880 bytes
255 heads, 63 sectors/track, 7296 cylinders, total 117210240 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: 0xd84ce8f8

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *        2048     2099199     1048576    b  W95 FAT32
/dev/sdb2         2099200    44044287    20972544    5  Extended
/dev/sdb5         2101248    44044287    20971520   83  Linux

Your comment "sudo fdisk /dev/sda to add a primary partition onto /dev/sda1" does not make sense. /dev/sda1 is a primary partition.

Run sudo mkfs.ext4 /dev/sda1

Milliways
  • 59,840
  • 31
  • 101
  • 209
  • What I have tried to say is, when I added the primary partition, which is /dev/sda1, it was added AFTER I used the command sudo fdisk /dev/sda. I tried to edit my comment to make that more clear however unfortunately I was over the 5 minute time. I have run the command, sudo mkfs.ext4 /dev/sda, it asks if I am sure I want to format the whole device, I type yes - it finishes its business and I reboot the Pi, blkid does not report the drive. dmesg states "unknown partition table". – Jake Ball Feb 23 '15 at 23:58
  • 1
    If you format the entire drive as a filesystem, then no, you won't have a partition table. Normally, you would format your partition /dev/sda1 (or whatever it is), not the entire device. If you have formatted the whole thing, consider starting over with fdisk to make a new partition table and partition, reboot (unusual, but just to be sure, given your difficulties), then make a filesystem in the first partition, not the entire device. – Chris Stratton Feb 24 '15 at 00:11
  • Hi guys, I left this overnight and had another bash just now. sudo blkid now returns the drive, and also reports ext4 as the filesystem (hooray!). I now have the problem where the Harddrive is constantly flickering and in use after mounting (with sudo mount /dev/sda1 /media/usbhdd as I was just testing before editing fstab), which I can tell both by the LED and the drive itself vibrating. Is there any reason for this? It feels to me as if this will drastically degrade the lifetime of my drive, so I would like to fix it. – Jake Ball Feb 24 '15 at 20:28
  • This should be another question Depends on the mount settings The best was is to modify /etc/fstab and make sure noatime is used. proc /proc proc defaults 0 0 UUID=xxxxx-yyyy /mnt/PiData ext4 defaults,noatime,noauto 0 0 NOTE It is more usual to mount in /mnt rather than /media (either will work) – Milliways Feb 24 '15 at 23:03
  • You only need to use noatime on SSDs; HDD with spinning-disk-platters can take a write operation to a file's metadata each time that file on the disk is written AND READ, though there is a tiny bit of extra time / cpu cycles needed to do. – SlySven Dec 22 '15 at 02:58