Chadster766 / McDebian

Linksys WRT3200ACM, WRT1900AC, WRT1900ACS, WRT1200AC and WRT32X Router Debian Implementation
98 stars 14 forks source link

Can‘t boot due to my USB KEY is not /dev/sda1 #31

Closed zhouruixi closed 7 years ago

zhouruixi commented 7 years ago

When I plug my cz80 USB KEY(as root of mcdebian) on usb2.0, and plug my mobile hard disk on usb3.0, the kernel show me cz80 is sdb not sda.

So, how about change kernel-command-line "root=/dev/sda1" to "root=PARTUUID=A special UUID", and we just need use tune2fs to set the rootfs's UUID to the specific UUID, then the kernel will always find the correct rootfs.

Chadster766 commented 7 years ago

I think that's a great idea.

Please reply with your USB drive UUID setup process :smiley:

Then I will test it. If successful add it to the McDebian rootfs Wiki and firmwares.

ValCher1961 commented 7 years ago

The idea is good, but if the disk fails, you won't be able to connect any other drive. And you're going to have to prepare a new kernel with a new UUID.

zhouruixi commented 7 years ago

My USB KEY is /dev/sdb on my computer. If the UUID of kernel cmdline is set to "86488f88-730d-43d2-8a60-3e3a82d9573e"

A. For a new rootfs

#mkfs.ext4 -U 86488f88-730d-43d2-8a60-3e3a82d9573e /dev/sdb1 # blkid /dev/sdb1 /dev/sdb1: UUID="86488f88-730d-43d2-8a60-3e3a82d9573e" TYPE="ext4" PARTUUID="d10f7095-01"

B. For a exist rootfs

# blkid /dev/sdb1 /dev/sdb1: UUID="32fedb62-4e10-4954-bb3a-56dd39a96299" TYPE="ext4" PARTUUID="d10f7095-01"

# tune2fs -U 86488f88-730d-43d2-8a60-3e3a82d9573e /dev/sdb1 # blkid /dev/sdb1 /dev/sdb1: UUID="86488f88-730d-43d2-8a60-3e3a82d9573e" TYPE="ext4" PARTUUID="d10f7095-01"

PS:

You can change rootfs's UUID to anyone with "tune2fs -U UUID". You can get a random UUID with "cat /proc/sys/kernel/random/uuid".

ValCher1961 commented 7 years ago

Oh, I did not know that I could change the UUID.

Chadster766 commented 7 years ago

@zhouruixi thanks for the instructions. I will test them out and reply with results.

zhouruixi commented 7 years ago

@Chadster766 Does it working on your test? I'm looking for your result.

Chadster766 commented 7 years ago

Sorry I haven't tested IT yet :-)

Chadster766 commented 7 years ago

I tested and it works. @zhouruixi I'm guessing you have a WRT1200AC, the firmware with the command line change is listed below.

http://www.protechs-online.com/downloads/McDebian/firmwares/McDebian-WRT1200AC-V1-FW_VER1_kernel_4.9.31_uuid_c58bfc9b-6399-4bdd-b5cf-97cc69a3cd49.img

Changes to the process:

  1. Kernel command line change "root=PARTUUID=c58bfc9b-6399-4bdd-b5cf-97cc69a3cd49"
  2. Use gdisk to change the USB Drive to a GPT partition table (done automatically by saving partition changes)
  3. Use gdisk to change the partition type to Linux 8300
  4. Use gdisk to set the partitions GUID otherwise known as PARTUUID
  5. Format with mkfs.ext4 /dev/sda1
  6. Extract the rootfs normally

My testing seems to indicate that a rootfs with these changes will boot with the standard McDebian firmware but that firmware with the kernel command line changes won't boot without the GPT and GUID changes to the USB drive partition table.

zhouruixi commented 7 years ago

@Chadster766 Thanks for your working, I'll try it later.

zhouruixi commented 7 years ago

Yes, It works well. I had read init/do_mounts.c and I know that should use PARTUUID instead of UUID.

Thank you!

I'll close the issue. @Chadster766