Headless Recovery with Persistent Ubuntu Live USB
As some of you know, recently my Samsung NC10 netbook screen was smashed in an unfortunate accident. I have since replaced this with the excellent Sammy N210 but was at a loss where to begin recovering data from the NC10.
Of course, the obvious solution was unscrew and take out the hard drive, however these Netbooks are tightly built, and since I’m still considering the possibility of replacing the screen, I don’t want to create any superficial damage to the case.
So I googled for options, initially hoping to snag a Linux liveCD that would automatically boot with sshd in order for me to log in remotely.
Aside from some vague forum references to Knoppix and editing configuration files, I got nowhere. However what did occur to me was that Ubuntu LiveCD on a usb flash drive can be set to be persistent so it saves any changes including packages and settings.
The following steps are what I did to get access to my netbook data despite having a smashed screen, without needing to take out the hard drive, hook up an external monitor or building my own distro. Hopefully it may be useful for anyone finding themselves in a similar situation.
This is by no means a silver bullet. You will require the following setup for this to work:
- The system with the broken screen must be capable of booting from USB.
- The Bios must already be set to boot from USB (unless you have some way to set it without a screen).
- A second ‘puter with sshd installed and running.
This will not work with a LiveCD, it needs to be a USB pen drive so that changes can be easily saved on the drive.
- Download an ISO of Ubuntu or Netbook Remix, which is what I used, and then use the Startup Disk Creator to create a live USB pen drive – check the box for persistent mode (“Stored in reserved extra space”).
- Run the LiveUSB and when it boots to desktop open a terminal and type:
sudo apt-get update
sudo apt-get install openssh-server - When installing openssh on a LiveCD/USB you need a password to log in remotely. This can be done 1 of 2 ways, either by setting ‘passwd’ for the default ubuntu user or creating a new user. NerdNotes.org offers a nice and easy tutorial. In practice I found that when I rebooted the liveUSB for some reason the default ubuntu user ‘lost’ the password so I had to create a new user instead.
- If you have created a new user, be sure to add the username to the admin group, giving root privileges:
- Test the ssh daemon by logging in remotely to the machine you will use for recovery. If you are prompted for a key then type ‘yes’ and hit enter:
- Then make sure you can ssh back to your ubuntu LiveUSB. You may also want to do a quick reboot and test run to see if you can ssh without problems and without touching the LiveUSB keyboard.
- Now shutdown the LiveUSB and plug it into your headless netbook/laptop, switch it on and let it boot up, it should take about 30 seconds to boot automatically after the menu and then another 30-45 seconds before you can ssh in.
- Create a directory you are going to use to copy all your files from your netbook.
- Once you can ssh to the LiveUSB, you want to mount your hard disk partition.
- It should now be easy after this to grab your files and scp them back to your curent system, whether you previously had Windows or Ubuntu (or other distro) Linux installed. However if like me, you had an encrypted home partition, then keep following the steps:
I got the original instructions for this from Dustin Kirklands blog – nb: I needed to use ecryptfs-add-passphrase in order to record my passphrase manually before mounting the encrypted directory. - Finally you can do a secure copy from your netbook back to your host pc:
sudo adduser <username> admin
ssh username@hostname
wafitz@ $ mkdir /media/bkup
wafitz@ubuntu$ sudo fdisk -l
Device Boot Start End Blocks Id System /dev/sda1 1 182 160101883+ 82 Linux swap / Solaris /dev/sda2 * 53782 60802 69389632 7 HPFS/NTFS
wafitz@ubuntu$ sudo mount /dev/sda1 /mnt
wafitz@ubuntu$ sudo mount -o bind /dev /mnt/dev
wafitz@ubuntu$ sudo mount -o bind /dev/shm /mnt/dev/shm
wafitz@ubuntu$ sudo mount -o bind /proc /mnt/proc
wafitz@ubuntu$ sudo mount -o bind /sys /mnt/sys
wafitz@ubuntu$ sudo chroot /mnt
root@ubuntu$ su - wafitz
wafitz@ubuntu$ ecryptfs-add-passphrase --fnek
wafitz@ubuntu$ ecryptfs-mount-private
Enter your login passphrase:
Warning: Using default salt value (undefined in ~/.ecryptfsrc) Inserted auth tok with sig [xxx] into the user session keyring
wafitz@ubuntu$ cd $HOME
wafitz@ubuntu$ ls -a
wafitz@ubuntu$ scp -pr * wafitz@:/media/bkup
If you have found this post whilst searching for a solution and this helps you, please let me know. Even more so, if this method can be refined or improved then I’d also like to read your comments!