[Tutorial - Outdated] RPi: - Move the filesystem to a USB Drive
[Tutorial - Outdated] RPi: - Move the filesystem to a USB Drive
Hey guys,
I was just wondering if it is possible to boot dietpi from a USB drive? I've been reading that this massively increases speed/performance of the Pi and would love to be able to do so with the already amazing Dietpi. Currently have a B+ as well as a Pi3 running Dietpi and would love to give the Pi3 even more performance power for Owncloud
I have a 128GB USB3 drive.
I hope you can help,
thanks,
P
I was just wondering if it is possible to boot dietpi from a USB drive? I've been reading that this massively increases speed/performance of the Pi and would love to be able to do so with the already amazing Dietpi. Currently have a B+ as well as a Pi3 running Dietpi and would love to give the Pi3 even more performance power for Owncloud
I have a 128GB USB3 drive.
I hope you can help,
thanks,
P
Re: Boot Dietpi from USB?
Hi jedisha,
Yes, you can run your DietPi system and all installed software from USB drive.
But to boot your RPi, you must have insert SD-Card any time. Without RPi will not boot. ( /boot/... must be on /dev/mmcblk0p1)
I would suggest, before you will change your root device, to Benchmarks your new Filesystem. Only read/write speed have a significant difference, it will have effect.
To do this, insert only one USB drive and reboot.
/dev/sda1 => is the new and only USB drive, mounted on: /mnt/usb_1
WARNING: if you answer "y" all data on USB drive will be lost.
10 Tools => Benchmarks Filesystem and RAM benchmarks => Flash Storage, USB Drive => Benchmark IO performance.
If the result is like you expect, we can guide you through the necessary changes.
cu
k-plan
Yes, you can run your DietPi system and all installed software from USB drive.
But to boot your RPi, you must have insert SD-Card any time. Without RPi will not boot. ( /boot/... must be on /dev/mmcblk0p1)
I would suggest, before you will change your root device, to Benchmarks your new Filesystem. Only read/write speed have a significant difference, it will have effect.
To do this, insert only one USB drive and reboot.
Code: Select all
root@oDroid-C1-Plus-Test:~# df -h
Dateisystem Größe Benutzt Verf. Verw% Eingehängt auf
/dev/mmcblk0p2 7,1G 579M 6,5G 9% /
udev 10M 0 10M 0% /dev
tmpfs 190M 5,4M 185M 3% /run
tmpfs 475M 0 475M 0% /dev/shm
tmpfs 5,0M 0 5,0M 0% /run/lock
tmpfs 475M 0 475M 0% /sys/fs/cgroup
tmpfs 10M 1,1M 9,0M 11% /DietPi
tmpfs 20M 12K 20M 1% /var/log
tmpfs 475M 0 475M 0% /tmp
/dev/mmcblk0p1 129M 25M 104M 20% /boot
/dev/sda1 57G 2,4G 52G 5% /mnt/usb_1
Code: Select all
root@oDroid-C1-Plus-Test:~# /DietPi/dietpi/dietpi-external_drive_setup
Code: Select all
--------------------------------
D I E T - P I
External Drive Setup
--------------------------------
An Existing ext4 Drive has Been Found
Dateisystem Größe Benutzt Verf. Verw% Eingehängt auf
/dev/sda1 57G 2,4G 52G 5% /mnt/usb_1
Would you like to format this drive? [y/N]
Code: Select all
root@oDroid-C1-Plus-Test:~# dietpi-config
If the result is like you expect, we can guide you through the necessary changes.
cu
k-plan
Last edited by k-plan on Sun Apr 24, 2016 6:47 pm, edited 1 time in total.
OUTDATED: Boot Dietpi from USB?
Hi,
edit by k-plan:
This Tutorial is outdated!
You can now use DietPi-Drive Manager.
It's more simple and do all the steps for you with more options.
System:
DietPi V116 | Raspberry Pi B+ (e.g. in my case a fresh installation)
Micro SD-Card: Verbatim 8GB Class 10 Micro SDHC
USB Device: Patriot 32GB USB 3.0 drive
Boot up time: ca. 40 sec
Note:
Why to use this "extended version"? (only 25 easy steps :shock: )
Because it's possible to use more than only one drive attached to your RPi.
# Preparation
- Make sure, " max_usb_current=1 " is proper set:
4 Advanced Options => 3 Max USB Current : Enabled
- Install some tools we’ll need later:
- Insert USB drive and check to see if usb is recognized:
- Locate the USB device name ( /dev/sdx ):
In this example, USB device is on sda. From this point on we use /dev/sda for the USB drive.
- Writing partition table to USB drive:
- Delete old partition(s) with d :
- Make your new partition with n , when prompted to enter information hit Enter to use defaults:
- Write the changes with w :
- Continue with formatting :
- Mounting USB device:
- Benchmark Filesystem and RAM IO performance
10 Tools => Benchmarks Filesystem and RAM benchmarks => Flash Storage, USB Drive, RAM => Benchmark IO performance.
# Preparing to change root device (system)
- Now we need Partition unique GUID (PARTUUID) of the USB device:
- Get the Partition unique GUID information with i and finish with q
e.g. Partition unique GUID: 7D25B382-0D0F-4EDD-B044-E41ADE98A451
- Backup your cmdline.txt file and edit it to include your new partition:
- Edit the file and change your “root=” to point to new filesystem partition with the find out Partition unique GUID (PARTUUID)
Watch for " rootdelay=10 " and save the file!
- Stop the services:
- Copy the filesystem over to your new partition:
Be patient - this will take some time!
- Get your partition UUID for fstab:
e.g. UUID=2c35b4da-c18a-4277-9db4-2ba592475e26
- Backup and edit the fstab file on your new filesystem:
- Comment out the old filesystem at /dev/mmcblk0p2 and add the new line pointing to your new filesystem and add your UUID as indicated.
- Comment out External Drives at /dev/sda1 ___ /mnt/usb_1 :
and save the file!
- Unmount your USB device:
- Cross the fingers and reboot your RPi:
Note that you will not see much activity on the ACT LED anymore. This LED only shows R/W activity on the SD card.
If your USB device have a activity LED, you can check here R/W activity.
Boot up time is now: ca. 30 sec
- After the RPi has booted, check the filesystem:
- Create a new swap file (e.g. 101 MB):
dietpi-config => 4 Advanced Options => 1 Swapfile Size
- Now benchmark filesystem and RAM IO performance again:
.. and reboot.
Note:
- To boot your RPi, you must have insert SD-Card at any time. Without RPi will not boot.
- If somethings goes wrong or your RPi doesn't boot, power off your RPi, put RPI SD-Card into your PC and restore " cmdline.txt.sdcard " to " cmdline.txt " on the DOS (FAT) partition named "boot"
Put edited SD-Card back into your RPi and power on. It will boot and run the system (DietPi) now from SD-Card like before your modifications.
------
Some useful Links, which have aided to make this howto:
https://www.raspberrypi.org/forums/view ... 29&t=44177
http://www.kupply.com/move-your-raspber ... -10-steps/
edit by k-plan:
This Tutorial is outdated!
You can now use DietPi-Drive Manager.
It's more simple and do all the steps for you with more options.
System:
DietPi V116 | Raspberry Pi B+ (e.g. in my case a fresh installation)
Micro SD-Card: Verbatim 8GB Class 10 Micro SDHC
USB Device: Patriot 32GB USB 3.0 drive
Boot up time: ca. 40 sec
Note:
Why to use this "extended version"? (only 25 easy steps :shock: )
Because it's possible to use more than only one drive attached to your RPi.
# Preparation
- Make sure, " max_usb_current=1 " is proper set:
Code: Select all
root@RPi-B-Plus:~# dietpi-config
Code: Select all
root@RPi-B-Plus:~# apt-get install gdisk rsync
Code: Select all
root@RPi-B-Plus:~# lsusb
Bus 001 Device 005: ID 13fe:5000 Kingston Technology Company Inc.
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Code: Select all
rroot@RPi-B-Plus:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 1 29.5G 0 disk
└─sda1 8:1 1 29.5G 0 part
mmcblk0 179:0 0 7.4G 0 disk
├─mmcblk0p1 179:1 0 60M 0 part /boot
└─mmcblk0p2 179:2 0 7.4G 0 part /
- Writing partition table to USB drive:
Code: Select all
root@RPi-B-Plus:~# gdisk /dev/sda
GPT fdisk (gdisk) version 0.8.10
Partition table scan:
MBR: MBR only
BSD: not present
APM: not present
GPT: not present
***************************************************************
Found invalid GPT and valid MBR; converting MBR to GPT format
in memory. THIS OPERATION IS POTENTIALLY DESTRUCTIVE! Exit by
typing 'q' if you don't want to convert your MBR partitions
to GPT format!
***************************************************************
Warning! Main partition table overlaps the first partition by 32 blocks!
You will need to delete this partition or resize it in another utility.
Warning! Secondary partition table overlaps the last partition by
33 blocks!
You will need to delete this partition or resize it in another utility.
Command (? for help): i
Using 1
Partition GUID code: EBD0A0A2-B9E5-4433-87C0-68B6B72699C7 (Microsoft basic data)
Partition unique GUID: FFEE1EB9-FE0D-4422-A3BE-5DEC4CB9F1DA
First sector: 2 (at 1024 bytes)
Last sector: 61800447 (at 29.5 GiB)
Partition size: 61800446 sectors (29.5 GiB)
Attribute flags: 0000000000000000
Partition name: 'Microsoft basic data'
Code: Select all
Command (? for help): d
Using 1
Code: Select all
Command (? for help): n
Partition number (1-128, default 1):
First sector (34-61800414, default = 34) or {+-}size{KMGTP}:
Last sector (34-61800414, default = 61800414) or {+-}size{KMGTP}:
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300):
Changed type of partition to 'Linux filesystem'
Code: Select all
Command (? for help): w
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!
Do you want to proceed? (Y/N): Y
OK; writing new GUID partition table (GPT) to /dev/sda.
The operation has completed successfully.
Code: Select all
root@RPi-B-Plus:~# mke2fs -t ext4 -L rootfs /dev/sda1
mke2fs 1.42.12 (29-Aug-2014)
Creating filesystem with 7725047 4k blocks and 1933312 inodes
Filesystem UUID: 2c35b4da-c18a-4277-9db4-2ba592475e26
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
Code: Select all
root@RPi-B-Plus:~# mount /dev/sda1 /mnt/usb_1/
Code: Select all
root@RPi-B-Plus:~# dietpi-config
# Preparing to change root device (system)
- Now we need Partition unique GUID (PARTUUID) of the USB device:
Code: Select all
root@RPi-B-Plus:~# gdisk /dev/sda
GPT fdisk (gdisk) version 0.8.10
Partition table scan:
MBR: protective
BSD: not present
APM: not present
GPT: present
Found valid GPT with protective MBR; using GPT.
Code: Select all
Command (? for help): i
Using 1
Partition GUID code: 0FC63DAF-8483-4772-8E79-3D69D8477DE4 (Linux filesystem)
Partition unique GUID: 7D25B382-0D0F-4EDD-B044-E41ADE98A451
First sector: 34 (at 17.0 KiB)
Last sector: 61800414 (at 29.5 GiB)
Partition size: 61800381 sectors (29.5 GiB)
Attribute flags: 0000000000000000
Partition name: 'Linux filesystem'
Command (? for help): q
- Backup your cmdline.txt file and edit it to include your new partition:
Code: Select all
root@RPi-B-Plus:~# cp /boot/cmdline.txt /boot/cmdline.txt.sdcard
root@RPi-B-Plus:~# nano /boot/cmdline.txt
Code: Select all
dwc_otg.lpm_enable=0 console=tty1 root=PARTUUID=7D25B382-0D0F-4EDD-B044-E41ADE98A451 rootfstype=ext4 elevator=noop fsck.repair=yes rootwait rootdelay=10
- Stop the services:
Code: Select all
root@RPi-B-Plus:~# /DietPi/dietpi/dietpi-services stop
Code: Select all
root@RPi-B-Plus:~# rsync -axv / /mnt/usb_1/
...
sent 756,662,697 bytes received 348,462 bytes 2,737,834.21 bytes/sec
total size is 755,276,856 speedup is 1.00
- Get your partition UUID for fstab:
Code: Select all
root@RPi-B-Plus:~# tune2fs -l /dev/sda1
tune2fs 1.42.12 (29-Aug-2014)
Filesystem volume name: rootfs
Last mounted on: /mnt/usb_1
Filesystem UUID: 2c35b4da-c18a-4277-9db4-2ba592475e26
...
- Backup and edit the fstab file on your new filesystem:
Code: Select all
root@RPi-B-Plus:~# cp /mnt/usb_1/etc/fstab /mnt/usb_1/etc/fstab.sdcard
root@RPi-B-Plus:~# nano /mnt/usb_1/etc/fstab
Code: Select all
#Internal Drives---------------------------------------------------
proc /proc proc defaults 0 0
/dev/mmcblk0p1 /boot vfat defaults,noatime,discard 0 2
## root on SD-card
### /dev/mmcblk0p2 / ext4 defaults,noatime,discard 0 1
## root on USB device
/dev/disk/by-uuid/2c35b4da-c18a-4277-9db4-2ba592475e26 / ext4 defaults,noatime,nodiratime 0 1
tmpfs /tmp tmpfs defaults,noatime,nodev,nosuid,mode=1777 0 0
tmpfs /var/log tmpfs defaults,size=20m,noatime,nodev,nosuid,mode=1777 0 0
tmpfs /DietPi tmpfs defaults,size=10m,noatime,nodev,nosuid,mode=1777 0 0
Code: Select all
#External Drives---------------------------------------------------
# - Try and use only ext4 for USB drives
# - Faster performance than NTFS, espically on RPi v1
## /dev/sda1 /mnt/usb_1 ext4 defaults,noatime,nofail 0 0
#/dev/sda1 /mnt/usb_1 ntfs-3g defaults,permissions,noatime,nofail 0 0
- Unmount your USB device:
Code: Select all
root@RPi-B-Plus:~# umount /dev/sda1
Code: Select all
root@RPi-B-Plus:~# reboot
If your USB device have a activity LED, you can check here R/W activity.
Boot up time is now: ca. 30 sec
- After the RPi has booted, check the filesystem:
Code: Select all
root@RPi-B-Plus:~# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 29G 813M 27G 3% /
devtmpfs 238M 0 238M 0% /dev
tmpfs 242M 0 242M 0% /dev/shm
tmpfs 242M 4.4M 237M 2% /run
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 242M 0 242M 0% /sys/fs/cgroup
tmpfs 10M 1.1M 9.0M 11% /DietPi
tmpfs 20M 12K 20M 1% /var/log
tmpfs 242M 0 242M 0% /tmp
/dev/mmcblk0p1 60M 22M 39M 36% /boot
Code: Select all
root@RPi-B-Plus:~# dietpi-config
Note:
- To boot your RPi, you must have insert SD-Card at any time. Without RPi will not boot.
- If somethings goes wrong or your RPi doesn't boot, power off your RPi, put RPI SD-Card into your PC and restore " cmdline.txt.sdcard " to " cmdline.txt " on the DOS (FAT) partition named "boot"
Put edited SD-Card back into your RPi and power on. It will boot and run the system (DietPi) now from SD-Card like before your modifications.
------
Some useful Links, which have aided to make this howto:
https://www.raspberrypi.org/forums/view ... 29&t=44177
http://www.kupply.com/move-your-raspber ... -10-steps/
Last edited by k-plan on Thu Sep 27, 2018 4:11 pm, edited 3 times in total.
Reason: Info updated !
Reason: Info updated !
Re: Boot Dietpi from USB?
EXcellent write-up k-plan. Thanks for sharing 

If you find our project or support useful, then we’d really appreciate it if you’d consider contributing to the project however you can.
Donating is the easiest – you can use PayPal or become a DietPi patron.
Donating is the easiest – you can use PayPal or become a DietPi patron.
Re: Boot Dietpi from USB?
Hey k-plan,
thx for your guide.
1 question in front:
On a fresh installation should I answer the question if I want to use an USB-Drive with yes or no?
I tried to use it on my Adroid-C2, but there is no /boot/cmdline.txt there only a boot.ini and this file looks different than your cmdline.txt.
So what do I have to put in there, if it is the right file.
Any hint?
Thx in adavance,
mike175de
thx for your guide.
1 question in front:
On a fresh installation should I answer the question if I want to use an USB-Drive with yes or no?
I tried to use it on my Adroid-C2, but there is no /boot/cmdline.txt there only a boot.ini and this file looks different than your cmdline.txt.
So what do I have to put in there, if it is the right file.
Any hint?
Thx in adavance,
mike175de
Re: Boot Dietpi from USB?
Hi mike,
If you want to only Data and Applications on the USB-Drive, but keep system and boot files on SD-Card, then answer "yes".
The rest will do DietPi for you.
Sorry, but for now it's to late for writing a guide. Will do it later.
If you want to swap over the hole system to your USB-Drive, I will prefer to answer "NO" at this point.mike175de wrote:1 question in front:
On a fresh installation should I answer the question if I want to use an USB-Drive with yes or no?
If you want to only Data and Applications on the USB-Drive, but keep system and boot files on SD-Card, then answer "yes".
The rest will do DietPi for you.
On Odroid XU4, XU3, C1, C1+, C0 and C2 you have to edit the "boot.ini" file:mike175de wrote:I tried to use it on my Adroid-C2, but there is no /boot/cmdline.txt there only a boot.ini and this file looks different than your cmdline.txt.
So what do I have to put in there, if it is the right file.
Any hint?
Code: Select all
/DietPi/boot.ini
Re: Boot Dietpi from USB?
Hi mike,
Let us know, if it will work for you.
cu
k-plan
Done and I have put the guide in here: http://dietpi.com/phpbb/viewtopic.php?f ... 1720#p1720Sorry, but for now it's to late for writing a guide. Will do it later.
Let us know, if it will work for you.
cu
k-plan
Re: Boot Dietpi from USB?
Hey k-plan,
yes it did
Thx a lot for your tut again! (as thanked already in the other post)!
mike175de
yes it did

Thx a lot for your tut again! (as thanked already in the other post)!
mike175de
Re: Boot Dietpi from USB?
Wow, k-plan thank you so much!
I've not been able to check back in on this for a wahile... just read through your comprehensive tut and will try and find time to implement soon!
thx, jedisha

I've not been able to check back in on this for a wahile... just read through your comprehensive tut and will try and find time to implement soon!
thx, jedisha
DietPi Boot RPi from USB
can it be the boot problem if i use some repair disc?or it will make it worst?