I really want to move root onto my external hdd, but I'm running into a road block.
I have all the usb, usb-storage, and scsi drivers compiled into my kernel, so there is no need to load modules from the filesystem to see the device. The kernel boot spam does in fact see the external drive.
However, I can't boot into the external drive, because /dev/sda doesn't exist until udev runs and populates /dev. I've looked at the static /dev entries, and sda sdaX ect are there before udev runs, but are not usable.
The moment udev and uevents finish running the drive becomes usable, and I have swap running on the device fine, because swap gets mounted after udev runs.
So I guess I need to set up a initramfs to make this work... but I'm having a hell of a time getting that set up and working... Partly because I've never done it before, and partly because the Pi's loader firmware has some serious limitations with initramfs at the moment because the size of the initramfs isn't passed into the kernel and has to be supplied manually in the cmdline.txt.
Anyone have this working?
root on an external hdd?
11 posts
- Posts: 9
- Joined: Fri Jul 06, 2012 11:54 pm
Solved.
It was never udev that was causing my troubles.
The problems was the discovery time on my cheap usb <> sata bridge. In order to finally get the system to boot off /dev/sda2 I ended up have to add
to my cmdline.txt
boot_delay=1000 causes the kernel to pause for one second between each kernel message printed to the console during boot. This caused enough time to pass for my bridge to be discovered and the /dev/sdaX entries to be populated. A side effect of this is that there is nothing on the HDMI port except a color bar test pattern for about the first 90 seconds of the boot. After enough of the drivers have been enabled the display comes to life and the rest of the boot process can continue. I tried just using a very long rootdelay time, to pause before mounting root, but it didn't end up seeing the sata bridge.
Oh well. This works. It's dirty, and it takes a while to boot, but that's ok. I'm putting this Pi together as a bench unit for development and testing.
The speedup after it's booted is amazing. emerge --sync takes no longer to run that on a regular desktop machine. Very pleased.
It was never udev that was causing my troubles.
The problems was the discovery time on my cheap usb <> sata bridge. In order to finally get the system to boot off /dev/sda2 I ended up have to add
- Code: Select all
boot_delay=1000
rootdelay=10
to my cmdline.txt
boot_delay=1000 causes the kernel to pause for one second between each kernel message printed to the console during boot. This caused enough time to pass for my bridge to be discovered and the /dev/sdaX entries to be populated. A side effect of this is that there is nothing on the HDMI port except a color bar test pattern for about the first 90 seconds of the boot. After enough of the drivers have been enabled the display comes to life and the rest of the boot process can continue. I tried just using a very long rootdelay time, to pause before mounting root, but it didn't end up seeing the sata bridge.
Oh well. This works. It's dirty, and it takes a while to boot, but that's ok. I'm putting this Pi together as a bench unit for development and testing.
The speedup after it's booted is amazing. emerge --sync takes no longer to run that on a regular desktop machine. Very pleased.
- Code: Select all
pi ~ # bonnie
File './Bonnie.843', size: 104857600
Writing with putc()...done
Rewriting...done
Writing intelligently...done
Reading with getc()...done
Reading intelligently...done
Seeker 2...Seeker 3...Seeker 1...start 'em...done...done...done...
-------Sequential Output-------- ---Sequential Input-- --Random--
-Per Char- --Block--- -Rewrite-- -Per Char- --Block--- --Seeks---
Machine MB K/sec %CPU K/sec %CPU K/sec %CPU K/sec %CPU K/sec %CPU /sec %CPU
100 2970 95.1 32031 61.0 29251 68.8 3171 99.3 100491 99.1 4982.6 98.4
- Posts: 9
- Joined: Fri Jul 06, 2012 11:54 pm
Hi
I would really like to know how you did this. I am running Ubuntu on my desktops and servers, and would like to get into rpi as a dev box, but I need the faster disk access and storage capabilities of an external drive. I'm not quite a noob as far as linux is concerned so some guidance would be appreciated.
please and thanks
fred
I would really like to know how you did this. I am running Ubuntu on my desktops and servers, and would like to get into rpi as a dev box, but I need the faster disk access and storage capabilities of an external drive. I'm not quite a noob as far as linux is concerned so some guidance would be appreciated.
please and thanks
fred
- Posts: 2
- Joined: Thu Aug 02, 2012 8:14 am
FredAlbrecht wrote:Hi
I would really like to know how you did this. I am running Ubuntu on my desktops and servers, and would like to get into rpi as a dev box, but I need the faster disk access and storage capabilities of an external drive. I'm not quite a noob as far as linux is concerned so some guidance would be appreciated.
please and thanks
fred
general instructions
dd the main image fs to your hard drive partition
i.e.
either straight from the .img or from the sd card image
then
sudo e2fsck /dev/sda1
sudo resizefs /dev/sda1
mount that drive somewhere i.e.
sudo mount /dev/sda1 /mnt
edit /mnt/etc/fstab and point root and swap to somewhere on /dev/sda [leave /boot as it is]
umount that drive
edit /boot/cmdline.txt and change teh rootfs from
mmblk0p2 to sda1
reboot
and all should be fine
[assuming that the drivers for your usb hd controller are complied into the kernel
if it fails then just revert /boot/cmdline.txt
1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX - Prosliver FTW
Thanks. I'm also reading the other instructions in other threads. Looks like this is going to be fun. 
- Posts: 2
- Joined: Thu Aug 02, 2012 8:14 am
viewtopic.php?f=26&t=10914&p=129474&hilit=resizefs#p122476
mayhelp - see the additional comments where I had made a small typo but you should be able to follow
mayhelp - see the additional comments where I had made a small typo but you should be able to follow
1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX - Prosliver FTW
FredAlbrecht wrote:Hi
I would really like to know how you did this. I am running Ubuntu on my desktops and servers, and would like to get into rpi as a dev box, but I need the faster disk access and storage capabilities of an external drive. I'm not quite a noob as far as linux is concerned so some guidance would be appreciated.
please and thanks
fred
It was really quite easy.
I just took one of the existing SD card images, and booted into it.
Plugged in my USB <> SATA bridge and external hard drive.
used fdisk to make a partition table on the drive with a parition for swap and root
made the filesystems in the normal way (I.E. mkswap /dev/sda1; mkfs.ext4 /dev/sda2)
mkdir /mnt/temp
mount /dev/sda2 /mnt/temp
cp -Rpvx / /mnt/temp
edited /etc/fstab to put root and swap into /dev/sda2 and /dev/sda1 respectively.
edited /boot/cmdline.txt to tell it root is now on /dev/sda2 and in my case to put in a boot delay. (I found that a delay as little as 32ms per line was enough to solve my issues. )
and rebooted.
When the system boots up after that it will use root and swap on the hdd, and leave the kernel and boot loader in the SD.
My cmdline.txt looks like ...
- Code: Select all
dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/sda2 boot_delay=32 rootdelay=10 rootwait
and my /etc/fstab looks like ...
- Code: Select all
/dev/mmcblk0p1 /boot vfat noauto,noatime 1 2
/dev/sda2 / ext4 noatime 0 1
/dev/sda1 none swap sw 0 0
- Posts: 9
- Joined: Fri Jul 06, 2012 11:54 pm
Why didnt you just root wait?
- Posts: 393
- Joined: Mon Jun 04, 2012 9:06 pm
- Location: Berkshire
aaa801 wrote:Why didnt you just root wait?
I did. Look at the cmdline.
The system didn't detect the new sata <-> usb bridge without the delay.
- Posts: 9
- Joined: Fri Jul 06, 2012 11:54 pm
Thanks RaTTuS, worked a charm. One question, though...
My /etc/fstab does not list the root partition. However everything works file. If I df, I find my root partition listed twice: as "rootfs" and as "/dev/root". There is no /dev/root however.
Everything seems fine; but I'd like to understand why it works without that fstab entry for /dev/sda1 as every other system I've ever worked on reqired it... ?
RaTTuS wrote:edit /mnt/etc/fstab and point root and swap to somewhere on /dev/sda
My /etc/fstab does not list the root partition. However everything works file. If I df, I find my root partition listed twice: as "rootfs" and as "/dev/root". There is no /dev/root however.
Everything seems fine; but I'd like to understand why it works without that fstab entry for /dev/sda1 as every other system I've ever worked on reqired it... ?
Raspberry Pi Utilities: https://github.com/johnlane/rpi-utils
For Raspberry Pi and Arch Linux
For Raspberry Pi and Arch Linux
- Posts: 38
- Joined: Fri Jul 20, 2012 8:26 pm
johnlane wrote:Thanks RaTTuS, worked a charm. One question, though...RaTTuS wrote:edit /mnt/etc/fstab and point root and swap to somewhere on /dev/sda
My /etc/fstab does not list the root partition. However everything works file. If I df, I find my root partition listed twice: as "rootfs" and as "/dev/root". There is no /dev/root however.
Everything seems fine; but I'd like to understand why it works without that fstab entry for /dev/sda1 as every other system I've ever worked on reqired it... ?
the root is made from the command line in /boot/cmdline.txt [because the GPU has to know where to look] so is not needed in the fstab earlier versions had it listed IIRC
in fact mine looks like
- Code: Select all
cat /etc/fstab
proc /proc proc defaults 0 0
/dev/mmcblk0p1 /boot vfat defaults 0 0
/dev/sda1 / ext4 defaults,noatime 0 0
/dev/sda4 swap swap defaults 0 0
# a swapfile is not a swap partition, so no using swapon|off from here on, use dphys-swapfile swap[on|off] for that
so / is mapped to /dev/sda1 but will probably be overridden by the cmdline.txt file
1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX - Prosliver FTW