Raspi 2: Move system root to usb-SSD

By openhabian setup you mean this will automatically move everything to the ssd?.. if so could you do that for the pi3 as well?!

Have done some scripting but I need to test it, not sure if I have time for it this weekend.

If the bash script works fine, I’ll try to integrate it into openhabian-setup.sh.
Maybe I’ll need some guidance …

does show the following at my RPi2:

NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda           8:0    0 29.8G  0 disk
mmcblk0     179:0    0   30G  0 disk
├─mmcblk0p1 179:1    0  128M  0 part /boot
└─mmcblk0p2 179:2    0 29.9G  0 part /

When I call the fdisk command, I get the following output:

Welcome to fdisk (util-linux 2.25.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0x8c1f768e.

Command (m for help):

I quit using “w” getting the following output:

The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

But when I try to create the filesystem, I get the following error:

mke2fs 1.42.12 (29-Aug-2014)
The file /dev/sda1 does not exist and no size was specified.

Any ideas?

Thanks,
Boby

Seems not to be a noob tutorial, because it is assumed to do some things while being in the fdisk tool. For noobs like me: Here’s what I did for creating a partition:

Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-62533295, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-62533295, default 62533295):

Created a new partition 1 of type 'Linux' and of size 29.8 GiB.

Command (m for help): w

Besides this: Great tutorial, thank you! Just moved my root fs within a few minutes. Thumbs ub!

Yes, you’re right, I didn’t describe the creation of the partion in detail, sorry for that.

The problem is that the disk can have already partions from its former life, so that you need to delete them before you can create one big (sda1) partion.

In the script to automate the process I’m using cfdisk, it has the command --delete to delete all partions (as far as I understand it), but I didn’t make progress with it the last few days.

I hope it fully works out for you now.

@ThomDietrich: I’ve integrated the process into openhabian-setup.sh now, see the PR

2 Likes

Merged! Thank you very much :wink:

Hi all,

Sorry to revive an old thread, but I’m trying to set up the file system on my SSD but I get the following message:

Can anyone help me with this? Does it mean my installation is on my SSD? This is a fresh install of OpenHABian.

sudo df:

Many thanks in advance

Hi,
sorry to hear that.

What does

cat /boot/cmdline.txt

say?

Hi Peter,

Thanks for your response.

The command shows the following:

I don’t understand a word but hope it helps :slight_smile:

Hi Craig,

that helps (at least a bit :-).

If that’s the cmdline.txt that one would get straight from setting up a new openhabian image, then “moye system root to usb” would not work for the time being.

You said that you did a fresh install of openhabian. Does that mean that you downloaded an openhabian-image and wrote that onto the SDcard via something like etcher or dd?

Are you using some kind of bootmanager like NOOBS or berryboot?

Hi Peter,

My fresh installation was done using Win32 Disk Imager to write the image to hear SD card. After a long while I could hen SSH to Openhabian.

On my previous installation I ran the ‘move root system to SSD’ option and it worked fine. I’ve tried a couple of times now with the same issue.

I only boot using the Openhabian image, no boot managers or anything like that. Really stumped now

Hi Craig,

it seems as if the reference to the root-partion for the bootloader has changed from an absolut reference (“root=/dev/mmcblk0p2”) to the usage of the partion uuid (root=PARTUUID=…).

I guess a quick fix for you would be to edit cmdline.txt (sudo nano /boot/cmdline.txt) and to replace the part

root=PARTUUID=3a958045-02
with
root=/dev/mmcblk0p2

Afterwards reboot and then it should work again.
Beware that there is a slight chance that the system is rendered unbootable after the change, so it would be wise to make a backup copy of the working cmdline.txt.
The type of the boot-partion is fat32, therefore it is easy accessible from a windows-machine.

I’ll try to make a fix for the issue so that it’s working out of the box again.

Peter

IMPORTANT ADDITION:
Please also check your /etc/fstab. If the root-partion is referenced there via partion uuid, that need to be changed also to /dev/mmcblk0p2 before using the function “move system root …”

Hey guys, the issue is actually not new, there was another user seeing the same thing. I didn’t have the time to fix this yet. @peter_juenger if you’d like throw a PR my way :wink:

Hi @ThomDietrich,

I’ve created a PR for that issue. Tested with new partuuid syntax and also old style dev / partion names, works fine here.

Hi @peter_juenger,

Please let me know when it is ready and I would be happy to test it.

Cheers,

Craig

Hi Peter,

The suggestion to edit cmdline.txt worked in that the file system was copied to SSD. After that however my connection times out on reboot :frowning:

My fstab looks like this…

changed to…

When the fix is in place on the openhabian-config menu please let me know and I would be happy to test it again.

Cheers

Merged. Please “Update” and try again :wink:

Thanks @peter_juenger for the excellent fix!

Hi guys,

This morning a did a fresh OpenHabian install und update, the process worked fine again until reboot. After reboot I cannot connect…

Is there any info I can provide to help?

Hi Craig,

doesn’t sound good. But I’ve no clue what went wrong.

I’ve installed the openhabian image here from scratch once again and moved the system to my ssd.
After rebooting everything is fine, I had no problem to connect again.

So the question for me is, wheter the fix is faulty or some other problem (hardware or connection issues) occured.

If it is a problem with moving the system to the usb-device, then it should be suciffient to put the SDcard in an external cardreader and copy back cmdline.txt.sdcard to cmdline.txt to make your PI boot again.