Welcome! Log In Create A New Profile

Advanced

Switch from SATA to USB boot

Posted by saschadd 
Switch from SATA to USB boot
July 08, 2017 06:00PM
I am running the NSA325v2 on Debian booted from sata and would like to switch the nsa325v2 from the sata
only boot to a way where i can send the sata drives to sleep so that i somehow a standby mode.
Now i have some stuff already installed and configured on the sata system and would like to reuse this system on the usb drive.
Is it possible to reuse the sata rootfs on the usb drive by copying over?
Can i do this while the nas is running the sata system?
If possible could you give me a hint how to do this please?

After that i still need to change some uboot settings so that it boots from usb, right?

-
happy hacking,

saschadd
Re: Switch from SATA to USB boot
July 08, 2017 06:33PM
saschadd,

> I am running the NSA325v2 on Debian booted from sa
> ta and would like to switch the nsa325v2 from the
> sata
> only boot to a way where i can send the sata drive
> s to sleep so that i somehow a standby mode.
> Now i have some stuff already installed and config
> ured on the sata system and would like to reuse th
> is system on the usb drive.
> Is it possible to reuse the sata rootfs on the usb
> drive by copying over?

Yes.

> Can i do this while the nas is running the sata sy
> stem?

It can be done, but not a good idea.

> After that i still need to change some uboot setti
> ngs so that it boots from usb, right?

If you have installed my u-boot and its default envs, there is no need to adjust anything. As long as you have only one pafrtition with label rootfs, it does not matter which or how many drives you have in the system.

> If possible could you give me a hint how to do thi
> s please?

I will write a different post for it below.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Cloning from SATA to USB rootfs
July 09, 2017 03:39AM
Cloning from SATA to USB rootfs Instruction

There are 2 different ways to clone a rootfs from HDD to USB (and vice versa).

1. Take rootfs off line (shutdown the box), bring it to another Linux computer and use the tar command. This approach is described here:

http://forum.doozan.com/read.php?2,12096,24034#msg-24034

2. For whatever reason, if you're booting with HDD rootfs, and don't want to uninstall it and use a toaster (HDDs dock) to clone it to a USB drive on another Linux computer. Then this is how it can be done using 2 USB drives. The 1st one is a temprary rootfs, the 2nd USB drive will be the future rootfs that you are cloning the HDD rootfs into.

In this procedure, I'm using the NSA325 currently booting with the rootfs on an internal HDD. And this NSA325 u-boot is the latest NSA325 u-boot from this thread. (previous version might work, but please ask this question before trying).

While the NSA325 is running, login as root user. This is important, you must be root.

a. Create the Debian 4.4 rootfs on the 1st USB drive. This is to boot the NSA325v2 temporarily. It should be label rootfs as instructed in the kernel rootfs thread for Kirkwood boxes.

b. Format the 2nd USB drive as you wish to have for the new USB rootfs: a single ext3 or ext4 partition, and then label it usb_rootfs. This will be the future rootfs.

Assuming it is assigned /dev/sdc1
tune2fs -L usb_rootfs /dev/sdc1

b. Relabel the HDD rootfs to sata_rootfs
tune2fs -L sata_rootfs /dev/sda1

c. Remove the 2nd USB drive. Keep the first USB drive attached, sync and reboot.

sync
shutdown -r now

d. After this you will be booted into the 1st USB rootfs with the NSA325. Log in as root/root.

e. Plug in the 2nd USB drive, mount it.

f. Copy the SATA rootfs to the 2nd USB drive. Assuming the 2nd USB drive is mounted as /media/sdc1. The SATA HDD is mounted as /media/sda1.

cd /media/sdc1
time cp -aR /media/sda1/* . &

g. When the copying is done, it will print the time statistics. Now do a sync and relabel the drive

sync
tune2fs -L rootfs /dev/sdc1

h. Shutdown the box, and remove the 1st USB drive. At this point the new USB rootf will be the one to boot (since it is labeled as rootfs).

i. Power up. The SATA drive will be mounted as the data drive, with label sata_rootfs.

You should do a few rebooting cycles to make sure that evreything is working. And then backup the USB rootfs drive. And then use the SATA drive as you wish (reformat to Ext4, relabel as MEDIA, ....).

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)



Edited 2 time(s). Last edit at 07/09/2017 03:55AM by bodhi.
Re: Cloning from SATA to USB rootfs
July 09, 2017 07:29AM
@Bodhi: I strongly don't recommend using a cp utility to copy/backup a live filesystem as you mentioned above in f section. The reason is simply a live filesystem contains /proc subdirectory whose files may and/or may not be copied (Hint: do a google search on this). If one must use the cp utility to copy/backup a live filesystem, perhaps perusing this discussion thread to learn more about what other copy utility, i.e. rsync, etc., can do in this matter.

FYI, my preference to copy and/or backup a Linux filesystem is to use tar over cp utility, (see my post).
Re: Cloning from SATA to USB rootfs
July 09, 2017 04:37PM
habibie,

As the saying goes: a little knowledge is a dangerous thing. But since we are only doing this as hobby, no harm will be caused by your advice, only some wasted time googling :))

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)



Edited 1 time(s). Last edit at 07/09/2017 04:39PM by bodhi.
Re: Switch from SATA to USB boot
July 18, 2017 05:35AM
I think @bodhi's sequence of commands will work fine, so just adding to this as an option ... I generally use always the same command for migrating a Debian installation, which always seems to work fine :

rsync -aAXv --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} / /path/to/backup/folder


Source : https://wiki.archlinux.org/index.php/rsync#Full_system_backup

BR

Don Charisma ... because anything is possible with Charisma

My blog - http://DonCharisma.org
Our commercial site - http://DonCharisma.com
Re: Switch from SATA to USB boot
July 19, 2017 07:05PM
Don,

Yes. There are many ways to skin the same cat :) cp, tar, rsync will work fine. But here is my list of reasons why one should prefer an approach over another.

1. Speed

Use cp to copy rootfs, if you want it done the quickest way, and don't need to create a backup, while doing this. And keep in mind that the rootfs should be off-line. /proc /sys /dev should not be copied, so take the rootfs off-line to clone it.

2. tar process achieves moderate speed and make a backup in the process, too. The rootfs should be off-line, too.

3. rsync is slowest, but if rootfs cloning is done live over the LAN, then it's the fastest and best approach. And it is most flexible, since you can interrupt the cloning and restart. I have several backup jobs running rsync daily.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)



Edited 2 time(s). Last edit at 07/20/2017 03:25AM by bodhi.
Re: Switch from SATA to USB boot
July 19, 2017 07:37PM
@bodhi ... very well put :) ... and yes, I just had a CPU hogging rsync on GFN, so makes perfect sense

Don Charisma ... because anything is possible with Charisma

My blog - http://DonCharisma.org
Our commercial site - http://DonCharisma.com
Re: Switch from SATA to USB boot
July 26, 2017 02:00AM
Thanks guys for the inputs.

I got it copied with bodhis approach with 2 usb drives which worked very well.
Now i only have to activate harddrive sleep as they are still always spinning.
But thats another thing to do which is not part of this thread. ;)

-
happy hacking,

saschadd
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: