gen 2)

this is obsolete doc -- see http://doc.nethence.com/ instead

How to rescue a FreeBSD 8.3 powered Dedibox SC (gen1 & gen 2) 

 

Introduction 

Problem is, the Ubuntu LiveCD (the only one provided by online.net, unfortunately) doesn't provide read-write support for the UFS2 file system type (CONFIG_UFS_FS_WRITE=y is obviously missing in the linux kernel configuration). 

 

Prepare your environment 

Start the rescue system (Ubuntu amd64) and proceed, 

sudo su -
export LANG=C
export TERM=xterm

 

Read-only 

Note that it's the BSD slide you would have to mount, not the DOS partition dedicated to FreeBSD, check with, 

dmesg | less ==> search for 'sda'

I got, 

[    2.029969] sd 0:0:0:0: [sda] 976773168 512-byte logical blocks: (500 GB/465 GiB)
[    2.030036] sd 0:0:0:0: [sda] 4096-byte physical blocks
[    2.030201] sd 0:0:0:0: [sda] Write Protect is off
[    2.030260] sd 0:0:0:0: [sda] Mode Sense: 00 3a 00 00
[    2.030312] sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[    2.031914]  sda: sda1
[    2.031917]  sda1: <bsd: sda5 sda6 >
[    2.032844] sd 0:0:0:0: [sda] Attached SCSI disk

so you can always mount read-only if you want, 

mkdir /lala/
mount -t ufs -r -o ufstype=ufs2 /dev/sda5 /lala/

 

Read-write workaround using Qemu 

Install Qemu, 

cd /
wget "ftp://ftp.free.fr/mirrors/ftp.freebsd.org/ISO-IMAGES-amd64/8.3/FreeBSD-8.3-RELEASE-amd64-bootonly.iso"
apt-get update
apt-get install qemu
qemu-system-x86_64 -no-kvm -hda /dev/sda -cdrom FreeBSD-8.3-RELEASE-amd64-bootonly.iso -curses -boot d 

note. adding the '-no-kvm' option is important otherwise the underlying system (Ubuntu LiveCD) crashes. 

choose, 

6 (shift and 6 on french keyboard, the layout has passed through) --> boot loader prompt
OK boot -s

(kernel boots...) 

/bin/ksh

note. your file system (here /dev/ad0s1a) get's mounted automaticly, you just have to fsck and re-mount it read-write. 

fsck -y /dev/ad0s1a
mount -o rw /

and proceed with your fixes. 

 

Once you are done you can simply, 

shutdown -p now

and you will get out of Qemu (otherwise you should have to), 

# Ctrl+Alt+2 to open QEMU monitor and 'quit'
# or Ctrl+A+C when you're using -nographics

Ref. http://comments.gmane.org/gmane.linux.embedded.yocto.general/3410 

 

Additional notes 

Alternatives through the network assuming you've got another box close-by at online.net

- using iSCSI but the tgt module doesn't seem to be available, 

- using dd through the network. 

 

References 

Error trying to mount FreeBSD/UFS partition from FreeNAS: http://askubuntu.com/questions/85189/error-trying-to-mount-freebsd-ufs-partition-from-freenas 

Gentoo: Mounting UFS2: http://geek00l.blogspot.fr/2007/02/gentoo-mounting-ufs2.html 

Mounting UFS in read/write under Linux (debian): http://ghantoos.org/2009/04/04/mounting-ufs-in-readwrite-under-linux/ 

QEMU Emulator User Documentation: http://wiki.qemu.org/download/qemu-doc.html