geffers
Posts: 384
Joined: Sun Jun 24, 2012 6:25 am
Location: UK
Contact: Website

Change root in cmdline.txt

Fri Aug 16, 2019 4:35 pm

Folks,

Think I misunderstood something some time back that I read in an article somewhere.

In the cmdline.txt file in the /boot directory there is an entry as follows;
root=PARTUUID=c82337fe-02
which seems to allow setting the root directory to a different location.

Now I am thinking you need the operating system to load before it can recognise the attached storage device so what is the point of altering this location?

Geffers

ejolson
Posts: 3588
Joined: Tue Mar 18, 2014 11:47 am

Re: Change root in cmdline.txt

Fri Aug 16, 2019 4:48 pm

geffers wrote:
Fri Aug 16, 2019 4:35 pm
Folks,

Think I misunderstood something some time back that I read in an article somewhere.

In the cmdline.txt file in the /boot directory there is an entry as follows;
root=PARTUUID=c82337fe-02
which seems to allow setting the root directory to a different location.

Now I am thinking you need the operating system to load before it can recognise the attached storage device so what is the point of altering this location?

Geffers
You are right. The bootloader first loads the Linux kernel from the FAT partition. Once loaded the kernel consults the root= setting to know which device contains all the user and system files that are part of the operating system and everything else. Setting root to a device other than the SD card allows running, for example, from an external USB drive after the initial program load of the kernel is finished.

geffers
Posts: 384
Joined: Sun Jun 24, 2012 6:25 am
Location: UK
Contact: Website

Re: Change root in cmdline.txt

Sat Aug 17, 2019 10:12 am

Now obviously I've done something wrong then.

I copied the actual ext4 partition (not just files within, used gparted to copy partition) to an external drive, got the PARTUUID then checked ID same when plugged in the the Pi.

Then deleted the ext4 partition on the SD card having altered the location of root to the PARTUUID on the cmdline.txt

Didn't boot, tried twice but then thought perhaps I misunderstood the setup.

Worked in the past but then didn't delete the ext4 partition on the SD card, all appeared to work but then I was unsure where OS was actually working from even though I had changed the root location.

Geoff

User avatar
thagrol
Posts: 1851
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Change root in cmdline.txt

Sat Aug 17, 2019 10:37 am

You need to edit /etc/fstab to match the new location as well.
This space unintentionally left blank.

Roken
Posts: 299
Joined: Sun Dec 31, 2017 4:35 pm
Location: UK

Re: Change root in cmdline.txt

Sat Aug 17, 2019 10:54 am

thagrol wrote:
Sat Aug 17, 2019 10:37 am
You need to edit /etc/fstab to match the new location as well.
For clarity, that's /etc/fstab on the NEW root partition. But you can simply comment out the / mount in the new fstab.
Headless PI. OMG, someone cut it's head off. Oh, hang on. it didn't have one to start with.

User avatar
graysky
Posts: 92
Joined: Fri Apr 05, 2013 11:43 am
Location: /run/user/1000
Contact: Website

Re: Change root in cmdline.txt

Sat Aug 17, 2019 11:05 am

I think there is a kernel parameter you need to change as well.

User avatar
thagrol
Posts: 1851
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Change root in cmdline.txt

Sat Aug 17, 2019 11:19 am

graysky wrote:
Sat Aug 17, 2019 11:05 am
I think there is a kernel parameter you need to change as well.
Not in my experience. /boot/cmdline.txt and /etc/fstab on the new partition is all I've ever had to change.
This space unintentionally left blank.

User avatar
graysky
Posts: 92
Joined: Fri Apr 05, 2013 11:43 am
Location: /run/user/1000
Contact: Website

Re: Change root in cmdline.txt

Sat Aug 17, 2019 11:38 am

thagrol wrote:
Sat Aug 17, 2019 11:19 am
Not in my experience. /boot/cmdline.txt and /etc/fstab on the new partition is all I've ever had to change.
No, it's hardcoded:
On Arch ARM: https://github.com/archlinuxarm/PKGBUIL ... onfig#L517
On Raspbian: https://github.com/raspberrypi/linux/bl ... config#L47

Could be possible to override elsewhere, IDK.

User avatar
HawaiianPi
Posts: 4634
Joined: Mon Apr 08, 2013 4:53 am
Location: Aloha, Oregon USA

Re: Change root in cmdline.txt

Sat Aug 17, 2019 11:49 am

Which model PI?

What OS?

What are you using for a power supply?

What kind of drive are you attempting to load the OS from?


For systems not capable of true USB boot, the simplest solution is to clone the entire card to the USB drive (preferably with the SD Card Copier utility included with Desktop versions of Raspbian), then copy just the bootcode.bin file to a FAT32 formatted SD card. That will load and run the entire OS from the USB drive on all models up to the 3B+ (although the 3B+ can USB boot without a card as well).

The new Pi 4B does not currently support USB booting, and does not use the bootcode.bin file, so you do need to have /boot on the card (for now). In that case, clone the card to the USB drive, then copy the contents of the "boot" partition to a FAT32 formatted micro SD card. After the system boots, edit /etc/fstab to mount the SD card as /boot (followed by a reboot) so that firmware and kernel updates are properly applied.

Forum member RonR has some handy scripts that can simplify the process.
My mind is like a browser. 27 tabs are open, 9 aren't responding,
lots of pop-ups...and where is that annoying music coming from?

User avatar
thagrol
Posts: 1851
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Change root in cmdline.txt

Sat Aug 17, 2019 12:12 pm

graysky wrote:
Sat Aug 17, 2019 11:38 am
thagrol wrote:
Sat Aug 17, 2019 11:19 am
Not in my experience. /boot/cmdline.txt and /etc/fstab on the new partition is all I've ever had to change.
No, it's hardcoded:
On Arch ARM: https://github.com/archlinuxarm/PKGBUIL ... onfig#L517
On Raspbian: https://github.com/raspberrypi/linux/bl ... config#L47

Could be possible to override elsewhere, IDK.
For raspbian that's the default config (hint: it's in the filename). That's clearly overridden by /boot/cmdline.txt otherwise all those things that rely on changes to cmdline.txt (quirks for UAS devices, moving root partition, serial console, etc) wouldn't be possible.

Don't know about Arch as I don't use it but I'd expect iot to be the same.
This space unintentionally left blank.

tpylkko
Posts: 382
Joined: Tue Oct 14, 2014 5:21 pm

Re: Change root in cmdline.txt

Sat Aug 17, 2019 7:10 pm

If you boot with your current settings, what error do you get?

Milliways
Posts: 456
Joined: Fri Apr 25, 2014 12:18 am
Location: Sydney, Australia

Re: Change root in cmdline.txt

Sat Aug 17, 2019 11:43 pm

tpylkko wrote:
Sat Aug 17, 2019 7:10 pm
If you boot with your current settings, what error do you get?
With the new default settings there is a Splash screen and there are NO error messages for a missing root partition.

To clarify - if you select Splash screen on boot (default) this will be shown, with minimal messaging.

If the root partition is inaccessible the display will show 4 raspberries - but no error messages (and obviously no Splash screen).

If you restore text boot you will see boot messages, including errors e.g. indicating missing root fs.
Last edited by Milliways on Sun Aug 18, 2019 8:15 am, edited 1 time in total.

User avatar
thagrol
Posts: 1851
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Change root in cmdline.txt

Sun Aug 18, 2019 12:21 am

Milliways wrote:
Sat Aug 17, 2019 11:43 pm
tpylkko wrote:
Sat Aug 17, 2019 7:10 pm
If you boot with your current settings, what error do you get?
With the new default settings there is a Splash screen and there are NO error messages for a missing root partition.
If you restore text boot you will see them.
Which splash screen? The rainbow square from the early bootloader or the one shown when the GUI is starting? (loaded from /usr/share/plymouth/themes/pix/splash.png so your root partition must be mounted and accessable).

If the latter, try appending

Code: Select all

quiet splash
to /boot/config.txt and rebooting/power cycling.

If the former, something is very wrong with your system as it would appear that the initial boot loader can't find a FAT partition to boot from.

Edit:

A couple of other approaches:
  • If you have access to another Pi and haven't removed the neccessary stuff from cmdline.txt you can make a serial connection between them and monitor the boot messages via that.
  • Likewise if you access to a USB to 3.3v serial dongle and another computer.
  • If the hang is on the desktop/gui splas screen, trry scanning your network for that Pi. If it shows up try to ping it and to connect via ssh.
This space unintentionally left blank.

geffers
Posts: 384
Joined: Sun Jun 24, 2012 6:25 am
Location: UK
Contact: Website

Re: Change root in cmdline.txt

Tue Aug 20, 2019 10:08 pm

thagrol wrote:
Sat Aug 17, 2019 11:19 am
graysky wrote:
Sat Aug 17, 2019 11:05 am
I think there is a kernel parameter you need to change as well.
Not in my experience. /boot/cmdline.txt and /etc/fstab on the new partition is all I've ever had to change.
Thanks, that worked spot on. Soon as I altered fstab it worked fine.

Geffers

geffers
Posts: 384
Joined: Sun Jun 24, 2012 6:25 am
Location: UK
Contact: Website

Re: Change root in cmdline.txt

Tue Aug 27, 2019 11:36 am

HawaiianPi wrote:
Sat Aug 17, 2019 11:49 am
Which model PI?

What OS?

What are you using for a power supply?

What kind of drive are you attempting to load the OS from?
It was only an experiment but for your info;
  • Pi Model 2B (Not 2B+)
    Buster-lite
    Raspberrypi 2.5 Amp PSU
    Copied the new Ext4 partition of a working installation from MicroSD card to an external USB 2.5" hard drive, left the FAT32 partition on MicroSD card for booting purposes.
    I deleted the Ext4 partition from the MicroSD card
As original post said I changed the entry of root in the cmdline.txt file to show new external drive. I forgot to alter the /etc/fstab file - once I did that all worked fine.

Appreciate it is booting from the MicroSD card but from then on external 2.5" drive is the source.

Geffers

Return to “General discussion”