Hi I am very new to Raspberry Pi environment, so looking for a bit of help to format a usb hard disk drive. I ran lsblk
and got
sda 8:0 0 37.3G 0 disk
sda1 8:1 0 37.3G 0 part
looking on web, if tried the following sudo mkfs.ext4 /dev/sda1 -L USB40gb
. It did something but when I tried to mount the drive again, it still showed the files that were there before and I can not create new file/folder "Error creating directory: Permission denied"
I am writing this from my Windows 8.1 PC so I can not cut and paste from the Pi. Trying to format its output is a bit hard.
Oh, there is nothing written after the word part
above. There use to be /media/USB40gb
so I have done something because this has disappeared. I am using PCManFM 0.9.10
It does not have a format option, which would make life a lot easier, but then its not Windows.
I think I am running the basic Linux OS for the Pi. It boots to a graphic environment, but I do not know how to advise what it is. I think its OpenBox 2.0.4
PS: I reran the format string above but this time I changed the label to read USB37gb
. I did this to confirm that I was in fact formatting the right drive. Low and behold, it actually formatted the drive, wiping everything from it. Great … testing it by creating a new folder on the drive and get error message Permission Denied!
So I have fixed the formatting issue by trial and error but still can't use the drive…
Best Answer
If you are connected to the RasPi with a terminal window or via ssh use fdisk to view and recreate the partitions. (make sure you are root,
su - root
orsudo -s
)while in fdisk you can verify the partitions with the the
p
commandUse the
d
command to delete existing partition, thenp
again to verify it is goneuse the
n
command creates a new partition, usep
for primary partition, Enter to default to partition 1, Enter to select first sector and Enter again to select last sector. This gives the whole disk to your new partition.now use the
p
command again to see your new partitionthe changes need to be written to the partition table, so use the
w
command to commit.run the
fdisk -l
command to see your disk which will now include /dev/sda1Now you can make your file system. Use the mkfs command.
after the superblocks are created and you get a prompt you are ready to mount your disk create a mount point, say you want it to be "mydisk"
now mount it
use
df
to verify disk is mounted. If you reboot you will need to remount it (you might want to add it to /etc/fstab)try writing a file to the disk
was the file created or did you get an err?