USB HDD


29 posts   Page 1 of 2   1, 2
by jgearing » Wed Jul 11, 2012 2:27 pm
Having failed to get my Pi to boot from my usb hard drive
i find the capacity of the drive is reduced from 256gb to 75 meg
is there some equivalent to SD Formatter to get it back to normal so I
can start again from scratch

Thanks

JG
Posts: 51
Joined: Sat Mar 03, 2012 6:33 pm
by RaTTuS » Wed Jul 11, 2012 2:36 pm
fdisk
what sort of drive ?
what instructiuons where you following
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe
User avatar
Posts: 9270
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
by jgearing » Wed Jul 11, 2012 3:01 pm
Sorry, I'm a bit lost
I've tried different methods as described in this forum without much luck
which is why I wanted to make a fresh start. I was trying to format from windows but always finish up with 75 meg. What would be the syntax for fdisk, would I have to point it to the drive

thanks
JG










i wa
Posts: 51
Joined: Sat Mar 03, 2012 6:33 pm
by jmanel » Thu Jul 12, 2012 5:46 am
Hi,
Sorry to ask, but do you have a 256GB SD card?
To initialize the card I followed the instructions found on the text of the magpi magazine and i got a card to boot the pi (i used the process described for linux but supose the windows works too)
I think that to begin the process another time you do not need to format the drive. But if you want you have to tell windows to initialize the external disk.
Anyone knows if your card is supported???
Hope you get it working
Josep
Posts: 1
Joined: Thu Jul 12, 2012 5:24 am
by Beerhunter » Thu Jul 12, 2012 7:42 am
jmanel. The OP said he/she has a Hard Disk, rather than an SD card.
Posts: 21
Joined: Wed Jun 27, 2012 10:23 am
by RaTTuS » Thu Jul 12, 2012 9:55 am
OP,
if this is a hard disk [256GB ]
and you have now somehow made it 75Mb
and you want to re-initialise it back to full size
then
if using windows you will have to go into [start | setting | control panel | adminsitrative tool | computer management | disk management ] and then re partition the drive from there ,
if using linux then use
fdisk
or parted
or
gparted
or cfdisk
if this is a SD card that has been nobbled then there are windows tools for this...

however
OP
we need more info - please be clear in what you have done - give us links to what you have followed and what you want to do
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe
User avatar
Posts: 9270
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
by jgearing » Thu Jul 12, 2012 11:10 am
Thanks RaTTuS
I got it back in windows following your instructions.
I was trying to use the drive to boot and run the Raspi
I installed squeeze on it using win 32 diskimager as you would with a card
I then tried to follow the instructions as given by andreword at the thread at
viewtopic.php?f=26&t=9117&p=112959#p112959
After that it all went pear shaped as you can see from the thread, as I recall
I then tried another method given on the thread and then gave up until i bought
a new wiki approved power hub which was more reliable. At that point I decided to reformat and reinstall squeeze on the drive. This is where we came in.
I am also a bit worried that as the hub would not supply enough power even using a Y cable I used a separate usb power supply to power the drive. This also seems to be feeding power into the Pi. Could this damage the Pi and is there a better way of doing it. Perhaps it may be best to forget the whole thing,
it's just that I had a spare drive and thought I'd try to use it
Would it be safer to run the pi from the hub?

Thanks for your help

JG
Posts: 51
Joined: Sat Mar 03, 2012 6:33 pm
by arturo777 » Thu Jul 12, 2012 3:54 pm
Hi,

It is only possible to start the system from an SD card - i.e. you must have one installed for the pi to work.

This needs to have the firmware on it and the initial boot image (e.g. a kernel). Using special kernel parameters or UBoot (a secondary bootloader that provides more options - still in heavy development), it may be possible to load an OS from other sources.

It is probably to start with just an SD card and then go from there :)
Posts: 28
Joined: Sat Mar 24, 2012 10:02 am
by RaTTuS » Fri Jul 13, 2012 1:05 pm
OK ,
here goes.
on my debian wheezy [it did work for squeeze also]
created the image on the SD card -
booted RPi successfully
sudo apt-get update
sudo apt-get upgrade
sudo rpi-update [if you've not got it then it's worth gettting it]
reboot
make sure everything seems to work ok. - I'm a console man so I don't bother with X - this will come later
sudo fdisk -l
this should show your SD card only
plug in USB HD ,
sudo fdisk -l
this should show another HD probbaly at /dev/sda
sudo fdisk /dev/sda
d
[all partitions]
n
[new partitions create 2 , one that takes up most of the disk and a small 2Gig one at the end that will be used as swap [type 82]]
sudo mkfs.ext4 /dev/sda1
this creates an ext4 filesystem
sudo mkswap /dev/sda2
this makes the swap system [but does not activate it]
sudo dd if=/dev/mmcblk0p2 of=/dev/sda1 bs=32M conv=noerror,sync
this copies the 2nd partition of your sdcard to the 1st partition of your hard disk [possibly this is what you want - though mmcblk0p2 may not be correct for you see the output of fdisk easlier
sudo e2fsck -f /dev/sda1
this checks the file system
sudo resize2fs /dev/sda1
this expands the data to fill the partition

now it gets a bit tricky
sudo cp /boot/cmdline.txt /boot/cmdline.ori
[make a backup of the original file]
sudo vi /boot/cmdline.txt
or your editor of choice
change the /dev/mmcblk0p2 / to be
/dev/sda1
you are changing the boot device from the SD card partition 2 to the Hard disk partition 1

you should also
sudo mount /dev/sda1 /mnt
and change in
/mnt/etc/fstab
the root device also [/dev/mmcblk0p2 /
to be
/dev/sda1
also change the swap parititon to be
/dev/sda2

then
sudo sync
sudo shutdown -r now

then when it comes back it will boot off the SD card and transfer to be running from the HD.

if it fails - use another machine to
copy /boot/cmdline.ori to /boot/cmdline.txt
and then reboot back.

YMMV

good luck
Last edited by RaTTuS on Tue Jun 24, 2014 12:02 pm, edited 1 time in total.
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe
User avatar
Posts: 9270
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
by jgearing » Fri Jul 13, 2012 1:35 pm
Thanks for that
When I pluck up some courage I'll give it a try
I'll let you know how I get on

Thanks again

JG
Posts: 51
Joined: Sat Mar 03, 2012 6:33 pm
by jillesdotcom » Sat Jul 21, 2012 12:03 pm
It is actually resize2fs ;-)

root@raspberrypi:~# resizefs /dev/sda1
-su: resizefs: command not found

root@raspberrypi:~# resize2fs /dev/sda1

resize2fs 1.42.4 (12-Jun-2012)
Resizing the filesystem on /dev/sda1 to 36621093 (4k) blocks.
The filesystem on /dev/sda1 is now 36621093 blocks long.





Furthermore dd takes forever, if you want to know progress of the dd use following command in another window:

root@raspberrypi:~# killall -USR1 dd

You will see status in original window:

863+0 records in
863+0 records out
28957474816 bytes (29 GB) copied, 4774.26 s, 6.1 MB/s


Kind regards,
Jilles Groenendijk
@JillesDOTCOM
Posts: 1
Joined: Sat Jul 21, 2012 11:57 am
by wb2ifs » Fri Feb 01, 2013 5:36 pm
This is what I did. Based on the previous comments:
1. Logged in to debian with the pi/raspberry account
2. sudo su (switch to su mode without the root password)
3. ls /dev
            (list all devices, depending on the type of drive)
            Look for /dev/sda
            Note your SD card will be listed as /dev/mmcblk0 (with partitions p1, p2, p3)
4. fdisk /dev/sda (obviously change this to match your HDD configuration)
5. p (print the partition table)
6. d <Enter> <number> (for each partition to delete them)
7. n <Enter> p <Enter> 1 <Enter> (Choose appropriate size for your main file area)
8. n <Enter> p <Enter> 2 <Enter> (make sure to have left yourself some swapspace)
9. You can set the boot flag if you want, but it isn’t needed since your booting from the SD card
10. mkfs.ext4 /dev/sda1 (format the first partition)
11. mkswap /dev/sda2 (format the swap space)
12. sudo dd if=/dev/mmcblk0p2 of=/dev/sda1 bs=8M conv=sync,noerror #[change sda1 to whatever you had made it in the fdisk above]
13. wait
14. sudo e2fck /dev/sda1
15. resize2fs /dev/sda1
16. sudo nano /boot/cmdline.txt
17. change mmcblk0p2 to sda1
18. sudo nano /etc/fstab (add swap partition)
19. sudo sync && sudo sync
20. sudo reboot

Jesse Alexander WB2IFS/3
Jesse Alexander, WB2IFS/3
wb2ifs@gmail.com
Twitter: @scipoet
http://www.linkedin.com/in/jessealexander
"Mastery is the ability to make that which is complex appear simple and easily understood."
User avatar
Posts: 9
Joined: Sun Oct 14, 2012 7:09 pm
Location: FN18ns Clinton, MD, USA
by vhanchon » Wed Feb 13, 2013 12:28 pm
Just a quick thank you to RaTTus for his excellent post.
Posts: 1
Joined: Wed Feb 13, 2013 12:26 pm
by vsayanam » Thu Apr 04, 2013 8:20 am
I saw this post only after trying a 20GB USB drive and pre-programmed 8GB SD card in Linux Fedora. After connecting both the devices, I ran 'dd' command to transfer all Linux files from SD card to HDD (formatted earlier in ext4). After copying (takes a lot of time), I changed 'cmdline.txt' file to change the boot from /dev/mmcblk0p2 to /dev/sda1. It appears to be working all right. But 'df -h' command does not show the 20GB HDD. Is it OK?
I had to use only a few commands for this operation.
Posts: 12
Joined: Tue Nov 06, 2012 11:10 am
by RaTTuS » Thu Apr 04, 2013 8:29 am
vsayanam wrote:I saw this post only after trying a 20GB USB drive and pre-programmed 8GB SD card in Linux Fedora. After connecting both the devices, I ran 'dd' command to transfer all Linux files from SD card to HDD (formatted earlier in ext4). After copying (takes a lot of time), I changed 'cmdline.txt' file to change the boot from /dev/mmcblk0p2 to /dev/sda1. It appears to be working all right. But 'df -h' command does not show the 20GB HDD. Is it OK?
I had to use only a few commands for this operation.

you will have to expand the rootfs
as a dd will just copy the contents and leave it as the original size.
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe
User avatar
Posts: 9270
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
by vsayanam » Thu Apr 04, 2013 10:02 am
Thank you for the quick reply. I had already run 'sudo resize2fs /dev/sda1' as given in your post. I got messages 'freeing already freed blocks' or something like that which scrolled very fast. After seeing your reply, I ran the command again and I got a message: "The file system is already 4882944 blocks long. Nothing to do!". But 'sudo fdisk -l' says that /dev/sda1 has 19531776 blocks. Why the difference? Does the 20GB HDD have full 20GB for use? Thanks in advance.
Posts: 12
Joined: Tue Nov 06, 2012 11:10 am
by vsayanam » Thu Apr 04, 2013 10:11 am
Sorry.. I was in a hurry to respond. When I ran 'df -h' after sending the reply, I saw the size of rootfs as 19G out of which 1.8G has been used. Earlier, I was not getting this. Thanks again.
Posts: 12
Joined: Tue Nov 06, 2012 11:10 am
by RaTTuS » Thu Apr 04, 2013 10:17 am
no worries - as long as your happy now ;-p
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe
User avatar
Posts: 9270
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
by giovani » Sun Sep 15, 2013 10:54 am
sudo resize2fs /dev/sda1
this expands the data to fill the partition


I have successfully done all the steps above until resize2fs. By now, after running resize2fs to expand the partition to use the 20GB I left available (btw I had to umount /dev/sda1 first because the first try resize2fs told it was not possibile to resize online) it has been over 12 hours that the command is running, and no other output than:

Code: Select all
pi@raspberrypi /mnt $ sudo resize2fs /dev/sda1
resize2fs 1.42.5 (29-Jul-2012)



Is this normal? How long could it take for resize2fs to resize to a 20GB partition (6GB were copied using dd previously)? It's an ext4 filesystem.
Posts: 17
Joined: Fri Sep 06, 2013 6:38 am
Location: Rome, Italy
by giovani » Wed Oct 16, 2013 5:08 pm
just for the record... after almost 100 hours running I have done a reboot and a new
sudo fsck.ext4 /dev/sda1
then run resize2fs again and all finished within about 2 minutes :-) go figure...
Posts: 17
Joined: Fri Sep 06, 2013 6:38 am
Location: Rome, Italy
by planetscape » Wed Nov 27, 2013 12:16 am
Hello. First, thanks for this post.

Got it working with only minor modifications for my unique situation.

However, my external HDD apparently "times out", sleeps, or hibernates after a certain period of inactivity, which makes it impossible for me to log in via SSH (using PuTTY) once it does. (I'm running headless.)

The ext HDD is a Toshiba Canvio 3.0 Plus, 1.5TB.

Furthermore, while I can physically power down the Pi and restart, "sudo reboot" does not seem to work: the Pi lights up, however, I cannot SSH in.

I do run:

Code: Select all
   sudo apt-get -y update
   sudo apt-get -y dist-upgrade
   sudo rpi-update


regularly.

Any ideas? (Other than "use another drive", please; that is not really an
option right now.)

Thanks in advance!

(Cross-posted to:
The Raspberry Pi Hobbyist: Running From an External Hard Drive)
Posts: 2
Joined: Tue Nov 26, 2013 9:52 pm
by RaTTuS » Wed Nov 27, 2013 9:19 am
leave a screen attached until you have fixed the issues,
does
dmesg
say anything of use after the HD has timed oout?
how are you powering it ?
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe
User avatar
Posts: 9270
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
by tedhale » Wed Nov 27, 2013 9:16 pm
Thanks for letting me know you posted here also. Here, the info will help more people.

try this:
apt-get install sdparm
then
sdparm --clear=STANDBY /dev/sdX
(where X is the appropriate letter for your drive)

if that works, then you can run it at each boot by adding it to /etc/rc.local

As a last resort, you could do a cron job to access the drive regularly to keep it awake.

crontab-e
(this will open the cron config file using nano as the edittor)
Add this line (again with the correct letter for your drive)
*/5 * * * * /bin/touch /dev/sdX &>/dev/null

This will access the device every 5 minutes.
Hope this helps.
- Ted B. Hale
http://raspberrypihobbyist.blogspot.com
User avatar
Posts: 114
Joined: Thu Sep 20, 2012 4:52 pm
Location: Williamsburg, VA, USA
by veteranz_guian25 » Fri Nov 29, 2013 6:22 pm
u just have to format it to LINUX, then if you want u can make partition for the drive and then mount it (not literally) using mount commands.. this way u could use your HDD in your raspi for storage :D
Posts: 14
Joined: Mon Sep 23, 2013 3:38 pm
by giovani » Fri Nov 29, 2013 9:45 pm
veteranz_guian25 wrote:u just have to format it to LINUX, then if you want u can make partition for the drive and then mount it (not literally) using mount commands.. this way u could use your HDD in your raspi for storage :D


is it enough to format and mount the drive as ext4 to avoid the auto-sleep function? I am about to get my toshiba canvio as well...
Posts: 17
Joined: Fri Sep 06, 2013 6:38 am
Location: Rome, Italy