Well, this follows up my earlier threads about rolling your own u-boot build to support the GoFlex Home (but it works equally well on a range of other devices, YMMV) once you've got them built, you'll probably want to ditch the stock OS in favour of something else, and Debian's pretty robust and has a nice new recent release "Wheezy"
This is based around Vlads Howto for squeeze, and with only slight variation you can also build an emdebian platform if that's what floats your boat.
I also go through some steps to deploy the file system to a USB stick and then transfer from USB stick to your device (hard disk deployment - it's slightly too large to fit in UBIFS on a GoFlexHome, my next task is to deploy emdebian to UBIFS)
Right, as before in my Howto roll your own u-boot and Howto roll your own linux kernel howtos, I'm assuming that you're using Debian for the build. I'm going to do this slightly differently to other guides - my work scenario prevented me from downloading the packages directly, so I built the image from dvd .iso image, I then added individual packages as required.
So as before, create a file to store your rootfs
now the rest needs to be done as root (although you may also be able to preceed these commands with sudo) - the remainder of this instruction assumes you're logged in as root
If you've not already got them then now's a good time to download an install a few utilities
Now, put your CD image into the drive (this is where it's useful using a VirtualBox VM for development - connect .ISO to drive) if you want to mount the .ISO without burning a CD, then you can mount it like this:
Then begin the bootstrap - you'll need to choose how you're going about it:
For Debian CD-ROM install:
For Debian regular download:
Now we're almost ready to chroot into our file system, but a bit of qemu preparation first:
As in Vlads instructions, you should see "I have no name!@hostname:/#" - so lets finish it off
which should end with "I: Base system installed successfully." in which case exit and re-enter the chroot, and set the password:
If planning to download your packages, then omit the cdrom mount instruction
Enter your chosen root password.
Now, we're ready to build up the base system - for the GoFlexHome, the limit is 256Mb, but as you want some space, I'd be looking at limiting it to 200Mb. First, lets tell apt where to get stuff, configure locales and prevent the system from installing too much dross that's not required
For Debian CD-Rom install:
Finally, we're ready to install stuff
Now, select an appropriate language for yourself - always include en_US.UTF-8 as well as your own language and export your own language for a default
If this not going onto UBIFS, then I'd also suggest the following tools:
Some configuration next - first, lets kill one of the pesky udev rules that may change your network card assignment:
Setup TTY's (disable the virtual TTYs and turn on serial console)
Setup network interfaces:
setup a machine hostname (replace "RescueDeb" with whatever you feel appropriate:
Setup fw_env for reading/writing uboot environment variables (this must match whatever's in your uboot environment):
Basic fstab
And setup mtab
Now, exit the chroot and copy the .deb file you created earlier into it (I'm assuming that you compiled the source in your home area in kernel/linux-3.4.56) before re-entering the chroot and installing the .deb package:
This will install the kernel to /boot, however as the architecture isn't right (although it's running the arm binaries, it's still in an x86/64 system and flash-kernel fails)
Now to manually create the uImage and uInitrd files:
Take a 1GB (or larger) flash stick and plug it into your computer, have a look at dmesg to see where it's putting it
Right, we can see it's picked it up as sdg with three partitions, let's fdisk it and make into a bootable USB stick for our device
Delete all partitions (command "d" followed by partition number if there's more than one)
I build my sticks as three partitions - a rootfs (1Gb) partition as ext3, a swap and then a data partition in the rest of it, so the command sequence is:
Then to format the disks, remount them and copy the files across:
Now at this point, I will generally dismount my target file system and copy it to the data partition of my rescue drive, once booted, I can mount the data partition, mount the image and copy it across to the drive of my GoFlex
Now, you should be able to plug it into your GoFlex home and boot up. You should also have ssh access, so you can deploy the image as you see fit:
Assumes that the HDD is formatted appropriately, but setting that up's pretty easy (this will blank your hard disc drive):
This is based around Vlads Howto for squeeze, and with only slight variation you can also build an emdebian platform if that's what floats your boat.
I also go through some steps to deploy the file system to a USB stick and then transfer from USB stick to your device (hard disk deployment - it's slightly too large to fit in UBIFS on a GoFlexHome, my next task is to deploy emdebian to UBIFS)
Right, as before in my Howto roll your own u-boot and Howto roll your own linux kernel howtos, I'm assuming that you're using Debian for the build. I'm going to do this slightly differently to other guides - my work scenario prevented me from downloading the packages directly, so I built the image from dvd .iso image, I then added individual packages as required.
So as before, create a file to store your rootfs
dd if=/dev/zero of=rootfs.img bs=1M count=1024
now the rest needs to be done as root (although you may also be able to preceed these commands with sudo) - the remainder of this instruction assumes you're logged in as root
su mkfs.ext2 -F rootfs.img mount rootfs.img /mnt -o loop
If you've not already got them then now's a good time to download an install a few utilities
apt-get install debootstrap qemu-user-static binfmt-support
Now, put your CD image into the drive (this is where it's useful using a VirtualBox VM for development - connect .ISO to drive) if you want to mount the .ISO without burning a CD, then you can mount it like this:
mount debian-7.1.0-armel-DVD-1.iso /media/cdrom0 -o loop
Then begin the bootstrap - you'll need to choose how you're going about it:
For Debian CD-ROM install:
debootstrap --verbose --arch armel --variant=minbase --foreign --no-check-gpg wheezy /mnt file:///media/cdrom
For Debian regular download:
debootstrap --verbose --arch armel --variant=minbase --foreign wheezy /mnt http://ftp.uk.debian.org/debianFor Emdebian download: there are no .iso images on the official repositories at the moment, so you'll have to download
debootstrap --verbose --arch armel --variant=minbase --foreign wheezy-grip /mnt http://ftp.uk.debian.org/emdebian/grip /usr/share/debootstrap/scripts/wheezy
Now we're almost ready to chroot into our file system, but a bit of qemu preparation first:
cp /usr/bin/qemu-arm-static /mnt/usr/bin mount -t sysfs none /mnt/sys mount -t proc proc /mnt/proc mount -B /dev /mnt/dev mount -B /dev/pts /mnt/dev/pts chroot /mnt
As in Vlads instructions, you should see "I have no name!@hostname:/#" - so lets finish it off
/debootstrap/debootstrap --second-stage
which should end with "I: Base system installed successfully." in which case exit and re-enter the chroot, and set the password:
exit mkdir /mnt/media/cdrom mount -B /media/cdrom /mnt/media/cdrom chroot /mnt passwd
If planning to download your packages, then omit the cdrom mount instruction
Enter your chosen root password.
Now, we're ready to build up the base system - for the GoFlexHome, the limit is 256Mb, but as you want some space, I'd be looking at limiting it to 200Mb. First, lets tell apt where to get stuff, configure locales and prevent the system from installing too much dross that's not required
For Debian CD-Rom install:
apt-cdrom -m add /media/cdromFor Regular Debian downloaded:
cat <<END > /etc/apt/sources.list deb http://security.debian.org/ wheezy/updates main deb http://ftp.debian.org/debian/ wheezy main contrib non-free ENDFor Emdebian
cat <<END > /etc/apt/sources.list deb http://security.debian.org/ wheezy-grip/updates main deb http://ftp.uk.debian.org/debian/grip wheezy-grip main deb http://security.debian.org/ wheezy/updates main deb http://ftp.debian.org/debian/ wheezy main END
Finally, we're ready to install stuff
cat <<END > /etc/apt/apt.conf APT::Install-Recommends "0"; APT::Install-Suggests "0"; END apt-get update export LANG=C apt-get install apt-utils apt-get install dialog apt-get install locales
Now, select an appropriate language for yourself - always include en_US.UTF-8 as well as your own language and export your own language for a default
export LANG=en_UK.UTF-8
apt-get install module-init-tools isc-dhcp-client udev netbase ifupdown iproute openssh-server iputils-ping wget net-tools ntpdate uboot-mkimage u-boot-tools vim
If this not going onto UBIFS, then I'd also suggest the following tools:
apt-get install samba libpam-smbpass smbclient openbsd-inetd ftp-ssl vsftpd lighttpd cron anacron bash-completion hdparm rsync bzip2 unzip zip screen less usbutils psmisc man info logrotate fakeroot ethtool rsyslog usbmount
Some configuration next - first, lets kill one of the pesky udev rules that may change your network card assignment:
rm /lib/udev/rules.d/75-persistent-net-generator.rules
Setup TTY's (disable the virtual TTYs and turn on serial console)
echo 'T0:2345:respawn:/sbin/getty -L ttyS0 115200 linux' >> /etc/inittab sed -i 's/^\([1-6]:.* tty[1-6]\)/#\1/' /etc/inittab
Setup network interfaces:
cat <<END > /etc/network/interfaces auto lo eth0 iface lo inet loopback iface eth0 inet dhcp END
setup a machine hostname (replace "RescueDeb" with whatever you feel appropriate:
echo RescueDeb > /etc/hostname
Setup fw_env for reading/writing uboot environment variables (this must match whatever's in your uboot environment):
echo /dev/mtd0 0xA0000 0x20000 0x20000 >> /etc/fw_env.config
Basic fstab
cat <<END > /etc/fstab # /etc/fstab: static file system information. # # <file system> <mount point> <type> <options> <dump> <pass> tmpfs /tmp tmpfs defaults 0 0 END
And setup mtab
rm -f /etc/mtab ln -s /proc/mounts /etc/mtab
Now, exit the chroot and copy the .deb file you created earlier into it (I'm assuming that you compiled the source in your home area in kernel/linux-3.4.56) before re-entering the chroot and installing the .deb package:
exit cp /home/user/kernel/linux-image-3.4.56-kirkwood_0.1_armel.deb /mnt/usr/src chroot /mnt cd /usr/src dpkg -i linux-image-3.4.56-kirkwood_0.1_armel.deb
This will install the kernel to /boot, however as the architecture isn't right (although it's running the arm binaries, it's still in an x86/64 system and flash-kernel fails)
Now to manually create the uImage and uInitrd files:
mkimage -A arm -O linux -T kernel -C none -a 0x00008000 -e 0x00008000 -n Linux-3.4.56-kirkwood -d /boot/vmlinuz-3.4.56-kirkwood /boot/uImage mkimage -A arm -O linux -T ramdisk -C gzip -a 0x00000000 -e 0x00000000 -n initramfs-3.4.56-kirkwood -d /boot/initrd.img-3.4.56-kirkwood /boot/uInitrdNow we can exit the chroot, remove it's links and be ready to copy it onto something
exit umount /mnt/media/cdrom umount /mnt/dev/pts umount /mnt/dev umount /mnt/proc umount /mnt/sys rm /mnt/usr/bin/qemu-arm-static
Take a 1GB (or larger) flash stick and plug it into your computer, have a look at dmesg to see where it's putting it
dmesg | tail -n 30 [225454.245933] usb 2-1.1: USB disconnect, device number 34 [225460.055782] usb 2-1.1: new high-speed USB device number 36 using ehci-pci [225460.141942] usb 2-1.1: New USB device found, idVendor=0781, idProduct=5151 [225460.141949] usb 2-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [225460.141953] usb 2-1.1: Product: Cruzer Micro [225460.141957] usb 2-1.1: Manufacturer: SanDisk [225460.141960] usb 2-1.1: SerialNumber: 2204521D65818E21 [225460.142596] scsi24 : usb-storage 2-1.1:1.0 [225461.145387] scsi 24:0:0:0: Direct-Access SanDisk Cruzer Micro 8.01 PQ: 0 ANSI: 0 CCS [225461.145936] sd 24:0:0:0: Attached scsi generic sg6 type 0 [225461.146957] sd 24:0:0:0: [sdg] 7862911 512-byte logical blocks: (4.02 GB/3.74 GiB) [225461.147619] sd 24:0:0:0: [sdg] Write Protect is off [225461.147622] sd 24:0:0:0: [sdg] Mode Sense: 45 00 00 08 [225461.148265] sd 24:0:0:0: [sdg] No Caching mode page present [225461.148268] sd 24:0:0:0: [sdg] Assuming drive cache: write through [225461.151622] sd 24:0:0:0: [sdg] No Caching mode page present [225461.151628] sd 24:0:0:0: [sdg] Assuming drive cache: write through [225461.161918] sdg: sdg1 sdg2 sdg3 [225461.165012] sd 24:0:0:0: [sdg] No Caching mode page present [225461.165019] sd 24:0:0:0: [sdg] Assuming drive cache: write through [225461.165023] sd 24:0:0:0: [sdg] Attached SCSI removable disk [225462.355598] EXT4-fs (sdg3): recovery complete [225462.355608] EXT4-fs (sdg3): mounted filesystem with ordered data mode. Opts: (null) [225462.361044] EXT2-fs (sdg1): warning: mounting unchecked fs, running e2fsck is recommended
Right, we can see it's picked it up as sdg with three partitions, let's fdisk it and make into a bootable USB stick for our device
umount /dev/sdg* fdisk /dev/sdg
Delete all partitions (command "d" followed by partition number if there's more than one)
I build my sticks as three partitions - a rootfs (1Gb) partition as ext3, a swap and then a data partition in the rest of it, so the command sequence is:
Command (m for help): n Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): p Partition number (1-4, default 1): 1 First sector (2048-7862910, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-7862910, default 7862910): +1GB Command (m for help): n Partition type: p primary (1 primary, 0 extended, 3 free) e extended Select (default p): p Partition number (1-4, default 2): 2 First sector (1955173-7862910, default 1955173): Using default value 1955173 Last sector, +sectors or +size{K,M,G} (1955173-7862910, default 7862910): +512MB Command (m for help): t Partition number (1-4): 2 Hex code (type L to list codes): 82 Changed system type of partition 2 to 82 (Linux swap / Solaris) Command (m for help): n Partition type: p primary (2 primary, 0 extended, 2 free) e extended Select (default p): p Partition number (1-4, default 3): 3 First sector (2955173-7862910, default 2955173): Using default value 2955173 Last sector, +sectors or +size{K,M,G} (2955173-7862910, default 7862910): Using default value 7862910 Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.
Then to format the disks, remount them and copy the files across:
mkfs.ext3 -L rootfs /dev/sdg1 mkfs.ext3 -L data /dev/sdg3 mkdir /media/usb0 mount /dev/sdg1 /media/usb0 cp -a /mnt/* /media/usb0
Now at this point, I will generally dismount my target file system and copy it to the data partition of my rescue drive, once booted, I can mount the data partition, mount the image and copy it across to the drive of my GoFlex
umount /dev/sdg1 umount /mnt mount /dev/sdg3 /media/usb0 cp /home/user/rootfs.img /media/usb0 umount /dev/sdg3
Now, you should be able to plug it into your GoFlex home and boot up. You should also have ssh access, so you can deploy the image as you see fit:
ssh root@RescueDeb mkdir /media/data mount /dev/sdb3 /media/data mount /media/data/rootfs.img /mnt -o loop mkdir /media/hdd mount /dev/sda1 /media/hdd cp -a /mnt/* /media/hdd/
Assumes that the HDD is formatted appropriately, but setting that up's pretty easy (this will blank your hard disc drive):
ssh root@RescueDeb fdisk /dev/sdaRepeat the selections as we did for setting up the flash memory stick partitions - although I would be inclined to provide a bit more space for expansion - maybe 7.5GB root, 512M swap and the remainder as data - partition schemes are a whole other game
mkfs.ext3 /dev/sda1 mkfs.ext3 /dev/sda3although there's nothing to prevent you using ext4 (just make sure that you include it as an option in your kernel build)