Moved the /etc folder to /home under ubuntu 16.04 on TX2 by mistake. So how can I repair it.

As the title, I moved the /etc folder to /home under ubuntu 16.04 on TX2 by mistake. And now I can’t enter the ubuntu system. Also I can’t enter the command line, Ctrl+ Alt+ F1/F2/p are useless.
So how can I repair the system.

reflash the Jetpack maybe the most quick method.

oh,NO, that is the last way I want to choose…

Can you SSH in and move it that way? Perhaps not, as /etc contains the startup scripts for the system services.

If traditional methods fail, you may need to backup the disk image to host PC, then mount the image on the host and perform the edits, then re-flash the edited image to your Jetson. Although given the state of your system, it is probably more reliable to backup your files from image and then re-flash with vanilla JetPack-L4T like duanbingnan suggested.

The clone/edit/restore will work.

Could you be more specifically? Thanks a lot.

See the links from the lower part of the post above.

OK,thank you, I’m working on it.

Just a sample set of commands to explain…

With the Jetson in recovery mode and the micro-B USB connected, the host will see the Jetson from:

lstx2='lsusb -d 0955:7c18'

Your host will need free space larger than the entire file system on the Jetson. From wherever you clone you can check via “df -H .” (the “.” is important).

You can clone in R28.2 via:

sudo ./ -r -k APP -G backup.img jetson-tx1 mmcblk0p1

If you wish to save a log of the clone:

sudo ./ -r -k APP -G backup.img jetson-tx1 mmcblk0p1 2>&1 | tee clone_log.txt

You will get a “.img” file (I throw this away) and a “.img.raw” file (I keep this). You could do this:

sudo -s
mount -o loop backup.img.raw /mnt
cd /mnt/home
mv ./etc ../
cd -
umount /mnt

Copy the edited raw file to the “bootloader/system.img” location (be careful with the original…although copies of a 30GB file can be difficult to keep around).

You might need to look at the exact size of your clone before restoring. I think normally the “-S” size parameter should be ignored during flash with the “-r” (“reuse image”) option, but my latest test actually required setting this to match the clone file size. My system was flashed originally with “-S 29318MiB”, so the exact file size from the clone is “29318 * 1024 * 1024 = 30742151168” bytes. I did a restore with a log file via:

sudo ./ -r -S 29318MiB jetson-tx2 mmcblk0p1 2>&1 | tee log_restore_rootfs.txt

After that I use “bzip -9” on my clone file in a separate location from the system.img file. Note that a flash using this full sized file takes much longer than the sparse original “.raw” file, but the sparse file can never be edited…the raw file is interchangeable and can be viewed or edited.

Thank you very much indeed.
And I want to know is there any possible to use a USB disk to boot the system. So I can enter the system and fix it.

Yes, but the need to use a serial console may depend on the existing extlinux.conf…it depends on current setup. It wouldn’t hurt to try.

I sometimes copy a clone to the SD card for testing. Things will be simplified if you still have a “bootloader/system.img.raw” from a previous flash. Do you still have this in your “Linux_for_Tegra/bootloader/” directory?