LloydPi3
Posts: 22
Joined: Fri Mar 25, 2016 1:53 am

Re: STICKY: HOWTO: Move the filesystem to a USB stick/Drive

Wed May 23, 2018 7:24 pm

Did you make sure you had 2 partitions? Make sure you have 2 partitions by typing sudo blkid – should show sda1 and sda2 where before it was sda1.

There should have been two n commands in gdisk.

This is what I did - following the instructions on the first page
A Before using gdisk need to make sure the HDD is available
1. lsusb to make sure the HDD is recognized & sudo blkid to make sure the HDD is /dev/sda1
2. We do not want it mounted.
B. Use gdisk
1. Type sudo gdisk /dev/sda
a. Finds something just delete it by typing command d (asked for what partition had to type 1 and then d and 2)
2. next command type n
a. Partion # type 1
b. First Sector Hit ENTER (ie accept as is)
c. Last sector I went with +10G or +250G whatever you want the first partition to be - make it large enough to add programs
d. Hex code Hit ENTER
3. Make another partition by typing n - could make more than 1 partition but not necessary
a. Partition # Hit ENTER
b. First sector Hit ENTER
c. Last sector Hit ENTER (uses the rest of the USB drive)
d. Hex Code Hit Enter
4. Verify by typing v
5. Write the partitions by typing w
6. Make sure you have 2 partitions by typing sudo blkid – should show sda1 and sda2 where before it was sda1.
C. Now we need to format the partitions
1. sudo mke2fs -t ext4 -L rootfs /dev/sda1
a. Said it was last mounted on /media/pi/rootfs proceed anyway and I said y
b. Takes a while writing superblocks and filesystem accounting –
2. sudo mke2fs -t ext4 -L my_data /dev/sda2 **** change the label name or you will have to use e2label

sineverba
Posts: 12
Joined: Tue Jul 16, 2013 3:27 pm

Re: STICKY: HOWTO: Move the filesystem to a USB stick/Drive

Sun Jun 10, 2018 11:00 am

HI to all,
I did follow procedure in first page. I have a PI1 and last Raspbian stretch (april 2018).

I did notice that last /fstab is a bit different, by the way I did follow the entry for

Code: Select all

/dev/disk-by-uuid
Of course, I did change also the cmdline.txt.

After the reboot, PI hangs with emergency mode and complains with

Code: Select all

Dependency failed for File System Check on /dev/disk/by-partuuid/5cxxxx
Dependency failed for /boot
Dependency failed for Local File System
Any suggest? Thank you very much

This is my fstab:

Code: Select all

proc            /proc           proc    defaults          0       0
PARTUUID=5c1ec57d-01  /boot           vfat    defaults          0       2
#PARTUUID=5c1ec57d-02  /               ext4    defaults,noatime  0       1
#/dev/disk/by-uuid/76929594-b034-4599-8f31-34af1ae2ff79 /       ext4    defaults,noatime 0 1
#PARTUUID=7F58C5CF-67B0-4868-A46F-73D87718DA4E  /       ext4    defaults,noatime 0 1
/dev/disk/by-uuid/76929594-b034-4599-8f31-34af1ae2ff79  /       ext4    defaults,noatime        0       1
# a swapfile is not a swap partition, no line here
#   use  dphys-swapfile swap[on|off]  for that
tmpfs   /tmp/log        tmpfs   nodev,nosuid,size=50M 0 0
And this is the cmdline.txt edited

Code: Select all

dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=PARTUUID=7f58c5cf-67b0-4868-a46f-73d87718da4e rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait
And at the end I did add the

Code: Select all

program_usb_timeout=1
to the config.txt

donbrew
Posts: 52
Joined: Sun Sep 04, 2016 2:32 pm

Re: STICKY: HOWTO: Move the filesystem to a USB stick/Drive

Sun Jul 15, 2018 3:03 pm

I used this procedure a few months ago with Jessie, it worked perfectly.

Yesterday I tried it with a updated Stretch; there are a couple of oddities.
rootfs auto mounts on /media/pi/rootfs
I also have a ntfs partition with lots of data on it
The problem with auto mounting is that rsync copies all of the data on the mount points, that fills the 20 Gb root very fast..

The work around was to exclude /media/ and /mnt/ in the rsync command
I mounted the new partition /dev/sda1 on /mnt/pihdd1 instead of mnt

sudo rsync -axv --exclude /media/ /mnt/ / /mnt/pihdd1

I am writing this from memory, so maybe some tinkering is needed.

DirkS
Posts: 9235
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: STICKY: HOWTO: Move the filesystem to a USB stick/Drive

Sun Jul 15, 2018 3:16 pm

donbrew wrote: rootfs auto mounts on /media/pi/rootfs
Looks as if it's automounted by the filemanager in the GUI (pcmanfm)
If that's the case then you can switch it off in the preferences.
donbrew wrote:
Sun Jul 15, 2018 3:03 pm
The problem with auto mounting is that rsync copies all of the data on the mount points, that fills the 20 Gb root very fast..

The work around was to exclude /media/ and /mnt/ in the rsync command
I mounted the new partition /dev/sda1 on /mnt/pihdd1 instead of mnt

sudo rsync -axv --exclude /media/ /mnt/ / /mnt/pihdd1
If you use -x (or --one-file-system) then you should not need the exclusions. It should stop at the mount points.

NoNameHere
Posts: 8
Joined: Mon Jun 19, 2017 10:38 am

Re: STICKY: HOWTO: Move the filesystem to a USB stick/Drive

Tue Jul 31, 2018 5:41 pm

I wonder if somebody managed to pull this off with an img file on a NTFS partition on a USB HDD.
The kernel should have a read-only NTFS driver built-in, so my first attempt was to set the NTFS partition as a root partition and see what it does. It didn't give any warnings about rootfstype=ntfs, but it completely refused to mount it either (Tried with both root=PARTUUID=*uuid* and plain root=/dev/sda1). rootwait made it just hang endlessly, no rootwait made it crash instantly without the root partition mounted.
My next attempt was to leave the cmdline.txt as it was, rename the /sbin/init to something else so that I got sh without pretty much booting the Raspbian, and try to do something from there. That got me to sucessfully mounting the NTFS partition and then mounting the img file on a loopback, but not much further than that. pivot_root fails with pivot_root: device or resource busy. Googling tells that this may be from /proc still mounted, but the /proc was never mounted here. I suspect NTFS-3G with its mount.ntfs-3g process still running may prevent the root change, but I don't know really.

Once again, maybe someone knows a proper way to do this?

lucian
Posts: 12
Joined: Wed May 08, 2013 10:33 am

Re: STICKY: HOWTO: Move the filesystem to a USB stick/Drive

Tue Jul 31, 2018 9:17 pm

Hello all,

This is a great guide. I have followed it for a pi raspberry pi 3b with raspbian installed and worked perfectly. I have later tried to apply the same guide on another raspberry pi 3b+ with osmc but for some weird reason after I do all the things in the guide the system will not boot. It will tell me that there are some errors on the /dev/sda1 device with the bad superblock. Is there a way to apply this guide to move the osmc system to a usb? I cannot use the official osmc installer.
Cheers

messypotamia
Posts: 54
Joined: Tue Jan 27, 2015 12:12 am

Re: STICKY: HOWTO: Move the filesystem to a USB stick/Drive

Wed Sep 26, 2018 3:17 pm

Starting to change my PI3's which are very busy with weather software to only boot from the SD then all read/writes are performed on the USB stick because of SD corruption. My first attempt at follow paulv's instructions was successful (thanks paulv) however I have noticed one anomaly which relates to the /var/log/syslog. Here's a pertinent screenshot which should describe what's happening.

Code: Select all

[email protected]:~ $ sudo logger powercrash2
[email protected]:~ $ tail /var/log/syslog
<...Snip...>
Sep 26 16:56:57 PI3Bplus pi: powercrash2
[email protected]:~ $ cat /var/log/syslog | tail | grep powercrash
Sep 26 16:56:57 PI3Bplus pi: powercrash2
[email protected]:~ $ cat /var/log/syslog |grep powercrash
Binary file (standard input) matches
[email protected]:~ 
As you can see, I write a test entry to syslog, I pipe a cat of the whole file thru |tail| and it picks it up, however, if I cat the syslog then directly into the grep, it doesn't pick it up and gives me a response I haven't seen before. On another Pi3 which I haven't yet moved the system to a USC stick, this doesn't happen. Anybody have an explanation for this? I rely on some scripts to reliably write to syslog, and when I'm testing.
Thanks! --MP

messypotamia
Posts: 54
Joined: Tue Jan 27, 2015 12:12 am

Re: STICKY: HOWTO: Move the filesystem to a USB stick/Drive

Fri Sep 28, 2018 8:20 am

messypotamia wrote:
Wed Sep 26, 2018 3:17 pm
Starting to change my PI3's which are very busy with weather software to only boot from the SD then all read/writes are performed on the USB <<SNIP>>
Anybody have an explanation for this? I rely on some scripts to reliably write to syslog, and when I'm testing.
Thanks! --MP
I discovered that, although I've never seen this before, it probably has nothing to do with moving the system to a USB stick; rather, somehow binary characters are being written to the syslog and grep (et al) has a hard time picking them out unless you tell it to include binary. Sorry for the trouble, leaving this just in case for someone else.

Naoned
Posts: 1
Joined: Sun Oct 07, 2018 7:02 am

Re: STICKY: HOWTO: Move the filesystem to a USB stick/Drive

Sun Oct 07, 2018 7:33 am

Hi

This tutorial is super well done! I am using a 32 GB 32 msata SSD drive in the Inateck case that runs on the Raspberry PI 3 Raspbian stretch!

[email protected]_3:~ $ sudo nano /etc/fstab

proc /proc proc defaults 0 0
PARTUUID=dcf7fcf9-01 /boot vfat defaults 0 2
PARTUUID=d7931bd4-3e99-448e-b5fe-f941c40b7ac6 / ext4 defaults,noatime 0 1
PARTUUID=9e43c454-5baf-4ec3-8796-36c29272ccec /mnt/my_data ext4 defaults 0 1

# PARTUUID=dcf7fcf9-02 / ext4 defaults,noatime 0 1
# a swapfile is not a swap partition, no line here
# use dphys-swapfile swap[on|off] for that

However, I have two questions:

How to access now all my SD card?

How to move the folder / home / pi / Documents in the 2nd partition my_data?

thanks in advance

Naoned

Return to “Advanced users”